@topy-ai/maggie 0.7.37 → 0.7.40

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.
Files changed (67) hide show
  1. package/README-zh-TW.md +65 -7
  2. package/README.md +80 -11
  3. package/bin/maggie.js +10 -2
  4. package/bundled-contracts/maggie-design/css-utility-evidence-v1.schema.json +10 -0
  5. package/bundled-contracts/maggie-design/dashboard-surface-v1.schema.json +11 -0
  6. package/bundled-contracts/maggie-design/progressive-enhancement-v1.schema.json +12 -0
  7. package/bundled-contracts/maggie-design/sample-surface-v1.schema.json +13 -0
  8. package/bundled-contracts/maggie-seo/privacy-origin-evidence-v1.schema.json +11 -0
  9. package/bundled-contracts/maggiedash/README.md +1 -1
  10. package/bundled-contracts/maggiedash/booking-access-v1.json +5 -4
  11. package/bundled-contracts/maggiedash/booking-customer-surface-v1.json +12 -1
  12. package/bundled-contracts/maggiedash/booking-email-templates-v1.json +2 -0
  13. package/bundled-contracts/maggiedash/booking-host-adapter-v1.json +16 -2
  14. package/bundled-contracts/maggiedash/booking-runtime.v1.json +41 -0
  15. package/bundled-contracts/maggiedash/execution-board.json +529 -28
  16. package/bundled-contracts/maggiedash/host-capabilities-v1.schema.json +10 -0
  17. package/bundled-contracts/maggiedash/site-structure-v1.schema.json +13 -0
  18. package/bundled-references/maggiedash-booking/ARCHITECTURE.md +218 -0
  19. package/bundled-references/maggiedash-booking/CURRENT-STATE.md +92 -0
  20. package/bundled-references/maggiedash-booking/DATA-FLOW.md +143 -0
  21. package/bundled-references/maggiedash-booking/DATA-MODEL.md +367 -0
  22. package/bundled-references/maggiedash-booking/DECISIONS.md +94 -0
  23. package/bundled-references/maggiedash-booking/EXECUTION-BOARD.json +2387 -0
  24. package/bundled-references/maggiedash-booking/HOST-ADAPTER.md +314 -0
  25. package/bundled-references/maggiedash-booking/ORAWELLNESS-INTEGRATION-AUDIT.md +227 -0
  26. package/bundled-references/maggiedash-booking/PAYMENT-GATEWAY.md +267 -0
  27. package/bundled-references/maggiedash-booking/PRD.md +228 -0
  28. package/bundled-references/maggiedash-booking/PROGRESS.md +2434 -0
  29. package/bundled-references/maggiedash-booking/QA-TEST-PLAN.md +235 -0
  30. package/bundled-references/maggiedash-booking/README.md +271 -0
  31. package/bundled-references/maggiedash-booking/RUNTIME-OPERATIONS.md +152 -0
  32. package/bundled-references/maggiedash-booking/SECURITY-COMPLIANCE.md +158 -0
  33. package/bundled-references/maggiedash-booking/SKILLS-AND-CLI.md +542 -0
  34. package/bundled-references/maggiedash-booking/STRIPE-INTEGRATION.md +129 -0
  35. package/bundled-references/maggiedash-booking/TASK-RUNBOOK.md +107 -0
  36. package/bundled-references/maggiedash-booking/TASKS.md +137 -0
  37. package/bundled-references/maggiedash-booking/USER-JOURNEYS.md +224 -0
  38. package/bundled-references/maggiedash-booking/diagrams/booking-dfd.excalidraw +1 -0
  39. package/bundled-references/maggiedash-booking/diagrams/booking-dfd.mmd +16 -0
  40. package/bundled-references/maggiedash-booking/diagrams/booking-dfd.png +0 -0
  41. package/bundled-references/maggiedash-booking/diagrams/booking-dfd.svg +1 -0
  42. package/bundled-references/maggiedash-booking/diagrams/booking-state-machine.mmd +19 -0
  43. package/bundled-references/maggiedash-booking/diagrams/booking-state-machine.png +0 -0
  44. package/bundled-references/maggiedash-booking/diagrams/booking-state-machine.svg +1 -0
  45. package/bundled-references/maggiedash-booking/diagrams/manager-journey.excalidraw +1 -0
  46. package/bundled-references/maggiedash-booking/diagrams/manager-journey.mmd +11 -0
  47. package/bundled-references/maggiedash-booking/diagrams/manager-journey.png +0 -0
  48. package/bundled-references/maggiedash-booking/diagrams/manager-journey.svg +1 -0
  49. package/bundled-references/maggiedash-booking/diagrams/payment-sequence.mmd +20 -0
  50. package/bundled-references/maggiedash-booking/diagrams/payment-sequence.png +0 -0
  51. package/bundled-references/maggiedash-booking/diagrams/payment-sequence.svg +1 -0
  52. package/bundled-references/maggiedash-booking/diagrams/system-context.excalidraw +1 -0
  53. package/bundled-references/maggiedash-booking/diagrams/system-context.mmd +10 -0
  54. package/bundled-references/maggiedash-booking/diagrams/system-context.png +0 -0
  55. package/bundled-references/maggiedash-booking/diagrams/system-context.svg +1 -0
  56. package/bundled-skills/maggie-blog-bootstrap/SKILL.md +16 -0
  57. package/bundled-skills/maggie-booking/SKILL.md +103 -22
  58. package/bundled-skills/maggie-design/SKILL.md +35 -0
  59. package/bundled-skills/maggie-seo-geo/SKILL.md +12 -0
  60. package/bundled-skills/maggie-service-booking/SKILL.md +14 -0
  61. package/bundled-tools/clis/maggie_booking.py +231 -31
  62. package/bundled-tools/clis/maggie_contracts.py +282 -0
  63. package/bundled-tools/clis/maggie_dash.py +28 -6
  64. package/bundled-tools/clis/maggie_design.py +29 -12
  65. package/bundled-tools/clis/maggie_service_booking.py +50 -1
  66. package/bundled-tools/clis/site_audit.py +49 -0
  67. package/package.json +1 -1
