@aglyn/plugins-commerce 1.0.0-beta.230 → 1.0.0-beta.231
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/package.json +13 -13
- package/src/index.d.ts +0 -1
- package/src/index.js +0 -1
- package/src/index.js.map +1 -1
- package/src/lib/barcode/barcode-decode.d.ts +71 -0
- package/src/lib/barcode/barcode-decode.js +498 -0
- package/src/lib/barcode/barcode-decode.js.map +1 -0
- package/src/lib/barcode/barcode-encode.d.ts +44 -0
- package/src/lib/barcode/barcode-encode.js +138 -0
- package/src/lib/barcode/barcode-encode.js.map +1 -0
- package/src/lib/barcode/barcode-scanner.component.d.ts +23 -0
- package/src/lib/barcode/barcode-scanner.component.js +260 -0
- package/src/lib/barcode/barcode-scanner.component.js.map +1 -0
- package/src/lib/barcode/scan-button.component.d.ts +10 -0
- package/src/lib/barcode/scan-button.component.js +62 -0
- package/src/lib/barcode/scan-button.component.js.map +1 -0
- package/src/lib/barcode/scanner-wedge.d.ts +35 -0
- package/src/lib/barcode/scanner-wedge.js +108 -0
- package/src/lib/barcode/scanner-wedge.js.map +1 -0
- package/src/lib/components/account.js +10 -1
- package/src/lib/components/account.js.map +1 -1
- package/src/lib/components/cart-extras.d.ts +45 -0
- package/src/lib/components/cart-extras.js +127 -0
- package/src/lib/components/cart-extras.js.map +1 -0
- package/src/lib/components/cart.js +82 -15
- package/src/lib/components/cart.js.map +1 -1
- package/src/lib/components/checkout-return-notice.d.ts +26 -0
- package/src/lib/components/checkout-return-notice.js +48 -0
- package/src/lib/components/checkout-return-notice.js.map +1 -0
- package/src/lib/components/commerce-console-page.js +124 -0
- package/src/lib/components/commerce-console-page.js.map +1 -1
- package/src/lib/components/commerce-console-sections.d.ts +1 -1
- package/src/lib/components/commerce-console-sections.js +4 -0
- package/src/lib/components/commerce-console-sections.js.map +1 -1
- package/src/lib/components/console/bulk-fulfill.d.ts +44 -0
- package/src/lib/components/console/bulk-fulfill.js +84 -0
- package/src/lib/components/console/bulk-fulfill.js.map +1 -0
- package/src/lib/components/console/customer-notifications-card.component.d.ts +19 -0
- package/src/lib/components/console/customer-notifications-card.component.js +149 -0
- package/src/lib/components/console/customer-notifications-card.component.js.map +1 -0
- package/src/lib/components/console/host-orders-card.component.js +84 -5
- package/src/lib/components/console/host-orders-card.component.js.map +1 -1
- package/src/lib/components/console/locations-card.component.js +164 -57
- package/src/lib/components/console/locations-card.component.js.map +1 -1
- package/src/lib/components/console/order-detail-dialog.component.js +209 -61
- package/src/lib/components/console/order-detail-dialog.component.js.map +1 -1
- package/src/lib/components/console/order-fulfillment-panel.component.d.ts +48 -0
- package/src/lib/components/console/order-fulfillment-panel.component.js +542 -0
- package/src/lib/components/console/order-fulfillment-panel.component.js.map +1 -0
- package/src/lib/components/console/order-invoice.component.d.ts +33 -0
- package/src/lib/components/console/order-invoice.component.js +81 -0
- package/src/lib/components/console/order-invoice.component.js.map +1 -0
- package/src/lib/components/console/order-receipt-resend.component.d.ts +21 -0
- package/src/lib/components/console/order-receipt-resend.component.js +203 -0
- package/src/lib/components/console/order-receipt-resend.component.js.map +1 -0
- package/src/lib/components/console/order-returns.component.d.ts +36 -0
- package/src/lib/components/console/order-returns.component.js +142 -0
- package/src/lib/components/console/order-returns.component.js.map +1 -0
- package/src/lib/components/console/order-shipping-actions.component.d.ts +54 -0
- package/src/lib/components/console/order-shipping-actions.component.js +149 -0
- package/src/lib/components/console/order-shipping-actions.component.js.map +1 -0
- package/src/lib/components/console/order-webhooks-card.component.d.ts +50 -0
- package/src/lib/components/console/order-webhooks-card.component.js +623 -0
- package/src/lib/components/console/order-webhooks-card.component.js.map +1 -0
- package/src/lib/components/console/order-zones.d.ts +155 -0
- package/src/lib/components/console/order-zones.js +40 -0
- package/src/lib/components/console/order-zones.js.map +1 -0
- package/src/lib/components/console/payment-methods-card.component.d.ts +67 -0
- package/src/lib/components/console/payment-methods-card.component.js +395 -0
- package/src/lib/components/console/payment-methods-card.component.js.map +1 -0
- package/src/lib/components/console/pos/pos-api.d.ts +124 -0
- package/src/lib/components/console/pos/pos-api.js +101 -0
- package/src/lib/components/console/pos/pos-api.js.map +1 -0
- package/src/lib/components/console/pos/pos-cart-panel.component.d.ts +36 -0
- package/src/lib/components/console/pos/pos-cart-panel.component.js +160 -0
- package/src/lib/components/console/pos/pos-cart-panel.component.js.map +1 -0
- package/src/lib/components/console/pos/pos-item-dialog.component.d.ts +39 -0
- package/src/lib/components/console/pos/pos-item-dialog.component.js +352 -0
- package/src/lib/components/console/pos/pos-item-dialog.component.js.map +1 -0
- package/src/lib/components/console/pos/pos-product-grid.component.d.ts +47 -0
- package/src/lib/components/console/pos/pos-product-grid.component.js +272 -0
- package/src/lib/components/console/pos/pos-product-grid.component.js.map +1 -0
- package/src/lib/components/console/pos/pos-receipt-panel.component.d.ts +27 -0
- package/src/lib/components/console/pos/pos-receipt-panel.component.js +282 -0
- package/src/lib/components/console/pos/pos-receipt-panel.component.js.map +1 -0
- package/src/lib/components/console/pos/pos-tender-dialogs.component.d.ts +53 -0
- package/src/lib/components/console/pos/pos-tender-dialogs.component.js +445 -0
- package/src/lib/components/console/pos/pos-tender-dialogs.component.js.map +1 -0
- package/src/lib/components/console/pos/pos-tender-panel.component.d.ts +31 -0
- package/src/lib/components/console/pos/pos-tender-panel.component.js +640 -0
- package/src/lib/components/console/pos/pos-tender-panel.component.js.map +1 -0
- package/src/lib/components/console/pos/use-pos-display.d.ts +43 -0
- package/src/lib/components/console/pos/use-pos-display.js +161 -0
- package/src/lib/components/console/pos/use-pos-display.js.map +1 -0
- package/src/lib/components/console/pos-devices-card.component.d.ts +14 -0
- package/src/lib/components/console/pos-devices-card.component.js +546 -0
- package/src/lib/components/console/pos-devices-card.component.js.map +1 -0
- package/src/lib/components/console/pos-display/brand-screen.d.ts +33 -0
- package/src/lib/components/console/pos-display/brand-screen.js +85 -0
- package/src/lib/components/console/pos-display/brand-screen.js.map +1 -0
- package/src/lib/components/console/pos-display/cart-screen.d.ts +29 -0
- package/src/lib/components/console/pos-display/cart-screen.js +166 -0
- package/src/lib/components/console/pos-display/cart-screen.js.map +1 -0
- package/src/lib/components/console/pos-display/pairing-screen.d.ts +24 -0
- package/src/lib/components/console/pos-display/pairing-screen.js +127 -0
- package/src/lib/components/console/pos-display/pairing-screen.js.map +1 -0
- package/src/lib/components/console/pos-display/pos-display-api.d.ts +90 -0
- package/src/lib/components/console/pos-display/pos-display-api.js +140 -0
- package/src/lib/components/console/pos-display/pos-display-api.js.map +1 -0
- package/src/lib/components/console/pos-display/receipt-screen.d.ts +35 -0
- package/src/lib/components/console/pos-display/receipt-screen.js +200 -0
- package/src/lib/components/console/pos-display/receipt-screen.js.map +1 -0
- package/src/lib/components/console/pos-display/tip-screen.d.ts +36 -0
- package/src/lib/components/console/pos-display/tip-screen.js +211 -0
- package/src/lib/components/console/pos-display/tip-screen.js.map +1 -0
- package/src/lib/components/console/pos-display-page.component.d.ts +16 -0
- package/src/lib/components/console/pos-display-page.component.js +407 -0
- package/src/lib/components/console/pos-display-page.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-customer-lookup.component.d.ts +40 -0
- package/src/lib/components/console/pos-ops/pos-customer-lookup.component.js +289 -0
- package/src/lib/components/console/pos-ops/pos-customer-lookup.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-last-receipt.component.d.ts +34 -0
- package/src/lib/components/console/pos-ops/pos-last-receipt.component.js +61 -0
- package/src/lib/components/console/pos-ops/pos-last-receipt.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-operations-bar.component.d.ts +38 -0
- package/src/lib/components/console/pos-ops/pos-operations-bar.component.js +129 -0
- package/src/lib/components/console/pos-ops/pos-operations-bar.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-ops-api.d.ts +37 -0
- package/src/lib/components/console/pos-ops/pos-ops-api.js +60 -0
- package/src/lib/components/console/pos-ops/pos-ops-api.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-pin-pad.component.d.ts +48 -0
- package/src/lib/components/console/pos-ops/pos-pin-pad.component.js +220 -0
- package/src/lib/components/console/pos-ops/pos-pin-pad.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-receipt-actions.component.d.ts +63 -0
- package/src/lib/components/console/pos-ops/pos-receipt-actions.component.js +186 -0
- package/src/lib/components/console/pos-ops/pos-receipt-actions.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-receipt.d.ts +39 -0
- package/src/lib/components/console/pos-ops/pos-receipt.js +182 -0
- package/src/lib/components/console/pos-ops/pos-receipt.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-return-dialog.component.d.ts +40 -0
- package/src/lib/components/console/pos-ops/pos-return-dialog.component.js +465 -0
- package/src/lib/components/console/pos-ops/pos-return-dialog.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-shift-history-card.component.d.ts +29 -0
- package/src/lib/components/console/pos-ops/pos-shift-history-card.component.js +253 -0
- package/src/lib/components/console/pos-ops/pos-shift-history-card.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-shift-panel.component.d.ts +34 -0
- package/src/lib/components/console/pos-ops/pos-shift-panel.component.js +494 -0
- package/src/lib/components/console/pos-ops/pos-shift-panel.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-shift-report.component.d.ts +37 -0
- package/src/lib/components/console/pos-ops/pos-shift-report.component.js +102 -0
- package/src/lib/components/console/pos-ops/pos-shift-report.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-staff-pins-card.component.d.ts +30 -0
- package/src/lib/components/console/pos-ops/pos-staff-pins-card.component.js +277 -0
- package/src/lib/components/console/pos-ops/pos-staff-pins-card.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/register-ops.d.ts +28 -0
- package/src/lib/components/console/pos-ops/register-ops.js +28 -0
- package/src/lib/components/console/pos-ops/register-ops.js.map +1 -0
- package/src/lib/components/console/pos-ops/use-pos-cashier.d.ts +46 -0
- package/src/lib/components/console/pos-ops/use-pos-cashier.js +128 -0
- package/src/lib/components/console/pos-ops/use-pos-cashier.js.map +1 -0
- package/src/lib/components/console/pos-ops/use-pos-sale-receipt.d.ts +36 -0
- package/src/lib/components/console/pos-ops/use-pos-sale-receipt.js +64 -0
- package/src/lib/components/console/pos-ops/use-pos-sale-receipt.js.map +1 -0
- package/src/lib/components/console/pos-page.component.d.ts +13 -5
- package/src/lib/components/console/pos-page.component.js +729 -657
- package/src/lib/components/console/pos-page.component.js.map +1 -1
- package/src/lib/components/console/product-editor-dialog.component.js +51 -7
- package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
- package/src/lib/components/console/product-labels-dialog.component.d.ts +13 -0
- package/src/lib/components/console/product-labels-dialog.component.js +197 -0
- package/src/lib/components/console/product-labels-dialog.component.js.map +1 -0
- package/src/lib/components/console/product-register-fields.component.d.ts +19 -0
- package/src/lib/components/console/product-register-fields.component.js +241 -0
- package/src/lib/components/console/product-register-fields.component.js.map +1 -0
- package/src/lib/components/console/product-zones.d.ts +44 -0
- package/src/lib/components/console/product-zones.js.map +1 -1
- package/src/lib/components/console/products-hub-card.component.js +12 -0
- package/src/lib/components/console/products-hub-card.component.js.map +1 -1
- package/src/lib/components/console/register-hardware-card.component.d.ts +33 -0
- package/src/lib/components/console/register-hardware-card.component.js +826 -0
- package/src/lib/components/console/register-hardware-card.component.js.map +1 -0
- package/src/lib/components/console/registers-card.component.js +24 -5
- package/src/lib/components/console/registers-card.component.js.map +1 -1
- package/src/lib/components/console/return-actions.d.ts +38 -0
- package/src/lib/components/console/return-actions.js +76 -0
- package/src/lib/components/console/return-actions.js.map +1 -0
- package/src/lib/components/console/return-detail-dialog.component.d.ts +34 -0
- package/src/lib/components/console/return-detail-dialog.component.js +718 -0
- package/src/lib/components/console/return-detail-dialog.component.js.map +1 -0
- package/src/lib/components/console/return-settings-card.component.d.ts +34 -0
- package/src/lib/components/console/return-settings-card.component.js +195 -0
- package/src/lib/components/console/return-settings-card.component.js.map +1 -0
- package/src/lib/components/console/return-zones.d.ts +87 -0
- package/src/lib/components/console/return-zones.js +31 -0
- package/src/lib/components/console/return-zones.js.map +1 -0
- package/src/lib/components/console/returns-card.component.d.ts +45 -0
- package/src/lib/components/console/returns-card.component.js +159 -0
- package/src/lib/components/console/returns-card.component.js.map +1 -0
- package/src/lib/components/console/shipping-settings-card.component.js +161 -5
- package/src/lib/components/console/shipping-settings-card.component.js.map +1 -1
- package/src/lib/components/console/shippingeasy-card.component.d.ts +59 -0
- package/src/lib/components/console/shippingeasy-card.component.js +378 -0
- package/src/lib/components/console/shippingeasy-card.component.js.map +1 -0
- package/src/lib/components/console/shipstation-card.component.d.ts +35 -0
- package/src/lib/components/console/shipstation-card.component.js +345 -0
- package/src/lib/components/console/shipstation-card.component.js.map +1 -0
- package/src/lib/components/console/start-return-dialog.component.d.ts +40 -0
- package/src/lib/components/console/start-return-dialog.component.js +243 -0
- package/src/lib/components/console/start-return-dialog.component.js.map +1 -0
- package/src/lib/components/console/stock-movements-card.component.js +2 -1
- package/src/lib/components/console/stock-movements-card.component.js.map +1 -1
- package/src/lib/components/console/store-settings-card.component.js +2 -66
- package/src/lib/components/console/store-settings-card.component.js.map +1 -1
- package/src/lib/components/console/store-zones.d.ts +42 -0
- package/src/lib/components/console/store-zones.js +39 -0
- package/src/lib/components/console/store-zones.js.map +1 -0
- package/src/lib/components/order-status.d.ts +36 -0
- package/src/lib/components/order-status.js +502 -0
- package/src/lib/components/order-status.js.map +1 -0
- package/src/lib/components/product-detail.js +41 -2
- package/src/lib/components/product-detail.js.map +1 -1
- package/src/lib/components/return-request.d.ts +32 -0
- package/src/lib/components/return-request.js +576 -0
- package/src/lib/components/return-request.js.map +1 -0
- package/src/lib/components/storefront-payment-appearance.d.ts +32 -0
- package/src/lib/components/storefront-payment-appearance.js +114 -0
- package/src/lib/components/storefront-payment-appearance.js.map +1 -0
- package/src/lib/components/storefront-payment-element.d.ts +57 -1
- package/src/lib/components/storefront-payment-element.js +332 -33
- package/src/lib/components/storefront-payment-element.js.map +1 -1
- package/src/lib/constants/order-status.d.ts +22 -0
- package/src/lib/constants/order-status.js +22 -0
- package/src/lib/constants/order-status.js.map +1 -0
- package/src/lib/constants/return-request.d.ts +27 -0
- package/src/lib/constants/return-request.js +32 -0
- package/src/lib/constants/return-request.js.map +1 -0
- package/src/lib/constants/stock-movement-query.js +2 -1
- package/src/lib/constants/stock-movement-query.js.map +1 -1
- package/src/lib/declarations.console-server.js +9 -0
- package/src/lib/declarations.console-server.js.map +1 -1
- package/src/lib/declarations.server.d.ts +2 -1
- package/src/lib/declarations.server.js +47 -1
- package/src/lib/declarations.server.js.map +1 -1
- package/src/lib/model/buyer-notifications.d.ts +59 -0
- package/src/lib/model/buyer-notifications.js +97 -0
- package/src/lib/model/buyer-notifications.js.map +1 -0
- package/src/lib/model/commerce-orders.d.ts +127 -1
- package/src/lib/model/commerce-orders.js +24 -15
- package/src/lib/model/commerce-orders.js.map +1 -1
- package/src/lib/model/commerce-payment-methods.d.ts +146 -0
- package/src/lib/model/commerce-payment-methods.js +247 -0
- package/src/lib/model/commerce-payment-methods.js.map +1 -0
- package/src/lib/model/commerce-pos-ops.d.ts +437 -0
- package/src/lib/model/commerce-pos-ops.js +721 -0
- package/src/lib/model/commerce-pos-ops.js.map +1 -0
- package/src/lib/model/commerce-pos.d.ts +263 -0
- package/src/lib/model/commerce-pos.js +375 -0
- package/src/lib/model/commerce-pos.js.map +1 -0
- package/src/lib/model/commerce-printers.d.ts +211 -0
- package/src/lib/model/commerce-printers.js +181 -0
- package/src/lib/model/commerce-printers.js.map +1 -0
- package/src/lib/model/commerce-receipt.d.ts +97 -0
- package/src/lib/model/commerce-receipt.js +180 -0
- package/src/lib/model/commerce-receipt.js.map +1 -0
- package/src/lib/model/commerce-returns.d.ts +207 -0
- package/src/lib/model/commerce-returns.js +300 -0
- package/src/lib/model/commerce-returns.js.map +1 -0
- package/src/lib/model/commerce-shipping.d.ts +44 -1
- package/src/lib/model/commerce-shipping.js +53 -9
- package/src/lib/model/commerce-shipping.js.map +1 -1
- package/src/lib/model/commerce-tax-engine.d.ts +90 -0
- package/src/lib/model/commerce-tax-engine.js +129 -0
- package/src/lib/model/commerce-tax-engine.js.map +1 -0
- package/src/lib/model/commerce.d.ts +88 -2
- package/src/lib/model/commerce.js +89 -1
- package/src/lib/model/commerce.js.map +1 -1
- package/src/lib/model/index.d.ts +15 -0
- package/src/lib/model/index.js +15 -0
- package/src/lib/model/index.js.map +1 -1
- package/src/lib/model/order-events.d.ts +154 -0
- package/src/lib/model/order-events.js +153 -0
- package/src/lib/model/order-events.js.map +1 -0
- package/src/lib/model/order-fulfillment.d.ts +117 -0
- package/src/lib/model/order-fulfillment.js +217 -0
- package/src/lib/model/order-fulfillment.js.map +1 -0
- package/src/lib/model/order-history.d.ts +58 -0
- package/src/lib/model/order-history.js +22 -0
- package/src/lib/model/order-history.js.map +1 -0
- package/src/lib/model/order-list-fields.d.ts +9 -1
- package/src/lib/model/order-list-fields.js +7 -1
- package/src/lib/model/order-list-fields.js.map +1 -1
- package/src/lib/model/order-shipping-export.d.ts +91 -0
- package/src/lib/model/order-shipping-export.js +192 -0
- package/src/lib/model/order-shipping-export.js.map +1 -0
- package/src/lib/model/order-status-view.d.ts +103 -0
- package/src/lib/model/order-status-view.js +156 -0
- package/src/lib/model/order-status-view.js.map +1 -0
- package/src/lib/model/order-webhooks.d.ts +142 -0
- package/src/lib/model/order-webhooks.js +91 -0
- package/src/lib/model/order-webhooks.js.map +1 -0
- package/src/lib/model/product-channel.d.ts +56 -0
- package/src/lib/model/product-channel.js +86 -0
- package/src/lib/model/product-channel.js.map +1 -0
- package/src/lib/model/product-modifiers.d.ts +80 -0
- package/src/lib/model/product-modifiers.js +140 -0
- package/src/lib/model/product-modifiers.js.map +1 -0
- package/src/lib/model/shippingeasy.d.ts +94 -0
- package/src/lib/model/shippingeasy.js +267 -0
- package/src/lib/model/shippingeasy.js.map +1 -0
- package/src/lib/model/shipstation.d.ts +125 -0
- package/src/lib/model/shipstation.js +399 -0
- package/src/lib/model/shipstation.js.map +1 -0
- package/src/lib/model/smart-collection-reads.d.ts +32 -0
- package/src/lib/model/smart-collection-reads.js +63 -0
- package/src/lib/model/smart-collection-reads.js.map +1 -0
- package/src/lib/model/tracking-url.d.ts +74 -0
- package/src/lib/model/tracking-url.js +159 -0
- package/src/lib/model/tracking-url.js.map +1 -0
- package/src/lib/plugin-config.d.ts +13 -0
- package/src/lib/plugin-config.js +77 -5
- package/src/lib/plugin-config.js.map +1 -1
- package/src/lib/plugin.js +23 -0
- package/src/lib/plugin.js.map +1 -1
- package/src/lib/pos-ops-config.d.ts +39 -0
- package/src/lib/pos-ops-config.js +88 -0
- package/src/lib/pos-ops-config.js.map +1 -0
- package/src/lib/printing/print-document.d.ts +106 -0
- package/src/lib/printing/print-document.js +464 -0
- package/src/lib/printing/print-document.js.map +1 -0
- package/src/lib/printing/product-labels.d.ts +58 -0
- package/src/lib/printing/product-labels.js +116 -0
- package/src/lib/printing/product-labels.js.map +1 -0
- package/src/lib/printing/render-epson.d.ts +57 -0
- package/src/lib/printing/render-epson.js +135 -0
- package/src/lib/printing/render-epson.js.map +1 -0
- package/src/lib/printing/render-star.d.ts +45 -0
- package/src/lib/printing/render-star.js +100 -0
- package/src/lib/printing/render-star.js.map +1 -0
- package/src/lib/printing/render-text.d.ts +25 -0
- package/src/lib/printing/render-text.js +53 -0
- package/src/lib/printing/render-text.js.map +1 -0
- package/src/lib/server/api-v1/openapi.js +27 -4
- package/src/lib/server/api-v1/openapi.js.map +1 -1
- package/src/lib/server/api-v1/order-view.d.ts +67 -0
- package/src/lib/server/api-v1/order-view.js +120 -0
- package/src/lib/server/api-v1/order-view.js.map +1 -0
- package/src/lib/server/api-v1/orders-and-products.js +58 -65
- package/src/lib/server/api-v1/orders-and-products.js.map +1 -1
- package/src/lib/server/billing-webhook.js +135 -28
- package/src/lib/server/billing-webhook.js.map +1 -1
- package/src/lib/server/cancel-order.js +29 -0
- package/src/lib/server/cancel-order.js.map +1 -1
- package/src/lib/server/carrier-rates-availability.d.ts +26 -0
- package/src/lib/server/carrier-rates-availability.js +76 -0
- package/src/lib/server/carrier-rates-availability.js.map +1 -0
- package/src/lib/server/carrier-shipping.d.ts +84 -0
- package/src/lib/server/carrier-shipping.js +135 -0
- package/src/lib/server/carrier-shipping.js.map +1 -0
- package/src/lib/server/cart-checkout.d.ts +2 -0
- package/src/lib/server/cart-checkout.js +226 -22
- package/src/lib/server/cart-checkout.js.map +1 -1
- package/src/lib/server/checkout-extras.d.ts +64 -0
- package/src/lib/server/checkout-extras.js +157 -0
- package/src/lib/server/checkout-extras.js.map +1 -0
- package/src/lib/server/{feed.d.ts → checkout-status.d.ts} +2 -7
- package/src/lib/server/checkout-status.js +111 -0
- package/src/lib/server/checkout-status.js.map +1 -0
- package/src/lib/server/checkout.js +86 -9
- package/src/lib/server/checkout.js.map +1 -1
- package/src/lib/server/draft-order.js +34 -5
- package/src/lib/server/draft-order.js.map +1 -1
- package/src/lib/server/fulfill-order.d.ts +127 -10
- package/src/lib/server/fulfill-order.js +451 -49
- package/src/lib/server/fulfill-order.js.map +1 -1
- package/src/lib/server/legacy-feed.d.ts +28 -0
- package/src/lib/server/legacy-feed.js +52 -0
- package/src/lib/server/legacy-feed.js.map +1 -0
- package/src/lib/server/native-checkout.d.ts +34 -15
- package/src/lib/server/native-checkout.js +32 -17
- package/src/lib/server/native-checkout.js.map +1 -1
- package/src/lib/server/order-event-host-emit.d.ts +23 -0
- package/src/lib/server/order-event-host-emit.js +30 -0
- package/src/lib/server/order-event-host-emit.js.map +1 -0
- package/src/lib/server/order-event-triggers.d.ts +37 -0
- package/src/lib/server/order-event-triggers.js +119 -0
- package/src/lib/server/order-event-triggers.js.map +1 -0
- package/src/lib/server/order-events.d.ts +62 -0
- package/src/lib/server/order-events.js +109 -0
- package/src/lib/server/order-events.js.map +1 -0
- package/src/lib/server/order-history.d.ts +23 -0
- package/src/lib/server/order-history.js +65 -0
- package/src/lib/server/order-history.js.map +1 -0
- package/src/lib/server/order-notifications.d.ts +185 -0
- package/src/lib/server/order-notifications.js +567 -0
- package/src/lib/server/order-notifications.js.map +1 -0
- package/src/lib/server/order-receipt-send.d.ts +39 -0
- package/src/lib/server/order-receipt-send.js +151 -0
- package/src/lib/server/order-receipt-send.js.map +1 -0
- package/src/lib/server/order-status-token.d.ts +31 -0
- package/src/lib/server/order-status-token.js +75 -0
- package/src/lib/server/order-status-token.js.map +1 -0
- package/src/lib/server/order-status.d.ts +58 -0
- package/src/lib/server/order-status.js +141 -0
- package/src/lib/server/order-status.js.map +1 -0
- package/src/lib/server/order-webhooks.d.ts +108 -0
- package/src/lib/server/order-webhooks.js +622 -0
- package/src/lib/server/order-webhooks.js.map +1 -0
- package/src/lib/server/orders-shipping-prepare.d.ts +26 -0
- package/src/lib/server/orders-shipping-prepare.js +121 -0
- package/src/lib/server/orders-shipping-prepare.js.map +1 -0
- package/src/lib/server/payment-method-domains.d.ts +209 -0
- package/src/lib/server/payment-method-domains.js +444 -0
- package/src/lib/server/payment-method-domains.js.map +1 -0
- package/src/lib/server/payment-methods.d.ts +77 -0
- package/src/lib/server/payment-methods.js +284 -0
- package/src/lib/server/payment-methods.js.map +1 -0
- package/src/lib/server/pos-auth.d.ts +50 -0
- package/src/lib/server/pos-auth.js +121 -0
- package/src/lib/server/pos-auth.js.map +1 -0
- package/src/lib/server/pos-customer.d.ts +49 -0
- package/src/lib/server/pos-customer.js +257 -0
- package/src/lib/server/pos-customer.js.map +1 -0
- package/src/lib/server/pos-display.d.ts +57 -0
- package/src/lib/server/pos-display.js +419 -0
- package/src/lib/server/pos-display.js.map +1 -0
- package/src/lib/server/pos-fee-month.d.ts +34 -0
- package/src/lib/server/pos-fee-month.js +36 -0
- package/src/lib/server/pos-fee-month.js.map +1 -0
- package/src/lib/server/pos-ops-gate.d.ts +161 -0
- package/src/lib/server/pos-ops-gate.js +295 -0
- package/src/lib/server/pos-ops-gate.js.map +1 -0
- package/src/lib/server/pos-ops-routes.d.ts +22 -0
- package/src/lib/server/pos-ops-routes.js +36 -0
- package/src/lib/server/pos-ops-routes.js.map +1 -0
- package/src/lib/server/pos-order.d.ts +1 -18
- package/src/lib/server/pos-order.js +222 -42
- package/src/lib/server/pos-order.js.map +1 -1
- package/src/lib/server/pos-payment.d.ts +39 -0
- package/src/lib/server/pos-payment.js +922 -0
- package/src/lib/server/pos-payment.js.map +1 -0
- package/src/lib/server/pos-print.d.ts +82 -0
- package/src/lib/server/pos-print.js +193 -0
- package/src/lib/server/pos-print.js.map +1 -0
- package/src/lib/server/pos-readers.d.ts +27 -0
- package/src/lib/server/pos-readers.js +276 -0
- package/src/lib/server/pos-readers.js.map +1 -0
- package/src/lib/server/pos-refund-authority.d.ts +60 -0
- package/src/lib/server/pos-refund-authority.js +72 -0
- package/src/lib/server/pos-refund-authority.js.map +1 -0
- package/src/lib/server/pos-return.d.ts +58 -0
- package/src/lib/server/pos-return.js +891 -0
- package/src/lib/server/pos-return.js.map +1 -0
- package/src/lib/server/pos-sale-stamp.d.ts +66 -0
- package/src/lib/server/pos-sale-stamp.js +84 -0
- package/src/lib/server/pos-sale-stamp.js.map +1 -0
- package/src/lib/server/pos-sale.d.ts +170 -0
- package/src/lib/server/pos-sale.js +461 -0
- package/src/lib/server/pos-sale.js.map +1 -0
- package/src/lib/server/pos-shift.d.ts +45 -0
- package/src/lib/server/pos-shift.js +484 -0
- package/src/lib/server/pos-shift.js.map +1 -0
- package/src/lib/server/pos-staff-pin.d.ts +26 -0
- package/src/lib/server/pos-staff-pin.js +339 -0
- package/src/lib/server/pos-staff-pin.js.map +1 -0
- package/src/lib/server/pos-stripe.d.ts +91 -0
- package/src/lib/server/pos-stripe.js +129 -0
- package/src/lib/server/pos-stripe.js.map +1 -0
- package/src/lib/server/pos-terminal-connection-token.d.ts +48 -0
- package/src/lib/server/pos-terminal-connection-token.js +166 -0
- package/src/lib/server/pos-terminal-connection-token.js.map +1 -0
- package/src/lib/server/pos-terminal.d.ts +218 -0
- package/src/lib/server/pos-terminal.js +1014 -0
- package/src/lib/server/pos-terminal.js.map +1 -0
- package/src/lib/server/print-queue.d.ts +124 -0
- package/src/lib/server/print-queue.js +301 -0
- package/src/lib/server/print-queue.js.map +1 -0
- package/src/lib/server/printer-poll.d.ts +75 -0
- package/src/lib/server/printer-poll.js +325 -0
- package/src/lib/server/printer-poll.js.map +1 -0
- package/src/lib/server/printer-secret.d.ts +39 -0
- package/src/lib/server/printer-secret.js +56 -0
- package/src/lib/server/printer-secret.js.map +1 -0
- package/src/lib/server/printers.d.ts +114 -0
- package/src/lib/server/printers.js +546 -0
- package/src/lib/server/printers.js.map +1 -0
- package/src/lib/server/product-catalog.d.ts +42 -0
- package/src/lib/server/product-catalog.js +305 -0
- package/src/lib/server/product-catalog.js.map +1 -0
- package/src/lib/server/refund.js +110 -45
- package/src/lib/server/refund.js.map +1 -1
- package/src/lib/server/reserve.js +2 -0
- package/src/lib/server/reserve.js.map +1 -1
- package/src/lib/server/return-status-action.d.ts +37 -0
- package/src/lib/server/return-status-action.js +57 -0
- package/src/lib/server/return-status-action.js.map +1 -0
- package/src/lib/server/returns.d.ts +119 -0
- package/src/lib/server/returns.js +938 -0
- package/src/lib/server/returns.js.map +1 -0
- package/src/lib/server/shipment-records.d.ts +36 -0
- package/src/lib/server/shipment-records.js +289 -0
- package/src/lib/server/shipment-records.js.map +1 -0
- package/src/lib/server/shipping-connector-gates.d.ts +40 -0
- package/src/lib/server/shipping-connector-gates.js +97 -0
- package/src/lib/server/shipping-connector-gates.js.map +1 -0
- package/src/lib/server/shipping-connectors.d.ts +29 -0
- package/src/lib/server/shipping-connectors.js +236 -0
- package/src/lib/server/shipping-connectors.js.map +1 -0
- package/src/lib/server/shippingeasy.d.ts +238 -0
- package/src/lib/server/shippingeasy.js +787 -0
- package/src/lib/server/shippingeasy.js.map +1 -0
- package/src/lib/server/shipstation.d.ts +129 -0
- package/src/lib/server/shipstation.js +483 -0
- package/src/lib/server/shipstation.js.map +1 -0
- package/src/lib/server/site-page-resolver.d.ts +5 -0
- package/src/lib/server/site-page-resolver.js +156 -1
- package/src/lib/server/site-page-resolver.js.map +1 -1
- package/src/lib/server/stock-levels.d.ts +21 -0
- package/src/lib/server/stock-levels.js +263 -0
- package/src/lib/server/stock-levels.js.map +1 -0
- package/src/lib/server/stripe-refund.d.ts +47 -0
- package/src/lib/server/stripe-refund.js +87 -0
- package/src/lib/server/stripe-refund.js.map +1 -0
- package/src/lib/server/supplier-update.js +46 -5
- package/src/lib/server/supplier-update.js.map +1 -1
- package/src/lib/server/tax-engine-quote.d.ts +47 -0
- package/src/lib/server/tax-engine-quote.js +105 -0
- package/src/lib/server/tax-engine-quote.js.map +1 -0
- package/src/lib/server.js +138 -2
- package/src/lib/server.js.map +1 -1
- package/src/lib/site.js +12 -0
- package/src/lib/site.js.map +1 -1
- package/src/lib/subprocessors.d.ts +26 -0
- package/src/lib/subprocessors.js +50 -0
- package/src/lib/subprocessors.js.map +1 -0
- package/src/lib/tenant-emails.js +461 -3
- package/src/lib/tenant-emails.js.map +1 -1
- package/src/lib/testing/fake-firestore.d.ts +45 -0
- package/src/lib/testing/fake-firestore.js +189 -0
- package/src/lib/testing/fake-firestore.js.map +1 -0
- package/src/lib/testing/memory-firestore.d.ts +123 -0
- package/src/lib/testing/memory-firestore.js +274 -0
- package/src/lib/testing/memory-firestore.js.map +1 -0
- package/src/lib/testing/pos-ops-harness.d.ts +50 -0
- package/src/lib/testing/pos-ops-harness.js +184 -0
- package/src/lib/testing/pos-ops-harness.js.map +1 -0
- package/src/lib/testing/pos-ops-memory-firestore.d.ts +55 -0
- package/src/lib/testing/pos-ops-memory-firestore.js +376 -0
- package/src/lib/testing/pos-ops-memory-firestore.js.map +1 -0
- package/src/lib/transfer/records-transfer.d.ts +11 -1
- package/src/lib/transfer/records-transfer.js +127 -5
- package/src/lib/transfer/records-transfer.js.map +1 -1
- package/src/lib/transfer/records.server.d.ts +9 -2
- package/src/lib/transfer/records.server.js +58 -7
- package/src/lib/transfer/records.server.js.map +1 -1
- package/src/lib/transfer/register-transfer-resources.js +40 -1
- package/src/lib/transfer/register-transfer-resources.js.map +1 -1
- package/src/lib/transfer/register-transfer-ui.js +4 -1
- package/src/lib/transfer/register-transfer-ui.js.map +1 -1
- package/src/lib/transfer/shipping-presets.d.ts +23 -0
- package/src/lib/transfer/shipping-presets.js +156 -0
- package/src/lib/transfer/shipping-presets.js.map +1 -0
- package/src/lib/transfer/tracking-transfer.d.ts +101 -0
- package/src/lib/transfer/tracking-transfer.js +546 -0
- package/src/lib/transfer/tracking-transfer.js.map +1 -0
- package/src/lib/transfer/tracking.server.d.ts +37 -0
- package/src/lib/transfer/tracking.server.js +393 -0
- package/src/lib/transfer/tracking.server.js.map +1 -0
- package/src/lib/transfer/transfer-keys.d.ts +2 -1
- package/src/lib/transfer/transfer-keys.js +6 -2
- package/src/lib/transfer/transfer-keys.js.map +1 -1
- package/src/lib/utils/code128.d.ts +37 -0
- package/src/lib/utils/code128.js +199 -0
- package/src/lib/utils/code128.js.map +1 -0
- package/src/lib/utils/order-invoice.d.ts +55 -0
- package/src/lib/utils/order-invoice.js +127 -0
- package/src/lib/utils/order-invoice.js.map +1 -0
- package/src/lib/utils/use-checkout-return-notice.d.ts +34 -0
- package/src/lib/utils/use-checkout-return-notice.js +78 -0
- package/src/lib/utils/use-checkout-return-notice.js.map +1 -0
- package/src/lib/server/feed.js +0 -69
- package/src/lib/server/feed.js.map +0 -1
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import type { PluginApiRequest } from '@aglyn/aglyn/server';
|
|
18
|
+
import type { PrintReport } from '../model/commerce-printers';
|
|
19
|
+
import { type PosOpsSettings } from '../pos-ops-config';
|
|
20
|
+
export interface PosOpsMembership {
|
|
21
|
+
orgWide: boolean;
|
|
22
|
+
hostRole: string | null;
|
|
23
|
+
permissions: {
|
|
24
|
+
managePos?: boolean;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export interface PosOpsDeps {
|
|
28
|
+
firestore(): FirebaseFirestore.Firestore;
|
|
29
|
+
verifyIdToken(token: string): Promise<{
|
|
30
|
+
uid: string;
|
|
31
|
+
}>;
|
|
32
|
+
membership(uid: string, hostId: string): Promise<PosOpsMembership>;
|
|
33
|
+
orgForHost(hostId: string): Promise<{
|
|
34
|
+
orgId: string;
|
|
35
|
+
org: Record<string, any> | null;
|
|
36
|
+
} | null>;
|
|
37
|
+
pluginConfig(orgId: string, hostId: string): Promise<Record<string, unknown>>;
|
|
38
|
+
/** The plan includes the register. */
|
|
39
|
+
posEntitled(org: Record<string, any> | null): boolean;
|
|
40
|
+
/** The HMAC secret staff assertions are signed with; throws when unset. */
|
|
41
|
+
signingSecret(): string;
|
|
42
|
+
/** A member's name as a receipt or a report prints it. */
|
|
43
|
+
memberName(uid: string): Promise<string>;
|
|
44
|
+
now(): number;
|
|
45
|
+
/** Stripe's REST API; `global.fetch` in production. */
|
|
46
|
+
fetch: typeof fetch;
|
|
47
|
+
/** The register's cloud printers (AGL-3619): drawer kicks and shift reports. */
|
|
48
|
+
printer: PosOpsPrinter;
|
|
49
|
+
}
|
|
50
|
+
/** What the register's routes ask of the printer queue. Never throws. */
|
|
51
|
+
export interface PosOpsPrinter {
|
|
52
|
+
kickDrawer(input: {
|
|
53
|
+
hostId: string;
|
|
54
|
+
registerId: string;
|
|
55
|
+
reason: 'paid_in' | 'paid_out' | 'drop' | 'cash_refund';
|
|
56
|
+
causeId: string;
|
|
57
|
+
createdBy?: string;
|
|
58
|
+
}): Promise<{
|
|
59
|
+
jobIds: string[];
|
|
60
|
+
}>;
|
|
61
|
+
printReport(input: {
|
|
62
|
+
hostId: string;
|
|
63
|
+
registerId: string;
|
|
64
|
+
shiftId: string;
|
|
65
|
+
report: PrintReport;
|
|
66
|
+
createdBy?: string;
|
|
67
|
+
attemptKey: string;
|
|
68
|
+
}): Promise<{
|
|
69
|
+
jobIds: string[];
|
|
70
|
+
}>;
|
|
71
|
+
}
|
|
72
|
+
export declare function defaultPosOpsDeps(): PosOpsDeps;
|
|
73
|
+
/** A JSON body, whether the dispatcher parsed it or not. */
|
|
74
|
+
export declare function posOpsBody(req: PluginApiRequest): Record<string, any>;
|
|
75
|
+
/** The request's idempotency key, either header spelling, bounded. */
|
|
76
|
+
export declare function posOpsIdempotencyKey(req: PluginApiRequest): string;
|
|
77
|
+
/** Who is at the register, once the gate admitted them. */
|
|
78
|
+
export interface PosOpsStaff {
|
|
79
|
+
uid: string;
|
|
80
|
+
hostId: string;
|
|
81
|
+
orgId: string;
|
|
82
|
+
org: Record<string, any> | null;
|
|
83
|
+
membership: PosOpsMembership;
|
|
84
|
+
/** An admin of the whole workspace: the one role with no refund limit. */
|
|
85
|
+
isManager: boolean;
|
|
86
|
+
settings: PosOpsSettings;
|
|
87
|
+
hostRef: FirebaseFirestore.DocumentReference;
|
|
88
|
+
}
|
|
89
|
+
export type PosOpsGate = {
|
|
90
|
+
ok: true;
|
|
91
|
+
staff: PosOpsStaff;
|
|
92
|
+
} | {
|
|
93
|
+
ok: false;
|
|
94
|
+
status: number;
|
|
95
|
+
error: string;
|
|
96
|
+
};
|
|
97
|
+
/** A site id the dispatcher's own sentinels and path tricks cannot pass for. */
|
|
98
|
+
declare function cleanId(value: unknown): string;
|
|
99
|
+
export { cleanId as posOpsCleanId };
|
|
100
|
+
/** Whether a member may work this site's register, by role and permission. */
|
|
101
|
+
export declare function mayWorkRegister(memberRole: unknown, membership: PosOpsMembership): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* The one role whose say-so a refund above the cashier limit needs: an admin
|
|
104
|
+
* of the whole workspace who is also this site's admin — the role
|
|
105
|
+
* `refund.ts` has always required to refund at all.
|
|
106
|
+
*/
|
|
107
|
+
export declare function isPosManager(memberRole: unknown, membership: PosOpsMembership): boolean;
|
|
108
|
+
export declare function authorizePosOps(deps: PosOpsDeps, req: PluginApiRequest, rawHostId: unknown): Promise<PosOpsGate>;
|
|
109
|
+
/** A register on this site, or a refusal: a register id from another site is unknown here. */
|
|
110
|
+
export declare function readPosRegister(staff: PosOpsStaff, rawRegisterId: unknown): Promise<{
|
|
111
|
+
ok: true;
|
|
112
|
+
ref: FirebaseFirestore.DocumentReference;
|
|
113
|
+
data: Record<string, any>;
|
|
114
|
+
} | {
|
|
115
|
+
ok: false;
|
|
116
|
+
status: number;
|
|
117
|
+
error: string;
|
|
118
|
+
}>;
|
|
119
|
+
export type PosAssertionPurpose = 'cashier' | 'manager';
|
|
120
|
+
export declare function mintPosAssertion(deps: PosOpsDeps, input: {
|
|
121
|
+
hostId: string;
|
|
122
|
+
registerId: string;
|
|
123
|
+
memberUid: string;
|
|
124
|
+
purpose: PosAssertionPurpose;
|
|
125
|
+
}): {
|
|
126
|
+
token: string;
|
|
127
|
+
expiresAtMs: number;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* The member an assertion names, or `null` — for a forged, expired, wrong-site,
|
|
131
|
+
* wrong-register or wrong-purpose one alike. It does NOT re-check the member:
|
|
132
|
+
* {@link resolvePosStaffAssertion} does that.
|
|
133
|
+
*/
|
|
134
|
+
export declare function readPosAssertion(deps: PosOpsDeps, token: unknown, expected: {
|
|
135
|
+
hostId: string;
|
|
136
|
+
registerId: string;
|
|
137
|
+
purpose: PosAssertionPurpose;
|
|
138
|
+
}): {
|
|
139
|
+
memberUid: string;
|
|
140
|
+
expiresAtMs: number;
|
|
141
|
+
} | null;
|
|
142
|
+
/**
|
|
143
|
+
* The member an assertion puts at the register, re-checked NOW against the
|
|
144
|
+
* site's roles and the organization's permissions — or `null` when the
|
|
145
|
+
* assertion is bad or the member may no longer do what it was minted for.
|
|
146
|
+
*/
|
|
147
|
+
export declare function resolvePosStaffAssertion(deps: PosOpsDeps, hostRef: FirebaseFirestore.DocumentReference, token: unknown, expected: {
|
|
148
|
+
hostId: string;
|
|
149
|
+
registerId: string;
|
|
150
|
+
purpose: PosAssertionPurpose;
|
|
151
|
+
}): Promise<string | null>;
|
|
152
|
+
/**
|
|
153
|
+
* Who rang this: the member a valid cashier assertion names, or the member
|
|
154
|
+
* signed in on the device when there is none or it no longer holds. The
|
|
155
|
+
* signed-in member already passed the gate, so the fallback never admits
|
|
156
|
+
* anybody new; it only decides whose name the sale carries.
|
|
157
|
+
*/
|
|
158
|
+
export declare function resolvePosCashier(deps: PosOpsDeps, staff: Pick<PosOpsStaff, 'uid' | 'hostId' | 'hostRef'>, registerId: string, token: unknown): Promise<{
|
|
159
|
+
cashierId: string;
|
|
160
|
+
via: 'pin' | 'session';
|
|
161
|
+
}>;
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ import * as Aglyn from "@aglyn/aglyn/server";
|
|
17
|
+
import { firebaseAdmin, getOrgForHost, getPluginConfig } from "@aglyn/tenant-data-admin";
|
|
18
|
+
import { findUserByUidAcrossPools } from "@aglyn/tenant-data-admin/server/auth-pools";
|
|
19
|
+
import { resolveOrgPermissions } from "@aglyn/tenant-runtime/org-permissions";
|
|
20
|
+
import { createHmac, timingSafeEqual } from "crypto";
|
|
21
|
+
import { POS_CASHIER_ASSERTION_TTL_MS, POS_MANAGER_ASSERTION_TTL_MS } from "../model/commerce-pos-ops.js";
|
|
22
|
+
import { posOpsSettings } from "../pos-ops-config.js";
|
|
23
|
+
import { isRefusedIdToken } from "@aglyn/tenant-data-admin/server/id-token-refusal";
|
|
24
|
+
export function defaultPosOpsDeps() {
|
|
25
|
+
return {
|
|
26
|
+
firestore: ()=>firebaseAdmin.app().firestore(),
|
|
27
|
+
verifyIdToken: async (token)=>{
|
|
28
|
+
const decoded = await firebaseAdmin.app().auth().verifyIdToken(token);
|
|
29
|
+
return {
|
|
30
|
+
uid: decoded.uid
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
membership: async (uid, hostId)=>{
|
|
34
|
+
var _resolved_hostRole;
|
|
35
|
+
var _resolved_permissions;
|
|
36
|
+
const resolved = await resolveOrgPermissions(uid, {
|
|
37
|
+
hostId
|
|
38
|
+
});
|
|
39
|
+
return {
|
|
40
|
+
orgWide: resolved.orgWide === true,
|
|
41
|
+
hostRole: (_resolved_hostRole = resolved.hostRole) != null ? _resolved_hostRole : null,
|
|
42
|
+
permissions: {
|
|
43
|
+
managePos: ((_resolved_permissions = resolved.permissions) == null ? void 0 : _resolved_permissions.managePos) === true
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
orgForHost: async (hostId)=>{
|
|
48
|
+
var _ref, _ref1, _found_org;
|
|
49
|
+
var _found_org1;
|
|
50
|
+
const found = await getOrgForHost(hostId);
|
|
51
|
+
if (!found) return null;
|
|
52
|
+
return {
|
|
53
|
+
orgId: String((_ref = (_ref1 = (_found_org1 = found.org) == null ? void 0 : _found_org1.id) != null ? _ref1 : found.orgId) != null ? _ref : ''),
|
|
54
|
+
org: (_found_org = found.org) != null ? _found_org : null
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
pluginConfig: async (orgId, hostId)=>{
|
|
58
|
+
var _ref;
|
|
59
|
+
return (_ref = await getPluginConfig(orgId, 'commerce', {
|
|
60
|
+
hostId
|
|
61
|
+
})) != null ? _ref : {};
|
|
62
|
+
},
|
|
63
|
+
posEntitled: (org)=>Aglyn.checkEntitlement(org, 'pos'),
|
|
64
|
+
signingSecret: ()=>{
|
|
65
|
+
const secret = process.env.TOKEN_SIGNING_SECRET;
|
|
66
|
+
if (!secret) throw new Error('TOKEN_SIGNING_SECRET is not configured');
|
|
67
|
+
return secret;
|
|
68
|
+
},
|
|
69
|
+
memberName: async (uid)=>{
|
|
70
|
+
// Every pool: a member who signs in through SSO lives in a GCIP tenant
|
|
71
|
+
// pool, not the project one (AGL-1122).
|
|
72
|
+
try {
|
|
73
|
+
var _this;
|
|
74
|
+
const user = (_this = await findUserByUidAcrossPools(uid)) == null ? void 0 : _this.record;
|
|
75
|
+
return (user == null ? void 0 : user.displayName) || (user == null ? void 0 : user.email) || 'Staff member';
|
|
76
|
+
} catch (unused) {
|
|
77
|
+
return 'Staff member';
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
now: ()=>Date.now(),
|
|
81
|
+
fetch: (input, init)=>fetch(input, init),
|
|
82
|
+
// Loaded on use: the printing module reaches the whole sale pipeline,
|
|
83
|
+
// which a shift count or a PIN check never needs.
|
|
84
|
+
printer: {
|
|
85
|
+
kickDrawer: async (input)=>(await import("./pos-print.js")).kickPosDrawer(input),
|
|
86
|
+
printReport: async (input)=>(await import("./pos-print.js")).printPosShiftReport(input)
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/** A JSON body, whether the dispatcher parsed it or not. */ export function posOpsBody(req) {
|
|
91
|
+
if (typeof req.body === 'string') {
|
|
92
|
+
try {
|
|
93
|
+
const parsed = JSON.parse(req.body);
|
|
94
|
+
return parsed && typeof parsed === 'object' ? parsed : {};
|
|
95
|
+
} catch (unused) {
|
|
96
|
+
return {};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return req.body && typeof req.body === 'object' ? req.body : {};
|
|
100
|
+
}
|
|
101
|
+
/** The request's idempotency key, either header spelling, bounded. */ export function posOpsIdempotencyKey(req) {
|
|
102
|
+
var _ref, _req_headers_idempotencykey;
|
|
103
|
+
return String((_ref = (_req_headers_idempotencykey = req.headers['idempotency-key']) != null ? _req_headers_idempotencykey : req.headers['Idempotency-Key']) != null ? _ref : '').trim().slice(0, 200);
|
|
104
|
+
}
|
|
105
|
+
/** A site id the dispatcher's own sentinels and path tricks cannot pass for. */ function cleanId(value) {
|
|
106
|
+
const id = String(value != null ? value : '').trim();
|
|
107
|
+
return /^[A-Za-z0-9_-]{1,128}$/.test(id) && !/^__.*__$/.test(id) ? id : '';
|
|
108
|
+
}
|
|
109
|
+
export { cleanId as posOpsCleanId };
|
|
110
|
+
/** Whether a member may work this site's register, by role and permission. */ export function mayWorkRegister(memberRole, membership) {
|
|
111
|
+
return (memberRole === 'admin' || memberRole === 'editor') && membership.permissions.managePos === true;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* The one role whose say-so a refund above the cashier limit needs: an admin
|
|
115
|
+
* of the whole workspace who is also this site's admin — the role
|
|
116
|
+
* `refund.ts` has always required to refund at all.
|
|
117
|
+
*/ export function isPosManager(memberRole, membership) {
|
|
118
|
+
return memberRole === 'admin' && membership.orgWide && membership.hostRole === 'admin';
|
|
119
|
+
}
|
|
120
|
+
export async function authorizePosOps(deps, req, rawHostId) {
|
|
121
|
+
var _req_headers_authorization, _hostSnapshot_get, _ref, _ref1, _ref2;
|
|
122
|
+
const authorization = String((_req_headers_authorization = req.headers.authorization) != null ? _req_headers_authorization : '');
|
|
123
|
+
const idToken = authorization.startsWith('Bearer ') ? authorization.slice('Bearer '.length) : '';
|
|
124
|
+
if (!idToken) return {
|
|
125
|
+
ok: false,
|
|
126
|
+
status: 401,
|
|
127
|
+
error: 'Unauthenticated'
|
|
128
|
+
};
|
|
129
|
+
const hostId = cleanId(rawHostId);
|
|
130
|
+
if (!hostId) return {
|
|
131
|
+
ok: false,
|
|
132
|
+
status: 400,
|
|
133
|
+
error: 'Missing hostId'
|
|
134
|
+
};
|
|
135
|
+
let uid;
|
|
136
|
+
try {
|
|
137
|
+
uid = (await deps.verifyIdToken(idToken)).uid;
|
|
138
|
+
} catch (error) {
|
|
139
|
+
if (!isRefusedIdToken(error)) throw error;
|
|
140
|
+
return {
|
|
141
|
+
ok: false,
|
|
142
|
+
status: 401,
|
|
143
|
+
error: 'Unauthenticated'
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
const hostRef = deps.firestore().collection('hosts').doc(hostId);
|
|
147
|
+
const hostSnapshot = await hostRef.get();
|
|
148
|
+
if (!hostSnapshot.exists) return {
|
|
149
|
+
ok: false,
|
|
150
|
+
status: 404,
|
|
151
|
+
error: 'Unknown site'
|
|
152
|
+
};
|
|
153
|
+
const memberRole = ((_hostSnapshot_get = hostSnapshot.get('memberRoles')) != null ? _hostSnapshot_get : {})[uid];
|
|
154
|
+
const membership = await deps.membership(uid, hostId);
|
|
155
|
+
if (!mayWorkRegister(memberRole, membership)) {
|
|
156
|
+
return {
|
|
157
|
+
ok: false,
|
|
158
|
+
status: 403,
|
|
159
|
+
error: 'Not permitted'
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
const owner = await deps.orgForHost(hostId);
|
|
163
|
+
if (!deps.posEntitled((_ref = owner == null ? void 0 : owner.org) != null ? _ref : null)) {
|
|
164
|
+
return {
|
|
165
|
+
ok: false,
|
|
166
|
+
status: 403,
|
|
167
|
+
error: 'POS requires the Pro plan or above'
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
const settings = posOpsSettings((owner == null ? void 0 : owner.orgId) ? await deps.pluginConfig(owner.orgId, hostId).catch(()=>({})) : {});
|
|
171
|
+
return {
|
|
172
|
+
ok: true,
|
|
173
|
+
staff: {
|
|
174
|
+
uid,
|
|
175
|
+
hostId,
|
|
176
|
+
orgId: (_ref1 = owner == null ? void 0 : owner.orgId) != null ? _ref1 : '',
|
|
177
|
+
org: (_ref2 = owner == null ? void 0 : owner.org) != null ? _ref2 : null,
|
|
178
|
+
membership,
|
|
179
|
+
isManager: isPosManager(memberRole, membership),
|
|
180
|
+
settings,
|
|
181
|
+
hostRef
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
/** A register on this site, or a refusal: a register id from another site is unknown here. */ export async function readPosRegister(staff, rawRegisterId) {
|
|
186
|
+
var _snapshot_data;
|
|
187
|
+
const registerId = cleanId(rawRegisterId);
|
|
188
|
+
if (!registerId) return {
|
|
189
|
+
ok: false,
|
|
190
|
+
status: 400,
|
|
191
|
+
error: 'Missing registerId'
|
|
192
|
+
};
|
|
193
|
+
const ref = staff.hostRef.collection('registers').doc(registerId);
|
|
194
|
+
const snapshot = await ref.get();
|
|
195
|
+
if (!snapshot.exists) return {
|
|
196
|
+
ok: false,
|
|
197
|
+
status: 404,
|
|
198
|
+
error: 'Unknown register'
|
|
199
|
+
};
|
|
200
|
+
return {
|
|
201
|
+
ok: true,
|
|
202
|
+
ref,
|
|
203
|
+
data: (_snapshot_data = snapshot.data()) != null ? _snapshot_data : {}
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
function signClaims(deps, payload) {
|
|
207
|
+
return createHmac('sha256', deps.signingSecret()).update(`pos-assertion:${payload}`).digest('hex');
|
|
208
|
+
}
|
|
209
|
+
export function mintPosAssertion(deps, input) {
|
|
210
|
+
const expiresAtMs = deps.now() + (input.purpose === 'manager' ? POS_MANAGER_ASSERTION_TTL_MS : POS_CASHIER_ASSERTION_TTL_MS);
|
|
211
|
+
const claims = {
|
|
212
|
+
v: 1,
|
|
213
|
+
h: input.hostId,
|
|
214
|
+
r: input.registerId,
|
|
215
|
+
u: input.memberUid,
|
|
216
|
+
p: input.purpose,
|
|
217
|
+
e: expiresAtMs
|
|
218
|
+
};
|
|
219
|
+
const payload = Buffer.from(JSON.stringify(claims)).toString('base64url');
|
|
220
|
+
return {
|
|
221
|
+
token: `${payload}.${signClaims(deps, payload)}`,
|
|
222
|
+
expiresAtMs
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* The member an assertion names, or `null` — for a forged, expired, wrong-site,
|
|
227
|
+
* wrong-register or wrong-purpose one alike. It does NOT re-check the member:
|
|
228
|
+
* {@link resolvePosStaffAssertion} does that.
|
|
229
|
+
*/ export function readPosAssertion(deps, token, expected) {
|
|
230
|
+
const value = typeof token === 'string' ? token.trim() : '';
|
|
231
|
+
const dot = value.lastIndexOf('.');
|
|
232
|
+
if (dot <= 0 || value.length > 2000) return null;
|
|
233
|
+
const payload = value.slice(0, dot);
|
|
234
|
+
const signature = value.slice(dot + 1);
|
|
235
|
+
let expected64;
|
|
236
|
+
try {
|
|
237
|
+
expected64 = signClaims(deps, payload);
|
|
238
|
+
} catch (unused) {
|
|
239
|
+
return null;
|
|
240
|
+
}
|
|
241
|
+
const a = Buffer.from(signature);
|
|
242
|
+
const b = Buffer.from(expected64);
|
|
243
|
+
if (a.length !== b.length || !timingSafeEqual(new Uint8Array(a), new Uint8Array(b))) return null;
|
|
244
|
+
let claims;
|
|
245
|
+
try {
|
|
246
|
+
claims = JSON.parse(Buffer.from(payload, 'base64url').toString('utf8'));
|
|
247
|
+
} catch (unused) {
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
if ((claims == null ? void 0 : claims.v) !== 1 || claims.h !== expected.hostId || claims.r !== expected.registerId || claims.p !== expected.purpose || typeof claims.u !== 'string' || !claims.u || !(Number(claims.e) > deps.now())) {
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
253
|
+
return {
|
|
254
|
+
memberUid: claims.u,
|
|
255
|
+
expiresAtMs: Number(claims.e)
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* The member an assertion puts at the register, re-checked NOW against the
|
|
260
|
+
* site's roles and the organization's permissions — or `null` when the
|
|
261
|
+
* assertion is bad or the member may no longer do what it was minted for.
|
|
262
|
+
*/ export async function resolvePosStaffAssertion(deps, hostRef, token, expected) {
|
|
263
|
+
var _host_get;
|
|
264
|
+
const read = readPosAssertion(deps, token, expected);
|
|
265
|
+
if (!read) return null;
|
|
266
|
+
const host = await hostRef.get();
|
|
267
|
+
const memberRole = ((_host_get = host.get('memberRoles')) != null ? _host_get : {})[read.memberUid];
|
|
268
|
+
const membership = await deps.membership(read.memberUid, expected.hostId);
|
|
269
|
+
const allowed = expected.purpose === 'manager' ? isPosManager(memberRole, membership) : mayWorkRegister(memberRole, membership);
|
|
270
|
+
return allowed ? read.memberUid : null;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Who rang this: the member a valid cashier assertion names, or the member
|
|
274
|
+
* signed in on the device when there is none or it no longer holds. The
|
|
275
|
+
* signed-in member already passed the gate, so the fallback never admits
|
|
276
|
+
* anybody new; it only decides whose name the sale carries.
|
|
277
|
+
*/ export async function resolvePosCashier(deps, staff, registerId, token) {
|
|
278
|
+
if (token) {
|
|
279
|
+
const memberUid = await resolvePosStaffAssertion(deps, staff.hostRef, token, {
|
|
280
|
+
hostId: staff.hostId,
|
|
281
|
+
registerId,
|
|
282
|
+
purpose: 'cashier'
|
|
283
|
+
});
|
|
284
|
+
if (memberUid) return {
|
|
285
|
+
cashierId: memberUid,
|
|
286
|
+
via: 'pin'
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
return {
|
|
290
|
+
cashierId: staff.uid,
|
|
291
|
+
via: 'session'
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
//# sourceMappingURL=pos-ops-gate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/server/pos-ops-gate.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as Aglyn from '@aglyn/aglyn/server'\nimport type { PluginApiRequest } from '@aglyn/aglyn/server'\nimport { firebaseAdmin, getOrgForHost, getPluginConfig } from '@aglyn/tenant-data-admin'\nimport { findUserByUidAcrossPools } from '@aglyn/tenant-data-admin/server/auth-pools'\nimport { resolveOrgPermissions } from '@aglyn/tenant-runtime/org-permissions'\nimport { createHmac, timingSafeEqual } from 'crypto'\nimport {\n POS_CASHIER_ASSERTION_TTL_MS,\n POS_MANAGER_ASSERTION_TTL_MS,\n} from '../model/commerce-pos-ops'\nimport type { PrintReport } from '../model/commerce-printers'\nimport { posOpsSettings, type PosOpsSettings } from '../pos-ops-config'\nimport { isRefusedIdToken } from '@aglyn/tenant-data-admin/server/id-token-refusal'\n\n/*==========================================\n * WHO MAY RUN THE REGISTER (AGL-3609), for the shift, PIN, customer and\n * return routes.\n *\n * The same two facts the sale route checks: the member's role ON THIS SITE\n * is `admin` or `editor` (the allowlist the Firestore rules enforce), and the\n * organization has not revoked `managePos` from them. Plus the plan's `pos`\n * entitlement, re-read every time because a downgrade happens between taps.\n *\n * Every Firebase and Stripe touch goes through {@link PosOpsDeps}, so the\n * routes' specs run each money path against an in-memory store and a counted\n * fetch without mocking a module.\n *=========================================*/\n\nexport interface PosOpsMembership {\n orgWide: boolean\n hostRole: string | null\n permissions: { managePos?: boolean }\n}\n\nexport interface PosOpsDeps {\n firestore(): FirebaseFirestore.Firestore\n verifyIdToken(token: string): Promise<{ uid: string }>\n membership(uid: string, hostId: string): Promise<PosOpsMembership>\n orgForHost(hostId: string): Promise<{ orgId: string; org: Record<string, any> | null } | null>\n pluginConfig(orgId: string, hostId: string): Promise<Record<string, unknown>>\n /** The plan includes the register. */\n posEntitled(org: Record<string, any> | null): boolean\n /** The HMAC secret staff assertions are signed with; throws when unset. */\n signingSecret(): string\n /** A member's name as a receipt or a report prints it. */\n memberName(uid: string): Promise<string>\n now(): number\n /** Stripe's REST API; `global.fetch` in production. */\n fetch: typeof fetch\n /** The register's cloud printers (AGL-3619): drawer kicks and shift reports. */\n printer: PosOpsPrinter\n}\n\n/** What the register's routes ask of the printer queue. Never throws. */\nexport interface PosOpsPrinter {\n kickDrawer(input: {\n hostId: string\n registerId: string\n reason: 'paid_in' | 'paid_out' | 'drop' | 'cash_refund'\n causeId: string\n createdBy?: string\n }): Promise<{ jobIds: string[] }>\n printReport(input: {\n hostId: string\n registerId: string\n shiftId: string\n report: PrintReport\n createdBy?: string\n attemptKey: string\n }): Promise<{ jobIds: string[] }>\n}\n\nexport function defaultPosOpsDeps(): PosOpsDeps {\n return {\n firestore: () => firebaseAdmin.app().firestore(),\n verifyIdToken: async (token) => {\n const decoded = await firebaseAdmin.app().auth().verifyIdToken(token)\n return { uid: decoded.uid }\n },\n membership: async (uid, hostId) => {\n const resolved = await resolveOrgPermissions(uid, { hostId })\n return {\n orgWide: resolved.orgWide === true,\n hostRole: resolved.hostRole ?? null,\n permissions: { managePos: resolved.permissions?.managePos === true },\n }\n },\n orgForHost: async (hostId) => {\n const found = await getOrgForHost(hostId)\n if (!found) return null\n return {\n orgId: String(found.org?.id ?? found.orgId ?? ''),\n org: (found.org as Record<string, any>) ?? null,\n }\n },\n pluginConfig: async (orgId, hostId) =>\n ((await getPluginConfig(orgId, 'commerce', { hostId })) ?? {}) as Record<string, unknown>,\n posEntitled: (org) => Aglyn.checkEntitlement(org as any, 'pos'),\n signingSecret: () => {\n const secret = process.env.TOKEN_SIGNING_SECRET\n if (!secret) throw new Error('TOKEN_SIGNING_SECRET is not configured')\n return secret\n },\n memberName: async (uid) => {\n // Every pool: a member who signs in through SSO lives in a GCIP tenant\n // pool, not the project one (AGL-1122).\n try {\n const user = (await findUserByUidAcrossPools(uid))?.record\n return user?.displayName || user?.email || 'Staff member'\n } catch {\n return 'Staff member'\n }\n },\n now: () => Date.now(),\n fetch: (input, init) => fetch(input, init),\n // Loaded on use: the printing module reaches the whole sale pipeline,\n // which a shift count or a PIN check never needs.\n printer: {\n kickDrawer: async (input) => (await import('./pos-print')).kickPosDrawer(input),\n printReport: async (input) => (await import('./pos-print')).printPosShiftReport(input),\n },\n }\n}\n\n/** A JSON body, whether the dispatcher parsed it or not. */\nexport function posOpsBody(req: PluginApiRequest): Record<string, any> {\n if (typeof req.body === 'string') {\n try {\n const parsed = JSON.parse(req.body)\n return parsed && typeof parsed === 'object' ? parsed : {}\n } catch {\n return {}\n }\n }\n return req.body && typeof req.body === 'object' ? (req.body as Record<string, any>) : {}\n}\n\n/** The request's idempotency key, either header spelling, bounded. */\nexport function posOpsIdempotencyKey(req: PluginApiRequest): string {\n return String(req.headers['idempotency-key'] ?? req.headers['Idempotency-Key'] ?? '')\n .trim()\n .slice(0, 200)\n}\n\n/** Who is at the register, once the gate admitted them. */\nexport interface PosOpsStaff {\n uid: string\n hostId: string\n orgId: string\n org: Record<string, any> | null\n membership: PosOpsMembership\n /** An admin of the whole workspace: the one role with no refund limit. */\n isManager: boolean\n settings: PosOpsSettings\n hostRef: FirebaseFirestore.DocumentReference\n}\n\nexport type PosOpsGate =\n | { ok: true; staff: PosOpsStaff }\n | { ok: false; status: number; error: string }\n\n/** A site id the dispatcher's own sentinels and path tricks cannot pass for. */\nfunction cleanId(value: unknown): string {\n const id = String(value ?? '').trim()\n return /^[A-Za-z0-9_-]{1,128}$/.test(id) && !/^__.*__$/.test(id) ? id : ''\n}\n\nexport { cleanId as posOpsCleanId }\n\n/** Whether a member may work this site's register, by role and permission. */\nexport function mayWorkRegister(memberRole: unknown, membership: PosOpsMembership): boolean {\n return (memberRole === 'admin' || memberRole === 'editor') && membership.permissions.managePos === true\n}\n\n/**\n * The one role whose say-so a refund above the cashier limit needs: an admin\n * of the whole workspace who is also this site's admin — the role\n * `refund.ts` has always required to refund at all.\n */\nexport function isPosManager(memberRole: unknown, membership: PosOpsMembership): boolean {\n return memberRole === 'admin' && membership.orgWide && membership.hostRole === 'admin'\n}\n\nexport async function authorizePosOps(\n deps: PosOpsDeps,\n req: PluginApiRequest,\n rawHostId: unknown,\n): Promise<PosOpsGate> {\n const authorization = String(req.headers.authorization ?? '')\n const idToken = authorization.startsWith('Bearer ') ? authorization.slice('Bearer '.length) : ''\n if (!idToken) return { ok: false, status: 401, error: 'Unauthenticated' }\n const hostId = cleanId(rawHostId)\n if (!hostId) return { ok: false, status: 400, error: 'Missing hostId' }\n let uid: string\n try {\n uid = (await deps.verifyIdToken(idToken)).uid\n } catch (error) {\n if (!isRefusedIdToken(error)) throw error\n return { ok: false, status: 401, error: 'Unauthenticated' }\n }\n const hostRef = deps.firestore().collection('hosts').doc(hostId)\n const hostSnapshot = await hostRef.get()\n if (!hostSnapshot.exists) return { ok: false, status: 404, error: 'Unknown site' }\n const memberRole = (hostSnapshot.get('memberRoles') ?? {})[uid]\n const membership = await deps.membership(uid, hostId)\n if (!mayWorkRegister(memberRole, membership)) {\n return { ok: false, status: 403, error: 'Not permitted' }\n }\n const owner = await deps.orgForHost(hostId)\n if (!deps.posEntitled(owner?.org ?? null)) {\n return { ok: false, status: 403, error: 'POS requires the Pro plan or above' }\n }\n const settings = posOpsSettings(\n owner?.orgId ? await deps.pluginConfig(owner.orgId, hostId).catch(() => ({})) : {},\n )\n return {\n ok: true,\n staff: {\n uid,\n hostId,\n orgId: owner?.orgId ?? '',\n org: owner?.org ?? null,\n membership,\n isManager: isPosManager(memberRole, membership),\n settings,\n hostRef,\n },\n }\n}\n\n/** A register on this site, or a refusal: a register id from another site is unknown here. */\nexport async function readPosRegister(\n staff: PosOpsStaff,\n rawRegisterId: unknown,\n): Promise<\n | { ok: true; ref: FirebaseFirestore.DocumentReference; data: Record<string, any> }\n | { ok: false; status: number; error: string }\n> {\n const registerId = cleanId(rawRegisterId)\n if (!registerId) return { ok: false, status: 400, error: 'Missing registerId' }\n const ref = staff.hostRef.collection('registers').doc(registerId)\n const snapshot = await ref.get()\n if (!snapshot.exists) return { ok: false, status: 404, error: 'Unknown register' }\n return { ok: true, ref, data: (snapshot.data() ?? {}) as Record<string, any> }\n}\n\n/*==========================================\n * STAFF ASSERTIONS: what a PIN buys.\n *\n * A PIN never signs anybody in. It mints a short-lived, signed statement\n * that one member of THIS site is at THIS register — `{hostId, registerId,\n * memberUid, purpose, expiry}` under an HMAC — and the routes that take one\n * re-check that member's role and `managePos` on every use, so a PIN never\n * carries more than its member holds right now, and a revoked member's\n * assertion stops working on the next tap rather than at expiry.\n *=========================================*/\n\nexport type PosAssertionPurpose = 'cashier' | 'manager'\n\ninterface AssertionClaims {\n v: 1\n h: string\n r: string\n u: string\n p: PosAssertionPurpose\n e: number\n}\n\nfunction signClaims(deps: PosOpsDeps, payload: string): string {\n return createHmac('sha256', deps.signingSecret()).update(`pos-assertion:${payload}`).digest('hex')\n}\n\nexport function mintPosAssertion(\n deps: PosOpsDeps,\n input: { hostId: string; registerId: string; memberUid: string; purpose: PosAssertionPurpose },\n): { token: string; expiresAtMs: number } {\n const expiresAtMs =\n deps.now() +\n (input.purpose === 'manager' ? POS_MANAGER_ASSERTION_TTL_MS : POS_CASHIER_ASSERTION_TTL_MS)\n const claims: AssertionClaims = {\n v: 1,\n h: input.hostId,\n r: input.registerId,\n u: input.memberUid,\n p: input.purpose,\n e: expiresAtMs,\n }\n const payload = Buffer.from(JSON.stringify(claims)).toString('base64url')\n return { token: `${payload}.${signClaims(deps, payload)}`, expiresAtMs }\n}\n\n/**\n * The member an assertion names, or `null` — for a forged, expired, wrong-site,\n * wrong-register or wrong-purpose one alike. It does NOT re-check the member:\n * {@link resolvePosStaffAssertion} does that.\n */\nexport function readPosAssertion(\n deps: PosOpsDeps,\n token: unknown,\n expected: { hostId: string; registerId: string; purpose: PosAssertionPurpose },\n): { memberUid: string; expiresAtMs: number } | null {\n const value = typeof token === 'string' ? token.trim() : ''\n const dot = value.lastIndexOf('.')\n if (dot <= 0 || value.length > 2000) return null\n const payload = value.slice(0, dot)\n const signature = value.slice(dot + 1)\n let expected64: string\n try {\n expected64 = signClaims(deps, payload)\n } catch {\n return null\n }\n const a = Buffer.from(signature)\n const b = Buffer.from(expected64)\n if (a.length !== b.length || !timingSafeEqual(new Uint8Array(a), new Uint8Array(b))) return null\n let claims: AssertionClaims\n try {\n claims = JSON.parse(Buffer.from(payload, 'base64url').toString('utf8'))\n } catch {\n return null\n }\n if (\n claims?.v !== 1 ||\n claims.h !== expected.hostId ||\n claims.r !== expected.registerId ||\n claims.p !== expected.purpose ||\n typeof claims.u !== 'string' ||\n !claims.u ||\n !(Number(claims.e) > deps.now())\n ) {\n return null\n }\n return { memberUid: claims.u, expiresAtMs: Number(claims.e) }\n}\n\n/**\n * The member an assertion puts at the register, re-checked NOW against the\n * site's roles and the organization's permissions — or `null` when the\n * assertion is bad or the member may no longer do what it was minted for.\n */\nexport async function resolvePosStaffAssertion(\n deps: PosOpsDeps,\n hostRef: FirebaseFirestore.DocumentReference,\n token: unknown,\n expected: { hostId: string; registerId: string; purpose: PosAssertionPurpose },\n): Promise<string | null> {\n const read = readPosAssertion(deps, token, expected)\n if (!read) return null\n const host = await hostRef.get()\n const memberRole = (host.get('memberRoles') ?? {})[read.memberUid]\n const membership = await deps.membership(read.memberUid, expected.hostId)\n const allowed =\n expected.purpose === 'manager'\n ? isPosManager(memberRole, membership)\n : mayWorkRegister(memberRole, membership)\n return allowed ? read.memberUid : null\n}\n\n/**\n * Who rang this: the member a valid cashier assertion names, or the member\n * signed in on the device when there is none or it no longer holds. The\n * signed-in member already passed the gate, so the fallback never admits\n * anybody new; it only decides whose name the sale carries.\n */\nexport async function resolvePosCashier(\n deps: PosOpsDeps,\n staff: Pick<PosOpsStaff, 'uid' | 'hostId' | 'hostRef'>,\n registerId: string,\n token: unknown,\n): Promise<{ cashierId: string; via: 'pin' | 'session' }> {\n if (token) {\n const memberUid = await resolvePosStaffAssertion(deps, staff.hostRef, token, {\n hostId: staff.hostId,\n registerId,\n purpose: 'cashier',\n })\n if (memberUid) return { cashierId: memberUid, via: 'pin' }\n }\n return { cashierId: staff.uid, via: 'session' }\n}\n"],"names":["Aglyn","firebaseAdmin","getOrgForHost","getPluginConfig","findUserByUidAcrossPools","resolveOrgPermissions","createHmac","timingSafeEqual","POS_CASHIER_ASSERTION_TTL_MS","POS_MANAGER_ASSERTION_TTL_MS","posOpsSettings","isRefusedIdToken","defaultPosOpsDeps","firestore","app","verifyIdToken","token","decoded","auth","uid","membership","hostId","resolved","orgWide","hostRole","permissions","managePos","orgForHost","found","orgId","String","org","id","pluginConfig","posEntitled","checkEntitlement","signingSecret","secret","process","env","TOKEN_SIGNING_SECRET","Error","memberName","user","record","displayName","email","now","Date","fetch","input","init","printer","kickDrawer","kickPosDrawer","printReport","printPosShiftReport","posOpsBody","req","body","parsed","JSON","parse","posOpsIdempotencyKey","headers","trim","slice","cleanId","value","test","posOpsCleanId","mayWorkRegister","memberRole","isPosManager","authorizePosOps","deps","rawHostId","hostSnapshot","authorization","idToken","startsWith","length","ok","status","error","hostRef","collection","doc","get","exists","owner","settings","catch","staff","isManager","readPosRegister","rawRegisterId","snapshot","registerId","ref","data","signClaims","payload","update","digest","mintPosAssertion","expiresAtMs","purpose","claims","v","h","r","u","memberUid","p","e","Buffer","from","stringify","toString","readPosAssertion","expected","dot","lastIndexOf","signature","expected64","a","b","Uint8Array","Number","resolvePosStaffAssertion","host","read","allowed","resolvePosCashier","cashierId","via"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,YAA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AOyG;IAC3C,IAAI,CAACW,MAAM,OAAO;IAClB,MAAMD,OAAO,MAAM9C,QAAQG,GAAG;IAC9B,MAAMhB,aAAa,EAAC2D,YAAAA,KAAK3C,GAAG,CAAC,0BAAT2C,YAA2B,CAAC,EAAE,CAACC,KAAKnB,SAAS,CAAC;IAClE,MAAM7F,aAAa,MAAMuD,KAAKvD,UAAU,CAACgH,KAAKnB,SAAS,EAAEQ,SAASpG,MAAM;IACxE,MAAMgH,UACJZ,SAASd,OAAO,KAAK,YACjBlC,aAAaD,YAAYpD,cACzBmD,gBAAgBC,YAAYpD;IAClC,OAAOiH,UAAUD,KAAKnB,SAAS,GAAG;AACpC;AAEA;;;;;CAKC,GACD,OAAO,eAAeqB,kBACpB3D,IAAgB,EAChBkB,KAAsD,EACtDK,UAAkB,EAClBlF,KAAc;IAEd,IAAIA,OAAO;QACT,MAAMiG,YAAY,MAAMiB,yBAAyBvD,MAAMkB,MAAMR,OAAO,EAAErE,OAAO;YAC3EK,QAAQwE,MAAMxE,MAAM;YACpB6E;YACAS,SAAS;QACX;QACA,IAAIM,WAAW,OAAO;YAAEsB,WAAWtB;YAAWuB,KAAK;QAAM;IAC3D;IACA,OAAO;QAAED,WAAW1C,MAAM1E,GAAG;QAAEqH,KAAK;IAAU;AAChD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* The register's operations routes (AGL-3609): shifts and the drawer, staff
|
|
19
|
+
* PINs, the customer lookup and returns, plus the sale printing. Console-auth,
|
|
20
|
+
* so they register on the console surface with the sale route itself.
|
|
21
|
+
*/
|
|
22
|
+
export declare function registerPosOpsRoutes(): void;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ import { registerPluginApiRoute } from "@aglyn/aglyn/server";
|
|
17
|
+
import { posCustomerHandler } from "./pos-customer.js";
|
|
18
|
+
import { registerPosSalePrinting } from "./pos-print.js";
|
|
19
|
+
import { posReturnHandler } from "./pos-return.js";
|
|
20
|
+
import { posShiftHandler } from "./pos-shift.js";
|
|
21
|
+
import { posStaffPinHandler } from "./pos-staff-pin.js";
|
|
22
|
+
/**
|
|
23
|
+
* The register's operations routes (AGL-3609): shifts and the drawer, staff
|
|
24
|
+
* PINs, the customer lookup and returns, plus the sale printing. Console-auth,
|
|
25
|
+
* so they register on the console surface with the sale route itself.
|
|
26
|
+
*/ export function registerPosOpsRoutes() {
|
|
27
|
+
registerPluginApiRoute('commerce/pos-shift', posShiftHandler);
|
|
28
|
+
registerPluginApiRoute('commerce/pos-staff-pin', posStaffPinHandler);
|
|
29
|
+
registerPluginApiRoute('commerce/pos-customer', posCustomerHandler);
|
|
30
|
+
registerPluginApiRoute('commerce/pos-return', posReturnHandler);
|
|
31
|
+
// A completed sale's receipt and drawer kick on the register's cloud
|
|
32
|
+
// printers (AGL-3619), through the sale-completed seam every path fires.
|
|
33
|
+
registerPosSalePrinting();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=pos-ops-routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/server/pos-ops-routes.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { registerPluginApiRoute } from '@aglyn/aglyn/server'\nimport { posCustomerHandler } from './pos-customer'\nimport { registerPosSalePrinting } from './pos-print'\nimport { posReturnHandler } from './pos-return'\nimport { posShiftHandler } from './pos-shift'\nimport { posStaffPinHandler } from './pos-staff-pin'\n\n/**\n * The register's operations routes (AGL-3609): shifts and the drawer, staff\n * PINs, the customer lookup and returns, plus the sale printing. Console-auth,\n * so they register on the console surface with the sale route itself.\n */\nexport function registerPosOpsRoutes(): void {\n registerPluginApiRoute('commerce/pos-shift', posShiftHandler)\n registerPluginApiRoute('commerce/pos-staff-pin', posStaffPinHandler)\n registerPluginApiRoute('commerce/pos-customer', posCustomerHandler)\n registerPluginApiRoute('commerce/pos-return', posReturnHandler)\n // A completed sale's receipt and drawer kick on the register's cloud\n // printers (AGL-3619), through the sale-completed seam every path fires.\n registerPosSalePrinting()\n}\n"],"names":["registerPluginApiRoute","posCustomerHandler","registerPosSalePrinting","posReturnHandler","posShiftHandler","posStaffPinHandler","registerPosOpsRoutes"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,sBAAsB,QAAQ,sBAAqB;AAC5D,SAASC,kBAAkB,QAAQ,oBAAgB;AACnD,SAASC,uBAAuB,QAAQ,iBAAa;AACrD,SAASC,gBAAgB,QAAQ,kBAAc;AAC/C,SAASC,eAAe,QAAQ,iBAAa;AAC7C,SAASC,kBAAkB,QAAQ,qBAAiB;AAEpD;;;;CAIC,GACD,OAAO,SAASC;IACdN,uBAAuB,sBAAsBI;IAC7CJ,uBAAuB,0BAA0BK;IACjDL,uBAAuB,yBAAyBC;IAChDD,uBAAuB,uBAAuBG;IAC9C,qEAAqE;IACrE,yEAAyE;IACzED;AACF"}
|
|
@@ -34,21 +34,4 @@ import { type PluginApiHandler } from '@aglyn/aglyn/server';
|
|
|
34
34
|
* and sales can post to an open reservation folio instead (AGL-317).
|
|
35
35
|
*/
|
|
36
36
|
export declare const posOrderHandler: PluginApiHandler;
|
|
37
|
-
|
|
38
|
-
* The billing month a non-card POS fee accrues into (AGL-2111): `YYYY-MM` in
|
|
39
|
-
* **UTC**, byte-identical to the key `apps/console/utils/billing-month.ts`
|
|
40
|
-
* mints and to the twelve other month counters on the platform
|
|
41
|
-
* (`orgs/{id}/apiUsage/*`, `orgs/{id}/assistUsage/*`, the per-host counters).
|
|
42
|
-
*
|
|
43
|
-
* It has to be UTC and it has to be this exact expression: `report-usage`
|
|
44
|
-
* sweeps `previousMonth()` in UTC and reads the accrual document by that key,
|
|
45
|
-
* so a local-time month would strand every sale rung in the offset window on a
|
|
46
|
-
* document no sweep ever looks at — which is uncollected revenue that leaves
|
|
47
|
-
* no trace. `offline-pos-fee-month-key.spec.ts` pins the two against each
|
|
48
|
-
* other rather than trusting the comment.
|
|
49
|
-
*
|
|
50
|
-
* Local rather than imported because `apps/console` is an app: a plugin
|
|
51
|
-
* library cannot import from it, and the repo's other eleven copies of this
|
|
52
|
-
* one-liner are the established shape.
|
|
53
|
-
*/
|
|
54
|
-
export declare function offlineFeeMonthKey(now?: Date): string;
|
|
37
|
+
export { offlineFeeMonthKey } from './pos-fee-month';
|