@@ -0,0 +1,158 @@
1
+ # Booking security and compliance
2
+
3
+ Booking handles identities, schedules, customer contact details, payment
4
+ references, and operational audit data. The design reduces risk by keeping the
5
+ host and payment provider boundaries explicit.
6
+
7
+ ## 1. Authentication and authorization
8
+
9
+ - Use the host's traditional email/password session and secure session cookie.
10
+ - Store only password hashes in the host database; never send passwords to the
11
+ dashboard bundle or an agent.
12
+ - Require project membership on every dashboard/API request.
13
+ - Require location scope for location-owned data.
14
+ - Enforce roles server-side for read and write actions.
15
+ - Re-check authorization inside every mutation transaction.
16
+ - Do not rely on hidden buttons, route obscurity, or client claims.
17
+ - Keep booking UI and APIs noindex where appropriate.
18
+
19
+ Suggested roles:
20
+
21
+ | Role | Read | Operate | Configure | Payments | Admin |
22
+ |---|---:|---:|---:|---:|---:|
23
+ | owner | all tenant | yes | yes | yes | yes |
24
+ | admin | permitted locations | yes | yes | policy-limited | no user deletion by default |
25
+ | manager | assigned locations | yes | yes | refund/request | no provider secrets |
26
+ | staff | assigned bookings | check-in/complete | no | no | no |
27
+ | viewer | permitted reports | no | no | redacted only | no |
28
+
29
+ The reference route policy makes the staff boundary explicit: staff may read
30
+ operational booking routes and may only mutate a booking through the lifecycle
31
+ transition route with `checked_in`, `in_progress`, `completed`, or `no_show`.
32
+ Staff cannot access payment routes, payment-health details, customer directory
33
+ routes, configuration mutations, or unrelated tenant data. The host adapter
34
+ must apply the session-derived location and assignment filter before returning
35
+ staff-visible rows; the UI must not be treated as that filter.
36
+
37
+ The shipped PostgreSQL manager repository now provides the assignment filter
38
+ for the standard host path: bookings, overview metrics, calendar, availability,
39
+ customer summaries, staff/resources, schedule rows, and booking/hold lifecycle
40
+ queries use the server-derived `staff_id`. Hosts must preserve that context when
41
+ wrapping the repository and must add equivalent filtering to any custom
42
+ repository or reporting endpoint.
43
+
44
+ Finance roles are restricted to payment and refund operations plus payment
45
+ health. Owner, admin, and manager permissions remain host-configured and must
46
+ still be checked against tenant and location scope on every request. The
47
+ standard Booking migration stores the host-configured staff/finance capability
48
+ set in `maggiedash_booking_user_roles.permissions_json`; the shared route
49
+ handler enforces it server-side. UI visibility is never the authorization
50
+ boundary.
51
+
52
+ ## 2. Payment data boundary
53
+
54
+ - Use hosted/tokenized provider flows where appropriate.
55
+ - Never store PAN, CVC, or full payment method payloads. Deployment-managed
56
+ provider keys remain in the host secret store; if dashboard-managed Stripe
57
+ configuration is enabled, the owner/manager submission is verified first and
58
+ stored only as authenticated ciphertext derived from `BOOKING_TOKEN_SECRET`,
59
+ never as a plaintext API key.
60
+ - Store local payment attempt and transaction IDs plus safe provider references.
61
+ - Keep provider secrets in server runtime configuration or a secret manager by
62
+ default. The documented single-business dashboard path is server-only and
63
+ may retain encrypted Stripe ciphertext for the host to use; deployment
64
+ secrets always take precedence.
65
+ - Do not serialize secrets through Astro/React props or `PUBLIC_*` variables.
66
+ - Redact authorization headers, webhook signatures, client secrets, and tokens
67
+ from logs and feedback drafts.
68
+ - Treat provider health and error messages as untrusted text; bound and redact
69
+ them before displaying or persisting.
70
+
71
+ The payment adapter must have an explicit PCI scope review before production.
72
+ The documentation does not claim a compliance certification.
73
+
74
+ ## 3. Webhook security
75
+
76
+ - Verify the provider signature with the correct tenant/account secret.
77
+ - Reject stale, malformed, unsigned, or wrong-account events.
78
+ - Deduplicate by provider and external event ID.
79
+ - Retain payload hash, event type, verification result, and safe processing
80
+ status. Do not retain raw body by default.
81
+ - Make processing order-independent where provider events can arrive out of
82
+ order.
83
+ - Use a dead-letter/reconciliation path for unmatched events.
84
+ - Return provider-appropriate retry status without leaking internals.
85
+
86
+ ## 4. Tenancy isolation
87
+
88
+ Every query is scoped by tenant and, when applicable, location. Tests must try:
89
+
90
+ - reading another tenant's booking by ID;
91
+ - guessing a booking, customer, payment, webhook, or media ID;
92
+ - using a manager role from another location;
93
+ - replaying an idempotency key under a different tenant;
94
+ - following a signed continuation token after scope changes.
95
+
96
+ The result must be a safe not-found or forbidden response with no existence
97
+ oracle beyond the documented policy.
98
+
99
+ ## 5. Customer privacy
100
+
101
+ - Minimize customer fields required for the selected booking flow.
102
+ - Separate marketing consent from service/booking consent.
103
+ - Do not put full customer details in analytics or notification events.
104
+ - Redact activity summaries and support exports by default.
105
+ - Define retention for cancelled bookings, payment references, notifications,
106
+ and webhook evidence.
107
+ - Provide an export/delete workflow subject to legal retention holds.
108
+ - Treat consultation, allergy, patch-test, or medical-like fields as a later
109
+ high-sensitivity module with separate review.
110
+
111
+ ## 6. Audit and non-repudiation
112
+
113
+ Audit events should include actor, tenant, action, entity, reason,
114
+ correlation ID, timestamp, and safe before/after summaries. Do not permit an
115
+ operator to edit or delete audit history through the booking UI.
116
+
117
+ Material actions requiring an audit event include:
118
+
119
+ - catalog, staff, resource, schedule, and policy changes;
120
+ - booking create, reschedule, cancellation, no-show, check-in, and completion;
121
+ - payment start, reconciliation, refund, and manual override;
122
+ - provider account connection or capability change;
123
+ - role/membership changes;
124
+ - migration and release gate overrides.
125
+
126
+ Creating, linking, deactivating, or changing the capabilities of a Booking
127
+ account must also be audited. Account invitations and password resets use
128
+ single-use, expiring tokens; the token is hashed in PostgreSQL and the raw
129
+ value is sent only through the server-side Resend request.
130
+
131
+ ## 7. Threat model checklist
132
+
133
+ | Threat | Control |
134
+ |---|---|
135
+ | Double booking | Transactional hold plus database overlap constraint |
136
+ | Duplicate charge | Local and provider idempotency keys |
137
+ | Forged success redirect | Verified webhook/provider reconciliation |
138
+ | Replay webhook | Provider event dedupe and timestamp/signature policy |
139
+ | Cross-tenant read | Server-side tenant/location scope in every query |
140
+ | Secret leakage | Server-only config, recursive redaction, safe reports |
141
+ | CSRF/session abuse | Same-origin requests, secure cookies, origin checks |
142
+ | Open redirect | Allowlisted same-site return destinations |
143
+ | Prompt/agent data leak | Explicit approved origin, no credentials in content tools |
144
+ | Provider outage | Capability state, retry queue, read-only degradation |
145
+ | Malicious customer input | Schema validation, output encoding, bounded text |
146
+
147
+ ## 8. Production security gate
148
+
149
+ The release gate must block when any of these is unverified:
150
+
151
+ - auth and tenant authorization tests;
152
+ - no-secret/browser-bundle scan;
153
+ - webhook signature and duplicate-event tests;
154
+ - idempotency conflict tests;
155
+ - SQL migration review and rollback story;
156
+ - redacted runtime and feedback evidence;
157
+ - dependency and provider SDK review;
158
+ - audit event coverage for material mutations.