qarpeo 0.0.0-alpha.10
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/LICENSE +21 -0
- package/README.md +102 -0
- package/dist/chunks/auth-schema.mjs +219 -0
- package/dist/chunks/wrangler.mjs +783 -0
- package/dist/cli/index.mjs +1085 -0
- package/dist/dev/env.d.ts +12 -0
- package/dist/dev/wrangler.d.ts +18 -0
- package/dist/module.d.ts +16 -0
- package/dist/module.mjs +4436 -0
- package/dist/runtime/ai.d.ts +25 -0
- package/dist/runtime/ai.mjs +106 -0
- package/dist/runtime/analytics.d.ts +24 -0
- package/dist/runtime/analytics.mjs +38 -0
- package/dist/runtime/app/components/BlobImage.vue +100 -0
- package/dist/runtime/app/components/CMSBlocks.vue +93 -0
- package/dist/runtime/app/components/CMSContent.vue +23 -0
- package/dist/runtime/app/components/CMSImage.vue +49 -0
- package/dist/runtime/app/components/CMSLocaleSwitcher.vue +110 -0
- package/dist/runtime/app/components/CMSPreviewBanner.vue +79 -0
- package/dist/runtime/app/components/CMSVersionBanner.vue +49 -0
- package/dist/runtime/app/components/CMSVersionSwitcher.vue +126 -0
- package/dist/runtime/app/components/ContentRenderer.vue +80 -0
- package/dist/runtime/app/components/FileUpload.vue +196 -0
- package/dist/runtime/app/components/ImpersonationBanner.vue +57 -0
- package/dist/runtime/app/components/SignedIn.vue +13 -0
- package/dist/runtime/app/components/SignedOut.vue +13 -0
- package/dist/runtime/app/components/shiki.css +34 -0
- package/dist/runtime/app/composables/analytics.d.ts +125 -0
- package/dist/runtime/app/composables/analytics.mjs +81 -0
- package/dist/runtime/app/composables/api-tokens.d.ts +49 -0
- package/dist/runtime/app/composables/api-tokens.mjs +61 -0
- package/dist/runtime/app/composables/auth.d.ts +50 -0
- package/dist/runtime/app/composables/auth.mjs +101 -0
- package/dist/runtime/app/composables/chat.d.ts +69 -0
- package/dist/runtime/app/composables/chat.mjs +159 -0
- package/dist/runtime/app/composables/cms-preview.d.ts +33 -0
- package/dist/runtime/app/composables/cms-preview.mjs +83 -0
- package/dist/runtime/app/composables/cms.d.ts +307 -0
- package/dist/runtime/app/composables/cms.mjs +355 -0
- package/dist/runtime/app/composables/docs-version.d.ts +35 -0
- package/dist/runtime/app/composables/docs-version.mjs +70 -0
- package/dist/runtime/app/composables/impersonation.d.ts +14 -0
- package/dist/runtime/app/composables/impersonation.mjs +44 -0
- package/dist/runtime/app/composables/notifications.d.ts +35 -0
- package/dist/runtime/app/composables/notifications.mjs +139 -0
- package/dist/runtime/app/composables/organization.d.ts +127 -0
- package/dist/runtime/app/composables/organization.mjs +138 -0
- package/dist/runtime/app/composables/passkey.d.ts +6 -0
- package/dist/runtime/app/composables/passkey.mjs +105 -0
- package/dist/runtime/app/composables/passwordless.d.ts +7 -0
- package/dist/runtime/app/composables/passwordless.mjs +67 -0
- package/dist/runtime/app/composables/payments.d.ts +43 -0
- package/dist/runtime/app/composables/payments.mjs +74 -0
- package/dist/runtime/app/composables/realtime.d.ts +96 -0
- package/dist/runtime/app/composables/realtime.mjs +432 -0
- package/dist/runtime/app/composables/site.d.ts +35 -0
- package/dist/runtime/app/composables/site.mjs +36 -0
- package/dist/runtime/app/composables/storage.d.ts +60 -0
- package/dist/runtime/app/composables/storage.mjs +294 -0
- package/dist/runtime/app/composables/tenant.d.ts +82 -0
- package/dist/runtime/app/composables/tenant.mjs +120 -0
- package/dist/runtime/app/composables/turnstile.d.ts +3 -0
- package/dist/runtime/app/composables/turnstile.mjs +10 -0
- package/dist/runtime/app/composables/two-factor.d.ts +12 -0
- package/dist/runtime/app/composables/two-factor.mjs +65 -0
- package/dist/runtime/app/middleware/auth.global.d.ts +2 -0
- package/dist/runtime/app/middleware/auth.global.mjs +44 -0
- package/dist/runtime/app/pages/cms.vue +2249 -0
- package/dist/runtime/app/pages/devtools/agents.vue +717 -0
- package/dist/runtime/app/pages/devtools/analytics.vue +618 -0
- package/dist/runtime/app/pages/devtools/auth.vue +351 -0
- package/dist/runtime/app/pages/devtools/blob.vue +745 -0
- package/dist/runtime/app/pages/devtools/db.vue +546 -0
- package/dist/runtime/app/pages/devtools/domains.vue +772 -0
- package/dist/runtime/app/pages/devtools/kv.vue +829 -0
- package/dist/runtime/app/pages/devtools/logs.vue +655 -0
- package/dist/runtime/app/pages/devtools/mail.vue +389 -0
- package/dist/runtime/app/pages/devtools/overview.vue +390 -0
- package/dist/runtime/app/pages/devtools/settings.vue +560 -0
- package/dist/runtime/app/pages/devtools.vue +165 -0
- package/dist/runtime/app/plugins/seo.d.ts +2 -0
- package/dist/runtime/app/plugins/seo.mjs +105 -0
- package/dist/runtime/app/plugins/shortcuts.client.d.ts +6 -0
- package/dist/runtime/app/plugins/shortcuts.client.mjs +19 -0
- package/dist/runtime/app/public/sw-notifications.mjs +52 -0
- package/dist/runtime/auth.d.ts +25 -0
- package/dist/runtime/auth.mjs +11 -0
- package/dist/runtime/bindings.d.ts +27 -0
- package/dist/runtime/bindings.mjs +38 -0
- package/dist/runtime/blob.d.ts +26 -0
- package/dist/runtime/blob.mjs +334 -0
- package/dist/runtime/bots.d.ts +1 -0
- package/dist/runtime/bots.mjs +1 -0
- package/dist/runtime/browser.d.ts +21 -0
- package/dist/runtime/browser.mjs +64 -0
- package/dist/runtime/cache.d.ts +19 -0
- package/dist/runtime/cache.mjs +12 -0
- package/dist/runtime/cms.d.ts +2 -0
- package/dist/runtime/cms.mjs +0 -0
- package/dist/runtime/db.d.ts +21 -0
- package/dist/runtime/db.mjs +36 -0
- package/dist/runtime/drizzle.d.ts +11 -0
- package/dist/runtime/drizzle.mjs +18 -0
- package/dist/runtime/email.d.ts +51 -0
- package/dist/runtime/email.mjs +245 -0
- package/dist/runtime/hyperdrive.d.ts +21 -0
- package/dist/runtime/hyperdrive.mjs +49 -0
- package/dist/runtime/index.d.ts +23 -0
- package/dist/runtime/index.mjs +23 -0
- package/dist/runtime/kv.d.ts +16 -0
- package/dist/runtime/kv.mjs +126 -0
- package/dist/runtime/payments.d.ts +2 -0
- package/dist/runtime/payments.mjs +0 -0
- package/dist/runtime/queue.d.ts +21 -0
- package/dist/runtime/queue.mjs +41 -0
- package/dist/runtime/rag.d.ts +1 -0
- package/dist/runtime/rag.mjs +1 -0
- package/dist/runtime/ratelimit.d.ts +21 -0
- package/dist/runtime/ratelimit.mjs +38 -0
- package/dist/runtime/realtime.d.ts +6 -0
- package/dist/runtime/realtime.mjs +13 -0
- package/dist/runtime/server/db/cms-schema.d.ts +651 -0
- package/dist/runtime/server/db/cms-schema.mjs +74 -0
- package/dist/runtime/server/durable-objects/agent.d.ts +14 -0
- package/dist/runtime/server/durable-objects/agent.mjs +571 -0
- package/dist/runtime/server/durable-objects/room.d.ts +34 -0
- package/dist/runtime/server/durable-objects/room.mjs +514 -0
- package/dist/runtime/server/middleware/auth.d.ts +2 -0
- package/dist/runtime/server/middleware/auth.mjs +108 -0
- package/dist/runtime/server/middleware/devtools.d.ts +2 -0
- package/dist/runtime/server/middleware/devtools.mjs +61 -0
- package/dist/runtime/server/middleware/ratelimit.d.ts +2 -0
- package/dist/runtime/server/middleware/ratelimit.mjs +49 -0
- package/dist/runtime/server/middleware/tenancy.d.ts +6 -0
- package/dist/runtime/server/middleware/tenancy.mjs +15 -0
- package/dist/runtime/server/middleware/tracker.d.ts +7 -0
- package/dist/runtime/server/middleware/tracker.mjs +9 -0
- package/dist/runtime/server/plugins/agents.d.ts +7 -0
- package/dist/runtime/server/plugins/agents.mjs +3 -0
- package/dist/runtime/server/plugins/cms.d.ts +7 -0
- package/dist/runtime/server/plugins/cms.mjs +16 -0
- package/dist/runtime/server/plugins/dev-logs.d.ts +1 -0
- package/dist/runtime/server/plugins/dev-logs.mjs +58 -0
- package/dist/runtime/server/plugins/dev-proxy.d.ts +3 -0
- package/dist/runtime/server/plugins/dev-proxy.mjs +21 -0
- package/dist/runtime/server/plugins/env.d.ts +6 -0
- package/dist/runtime/server/plugins/env.mjs +17 -0
- package/dist/runtime/server/plugins/queue.d.ts +6 -0
- package/dist/runtime/server/plugins/queue.mjs +8 -0
- package/dist/runtime/server/routes/__qarpeo/agents/chat.post.d.ts +20 -0
- package/dist/runtime/server/routes/__qarpeo/agents/chat.post.mjs +110 -0
- package/dist/runtime/server/routes/__qarpeo/agents/clear.post.d.ts +7 -0
- package/dist/runtime/server/routes/__qarpeo/agents/clear.post.mjs +15 -0
- package/dist/runtime/server/routes/__qarpeo/agents/create.post.d.ts +17 -0
- package/dist/runtime/server/routes/__qarpeo/agents/create.post.mjs +47 -0
- package/dist/runtime/server/routes/__qarpeo/agents/history.get.d.ts +15 -0
- package/dist/runtime/server/routes/__qarpeo/agents/history.get.mjs +24 -0
- package/dist/runtime/server/routes/__qarpeo/agents/list.get.d.ts +5 -0
- package/dist/runtime/server/routes/__qarpeo/agents/list.get.mjs +63 -0
- package/dist/runtime/server/routes/__qarpeo/analytics/events.get.d.ts +64 -0
- package/dist/runtime/server/routes/__qarpeo/analytics/events.get.mjs +55 -0
- package/dist/runtime/server/routes/__qarpeo/analytics/summary.get.d.ts +30 -0
- package/dist/runtime/server/routes/__qarpeo/analytics/summary.get.mjs +73 -0
- package/dist/runtime/server/routes/__qarpeo/auth/revoke-session.post.d.ts +6 -0
- package/dist/runtime/server/routes/__qarpeo/auth/revoke-session.post.mjs +26 -0
- package/dist/runtime/server/routes/__qarpeo/auth/sessions.get.d.ts +6 -0
- package/dist/runtime/server/routes/__qarpeo/auth/sessions.get.mjs +46 -0
- package/dist/runtime/server/routes/__qarpeo/auth/users.get.d.ts +7 -0
- package/dist/runtime/server/routes/__qarpeo/auth/users.get.mjs +65 -0
- package/dist/runtime/server/routes/__qarpeo/blob/files.get.d.ts +22 -0
- package/dist/runtime/server/routes/__qarpeo/blob/files.get.mjs +36 -0
- package/dist/runtime/server/routes/__qarpeo/db/query.post.d.ts +23 -0
- package/dist/runtime/server/routes/__qarpeo/db/query.post.mjs +34 -0
- package/dist/runtime/server/routes/__qarpeo/db/tables.get.d.ts +31 -0
- package/dist/runtime/server/routes/__qarpeo/db/tables.get.mjs +81 -0
- package/dist/runtime/server/routes/__qarpeo/kv/delete.post.d.ts +11 -0
- package/dist/runtime/server/routes/__qarpeo/kv/delete.post.mjs +18 -0
- package/dist/runtime/server/routes/__qarpeo/kv/get.get.d.ts +11 -0
- package/dist/runtime/server/routes/__qarpeo/kv/get.get.mjs +20 -0
- package/dist/runtime/server/routes/__qarpeo/kv/keys.get.d.ts +8 -0
- package/dist/runtime/server/routes/__qarpeo/kv/keys.get.mjs +27 -0
- package/dist/runtime/server/routes/__qarpeo/kv/set.post.d.ts +14 -0
- package/dist/runtime/server/routes/__qarpeo/kv/set.post.mjs +24 -0
- package/dist/runtime/server/routes/__qarpeo/logs.delete.d.ts +5 -0
- package/dist/runtime/server/routes/__qarpeo/logs.delete.mjs +6 -0
- package/dist/runtime/server/routes/__qarpeo/logs.get.d.ts +5 -0
- package/dist/runtime/server/routes/__qarpeo/logs.get.mjs +26 -0
- package/dist/runtime/server/routes/__qarpeo/logs.post.d.ts +6 -0
- package/dist/runtime/server/routes/__qarpeo/logs.post.mjs +17 -0
- package/dist/runtime/server/routes/__qarpeo/mail/bounce.post.d.ts +5 -0
- package/dist/runtime/server/routes/__qarpeo/mail/bounce.post.mjs +37 -0
- package/dist/runtime/server/routes/__qarpeo/mail/clear.post.d.ts +4 -0
- package/dist/runtime/server/routes/__qarpeo/mail/clear.post.mjs +6 -0
- package/dist/runtime/server/routes/__qarpeo/mail/inbox.get.d.ts +5 -0
- package/dist/runtime/server/routes/__qarpeo/mail/inbox.get.mjs +7 -0
- package/dist/runtime/server/routes/__qarpeo/mail/send-test.post.d.ts +4 -0
- package/dist/runtime/server/routes/__qarpeo/mail/send-test.post.mjs +29 -0
- package/dist/runtime/server/routes/__qarpeo/mail/track/click/[id].get.d.ts +2 -0
- package/dist/runtime/server/routes/__qarpeo/mail/track/click/[id].get.mjs +23 -0
- package/dist/runtime/server/routes/__qarpeo/mail/track/open/[id].get.d.ts +2 -0
- package/dist/runtime/server/routes/__qarpeo/mail/track/open/[id].get.mjs +31 -0
- package/dist/runtime/server/routes/__qarpeo/overview/health.get.d.ts +8 -0
- package/dist/runtime/server/routes/__qarpeo/overview/health.get.mjs +46 -0
- package/dist/runtime/server/routes/__qarpeo/overview.get.d.ts +32 -0
- package/dist/runtime/server/routes/__qarpeo/overview.get.mjs +38 -0
- package/dist/runtime/server/routes/__qarpeo/settings/reset-dev-data.post.d.ts +11 -0
- package/dist/runtime/server/routes/__qarpeo/settings/reset-dev-data.post.mjs +84 -0
- package/dist/runtime/server/routes/__qarpeo/settings.get.d.ts +124 -0
- package/dist/runtime/server/routes/__qarpeo/settings.get.mjs +145 -0
- package/dist/runtime/server/routes/__qarpeo/tenants/create.post.d.ts +7 -0
- package/dist/runtime/server/routes/__qarpeo/tenants/create.post.mjs +26 -0
- package/dist/runtime/server/routes/__qarpeo/tenants/domain-add.post.d.ts +6 -0
- package/dist/runtime/server/routes/__qarpeo/tenants/domain-add.post.mjs +29 -0
- package/dist/runtime/server/routes/__qarpeo/tenants/domain-delete.post.d.ts +7 -0
- package/dist/runtime/server/routes/__qarpeo/tenants/domain-delete.post.mjs +21 -0
- package/dist/runtime/server/routes/__qarpeo/tenants/domain-verify.post.d.ts +9 -0
- package/dist/runtime/server/routes/__qarpeo/tenants/domain-verify.post.mjs +21 -0
- package/dist/runtime/server/routes/__qarpeo/tenants/list.get.d.ts +15 -0
- package/dist/runtime/server/routes/__qarpeo/tenants/list.get.mjs +22 -0
- package/dist/runtime/server/routes/agents/[agent]/chat.post.d.ts +2 -0
- package/dist/runtime/server/routes/agents/[agent]/chat.post.mjs +35 -0
- package/dist/runtime/server/routes/agents/[agent]/clear.post.d.ts +4 -0
- package/dist/runtime/server/routes/agents/[agent]/clear.post.mjs +27 -0
- package/dist/runtime/server/routes/agents/[agent]/history.get.d.ts +4 -0
- package/dist/runtime/server/routes/agents/[agent]/history.get.mjs +27 -0
- package/dist/runtime/server/routes/analytics/events.get.d.ts +3 -0
- package/dist/runtime/server/routes/analytics/events.get.mjs +17 -0
- package/dist/runtime/server/routes/analytics/pageviews.get.d.ts +3 -0
- package/dist/runtime/server/routes/analytics/pageviews.get.mjs +15 -0
- package/dist/runtime/server/routes/analytics/summary.get.d.ts +6 -0
- package/dist/runtime/server/routes/analytics/summary.get.mjs +15 -0
- package/dist/runtime/server/routes/atom.xml.get.d.ts +2 -0
- package/dist/runtime/server/routes/atom.xml.get.mjs +76 -0
- package/dist/runtime/server/routes/auth/2fa/disable.post.d.ts +4 -0
- package/dist/runtime/server/routes/auth/2fa/disable.post.mjs +44 -0
- package/dist/runtime/server/routes/auth/2fa/setup.post.d.ts +6 -0
- package/dist/runtime/server/routes/auth/2fa/setup.post.mjs +32 -0
- package/dist/runtime/server/routes/auth/2fa/verify.post.d.ts +6 -0
- package/dist/runtime/server/routes/auth/2fa/verify.post.mjs +92 -0
- package/dist/runtime/server/routes/auth/[provider]/callback.d.ts +1 -0
- package/dist/runtime/server/routes/auth/[provider]/callback.mjs +1 -0
- package/dist/runtime/server/routes/auth/[provider].d.ts +3 -0
- package/dist/runtime/server/routes/auth/[provider].mjs +95 -0
- package/dist/runtime/server/routes/auth/account.delete.d.ts +5 -0
- package/dist/runtime/server/routes/auth/account.delete.mjs +52 -0
- package/dist/runtime/server/routes/auth/impersonate/start.post.d.ts +5 -0
- package/dist/runtime/server/routes/auth/impersonate/start.post.mjs +14 -0
- package/dist/runtime/server/routes/auth/impersonate/stop.post.d.ts +5 -0
- package/dist/runtime/server/routes/auth/impersonate/stop.post.mjs +5 -0
- package/dist/runtime/server/routes/auth/logout-all.post.d.ts +4 -0
- package/dist/runtime/server/routes/auth/logout-all.post.mjs +16 -0
- package/dist/runtime/server/routes/auth/logout-others.post.d.ts +4 -0
- package/dist/runtime/server/routes/auth/logout-others.post.mjs +11 -0
- package/dist/runtime/server/routes/auth/logout.post.d.ts +4 -0
- package/dist/runtime/server/routes/auth/logout.post.mjs +17 -0
- package/dist/runtime/server/routes/auth/magic-link/send.post.d.ts +10 -0
- package/dist/runtime/server/routes/auth/magic-link/send.post.mjs +29 -0
- package/dist/runtime/server/routes/auth/magic-link/verify.get.d.ts +2 -0
- package/dist/runtime/server/routes/auth/magic-link/verify.get.mjs +81 -0
- package/dist/runtime/server/routes/auth/organization/create.post.d.ts +5 -0
- package/dist/runtime/server/routes/auth/organization/create.post.mjs +10 -0
- package/dist/runtime/server/routes/auth/organization/invite.post.d.ts +9 -0
- package/dist/runtime/server/routes/auth/organization/invite.post.mjs +27 -0
- package/dist/runtime/server/routes/auth/organization/join.post.d.ts +6 -0
- package/dist/runtime/server/routes/auth/organization/join.post.mjs +15 -0
- package/dist/runtime/server/routes/auth/organization/list.get.d.ts +5 -0
- package/dist/runtime/server/routes/auth/organization/list.get.mjs +7 -0
- package/dist/runtime/server/routes/auth/organization/members/[id].delete.d.ts +4 -0
- package/dist/runtime/server/routes/auth/organization/members/[id].delete.mjs +33 -0
- package/dist/runtime/server/routes/auth/organization/members/index.get.d.ts +6 -0
- package/dist/runtime/server/routes/auth/organization/members/index.get.mjs +18 -0
- package/dist/runtime/server/routes/auth/organization/mfa.post.d.ts +6 -0
- package/dist/runtime/server/routes/auth/organization/mfa.post.mjs +33 -0
- package/dist/runtime/server/routes/auth/organization/sso/[id].delete.d.ts +4 -0
- package/dist/runtime/server/routes/auth/organization/sso/[id].delete.mjs +28 -0
- package/dist/runtime/server/routes/auth/organization/sso/index.get.d.ts +2 -0
- package/dist/runtime/server/routes/auth/organization/sso/index.get.mjs +23 -0
- package/dist/runtime/server/routes/auth/organization/sso/index.post.d.ts +5 -0
- package/dist/runtime/server/routes/auth/organization/sso/index.post.mjs +84 -0
- package/dist/runtime/server/routes/auth/organization/switch.post.d.ts +6 -0
- package/dist/runtime/server/routes/auth/organization/switch.post.mjs +14 -0
- package/dist/runtime/server/routes/auth/otp/send.post.d.ts +10 -0
- package/dist/runtime/server/routes/auth/otp/send.post.mjs +29 -0
- package/dist/runtime/server/routes/auth/otp/verify.post.d.ts +6 -0
- package/dist/runtime/server/routes/auth/otp/verify.post.mjs +95 -0
- package/dist/runtime/server/routes/auth/sessions/[id].delete.d.ts +5 -0
- package/dist/runtime/server/routes/auth/sessions/[id].delete.mjs +24 -0
- package/dist/runtime/server/routes/auth/sessions.get.d.ts +2 -0
- package/dist/runtime/server/routes/auth/sessions.get.mjs +11 -0
- package/dist/runtime/server/routes/auth/sso/login.get.d.ts +2 -0
- package/dist/runtime/server/routes/auth/sso/login.get.mjs +94 -0
- package/dist/runtime/server/routes/auth/sso/oidc/callback.get.d.ts +2 -0
- package/dist/runtime/server/routes/auth/sso/oidc/callback.get.mjs +113 -0
- package/dist/runtime/server/routes/auth/sso/saml/acs.post.d.ts +2 -0
- package/dist/runtime/server/routes/auth/sso/saml/acs.post.mjs +95 -0
- package/dist/runtime/server/routes/auth/tokens/[id].delete.d.ts +4 -0
- package/dist/runtime/server/routes/auth/tokens/[id].delete.mjs +13 -0
- package/dist/runtime/server/routes/auth/tokens/create.post.d.ts +9 -0
- package/dist/runtime/server/routes/auth/tokens/create.post.mjs +17 -0
- package/dist/runtime/server/routes/auth/tokens/index.get.d.ts +9 -0
- package/dist/runtime/server/routes/auth/tokens/index.get.mjs +5 -0
- package/dist/runtime/server/routes/auth/turnstile/verify.post.d.ts +2 -0
- package/dist/runtime/server/routes/auth/turnstile/verify.post.mjs +15 -0
- package/dist/runtime/server/routes/auth/user.get.d.ts +2 -0
- package/dist/runtime/server/routes/auth/user.get.mjs +6 -0
- package/dist/runtime/server/routes/auth/webauthn/login/options.post.d.ts +2 -0
- package/dist/runtime/server/routes/auth/webauthn/login/options.post.mjs +17 -0
- package/dist/runtime/server/routes/auth/webauthn/login/verify.post.d.ts +6 -0
- package/dist/runtime/server/routes/auth/webauthn/login/verify.post.mjs +127 -0
- package/dist/runtime/server/routes/auth/webauthn/register/options.post.d.ts +2 -0
- package/dist/runtime/server/routes/auth/webauthn/register/options.post.mjs +47 -0
- package/dist/runtime/server/routes/auth/webauthn/register/verify.post.d.ts +5 -0
- package/dist/runtime/server/routes/auth/webauthn/register/verify.post.mjs +88 -0
- package/dist/runtime/server/routes/cms/[collection]/[id]/preview-token.post.d.ts +8 -0
- package/dist/runtime/server/routes/cms/[collection]/[id]/preview-token.post.mjs +27 -0
- package/dist/runtime/server/routes/cms/[collection]/[id]/publish.post.d.ts +6 -0
- package/dist/runtime/server/routes/cms/[collection]/[id]/publish.post.mjs +19 -0
- package/dist/runtime/server/routes/cms/[collection]/[id]/review.post.d.ts +6 -0
- package/dist/runtime/server/routes/cms/[collection]/[id]/review.post.mjs +33 -0
- package/dist/runtime/server/routes/cms/[collection]/[id].delete.d.ts +4 -0
- package/dist/runtime/server/routes/cms/[collection]/[id].delete.mjs +17 -0
- package/dist/runtime/server/routes/cms/[collection]/[id].put.d.ts +4 -0
- package/dist/runtime/server/routes/cms/[collection]/[id].put.mjs +18 -0
- package/dist/runtime/server/routes/cms/[collection]/[slug].get.d.ts +4 -0
- package/dist/runtime/server/routes/cms/[collection]/[slug].get.mjs +19 -0
- package/dist/runtime/server/routes/cms/[collection]/atom.xml.get.d.ts +2 -0
- package/dist/runtime/server/routes/cms/[collection]/atom.xml.get.mjs +69 -0
- package/dist/runtime/server/routes/cms/[collection]/by-path.get.d.ts +8 -0
- package/dist/runtime/server/routes/cms/[collection]/by-path.get.mjs +23 -0
- package/dist/runtime/server/routes/cms/[collection]/feed.xml.get.d.ts +2 -0
- package/dist/runtime/server/routes/cms/[collection]/feed.xml.get.mjs +65 -0
- package/dist/runtime/server/routes/cms/[collection]/index.get.d.ts +7 -0
- package/dist/runtime/server/routes/cms/[collection]/index.get.mjs +15 -0
- package/dist/runtime/server/routes/cms/[collection]/index.post.d.ts +4 -0
- package/dist/runtime/server/routes/cms/[collection]/index.post.mjs +23 -0
- package/dist/runtime/server/routes/cms/[collection]/references.get.d.ts +19 -0
- package/dist/runtime/server/routes/cms/[collection]/references.get.mjs +47 -0
- package/dist/runtime/server/routes/cms/[collection]/surroundings.get.d.ts +10 -0
- package/dist/runtime/server/routes/cms/[collection]/surroundings.get.mjs +12 -0
- package/dist/runtime/server/routes/cms/collections/[id].delete.d.ts +4 -0
- package/dist/runtime/server/routes/cms/collections/[id].delete.mjs +10 -0
- package/dist/runtime/server/routes/cms/collections/[id].put.d.ts +4 -0
- package/dist/runtime/server/routes/cms/collections/[id].put.mjs +11 -0
- package/dist/runtime/server/routes/cms/collections/index.get.d.ts +4 -0
- package/dist/runtime/server/routes/cms/collections/index.get.mjs +6 -0
- package/dist/runtime/server/routes/cms/collections/index.post.d.ts +4 -0
- package/dist/runtime/server/routes/cms/collections/index.post.mjs +19 -0
- package/dist/runtime/server/routes/cms/components/index.get.d.ts +17 -0
- package/dist/runtime/server/routes/cms/components/index.get.mjs +16 -0
- package/dist/runtime/server/routes/cms/deploy.post.d.ts +4 -0
- package/dist/runtime/server/routes/cms/deploy.post.mjs +46 -0
- package/dist/runtime/server/routes/cms/export.post.d.ts +10 -0
- package/dist/runtime/server/routes/cms/export.post.mjs +55 -0
- package/dist/runtime/server/routes/cms/navigation.get.d.ts +8 -0
- package/dist/runtime/server/routes/cms/navigation.get.mjs +36 -0
- package/dist/runtime/server/routes/cms/preview/disable.get.d.ts +9 -0
- package/dist/runtime/server/routes/cms/preview/disable.get.mjs +9 -0
- package/dist/runtime/server/routes/cms/preview/enable.get.d.ts +14 -0
- package/dist/runtime/server/routes/cms/preview/enable.get.mjs +42 -0
- package/dist/runtime/server/routes/cms/publish-scheduled.post.d.ts +11 -0
- package/dist/runtime/server/routes/cms/publish-scheduled.post.mjs +35 -0
- package/dist/runtime/server/routes/cms/search.get.d.ts +13 -0
- package/dist/runtime/server/routes/cms/search.get.mjs +137 -0
- package/dist/runtime/server/routes/cms/sync.post.d.ts +7 -0
- package/dist/runtime/server/routes/cms/sync.post.mjs +18 -0
- package/dist/runtime/server/routes/cms/webhooks/[provider].post.d.ts +150 -0
- package/dist/runtime/server/routes/cms/webhooks/[provider].post.mjs +213 -0
- package/dist/runtime/server/routes/docs/search.get.d.ts +15 -0
- package/dist/runtime/server/routes/docs/search.get.mjs +20 -0
- package/dist/runtime/server/routes/feed.xml.get.d.ts +2 -0
- package/dist/runtime/server/routes/feed.xml.get.mjs +73 -0
- package/dist/runtime/server/routes/mail/bounce.post.d.ts +14 -0
- package/dist/runtime/server/routes/mail/bounce.post.mjs +56 -0
- package/dist/runtime/server/routes/mail/inbox/[id].get.d.ts +2 -0
- package/dist/runtime/server/routes/mail/inbox/[id].get.mjs +9 -0
- package/dist/runtime/server/routes/mail/inbox.get.d.ts +4 -0
- package/dist/runtime/server/routes/mail/inbox.get.mjs +7 -0
- package/dist/runtime/server/routes/mail/suppressions/[email].delete.d.ts +11 -0
- package/dist/runtime/server/routes/mail/suppressions/[email].delete.mjs +18 -0
- package/dist/runtime/server/routes/mail/suppressions/index.get.d.ts +12 -0
- package/dist/runtime/server/routes/mail/suppressions/index.get.mjs +23 -0
- package/dist/runtime/server/routes/mail/suppressions/index.post.d.ts +10 -0
- package/dist/runtime/server/routes/mail/suppressions/index.post.mjs +23 -0
- package/dist/runtime/server/routes/mail/unsubscribe.d.ts +13 -0
- package/dist/runtime/server/routes/mail/unsubscribe.mjs +91 -0
- package/dist/runtime/server/routes/mail/webhooks.post.d.ts +12 -0
- package/dist/runtime/server/routes/mail/webhooks.post.mjs +71 -0
- package/dist/runtime/server/routes/notifications/[id]/read.post.d.ts +4 -0
- package/dist/runtime/server/routes/notifications/[id]/read.post.mjs +13 -0
- package/dist/runtime/server/routes/notifications/[id].delete.d.ts +4 -0
- package/dist/runtime/server/routes/notifications/[id].delete.mjs +13 -0
- package/dist/runtime/server/routes/notifications/[id].get.d.ts +2 -0
- package/dist/runtime/server/routes/notifications/[id].get.mjs +15 -0
- package/dist/runtime/server/routes/notifications/index.get.d.ts +6 -0
- package/dist/runtime/server/routes/notifications/index.get.mjs +18 -0
- package/dist/runtime/server/routes/notifications/push/subscribe.post.d.ts +4 -0
- package/dist/runtime/server/routes/notifications/push/subscribe.post.mjs +20 -0
- package/dist/runtime/server/routes/notifications/push/unsubscribe.post.d.ts +4 -0
- package/dist/runtime/server/routes/notifications/push/unsubscribe.post.mjs +15 -0
- package/dist/runtime/server/routes/notifications/read-all.post.d.ts +4 -0
- package/dist/runtime/server/routes/notifications/read-all.post.mjs +11 -0
- package/dist/runtime/server/routes/payments/cancel.post.d.ts +7 -0
- package/dist/runtime/server/routes/payments/cancel.post.mjs +9 -0
- package/dist/runtime/server/routes/payments/change-plan.post.d.ts +7 -0
- package/dist/runtime/server/routes/payments/change-plan.post.mjs +12 -0
- package/dist/runtime/server/routes/payments/checkout.post.d.ts +9 -0
- package/dist/runtime/server/routes/payments/checkout.post.mjs +16 -0
- package/dist/runtime/server/routes/payments/pause.post.d.ts +7 -0
- package/dist/runtime/server/routes/payments/pause.post.mjs +9 -0
- package/dist/runtime/server/routes/payments/portal.post.d.ts +5 -0
- package/dist/runtime/server/routes/payments/portal.post.mjs +9 -0
- package/dist/runtime/server/routes/payments/subscription.get.d.ts +6 -0
- package/dist/runtime/server/routes/payments/subscription.get.mjs +9 -0
- package/dist/runtime/server/routes/payments/usage.get.d.ts +12 -0
- package/dist/runtime/server/routes/payments/usage.get.mjs +18 -0
- package/dist/runtime/server/routes/payments/usage.post.d.ts +6 -0
- package/dist/runtime/server/routes/payments/usage.post.mjs +24 -0
- package/dist/runtime/server/routes/payments/webhook.post.d.ts +14 -0
- package/dist/runtime/server/routes/payments/webhook.post.mjs +21 -0
- package/dist/runtime/server/routes/realtime/broadcast.post.d.ts +4 -0
- package/dist/runtime/server/routes/realtime/broadcast.post.mjs +26 -0
- package/dist/runtime/server/routes/realtime/history.delete.d.ts +13 -0
- package/dist/runtime/server/routes/realtime/history.delete.mjs +12 -0
- package/dist/runtime/server/routes/realtime/history.get.d.ts +16 -0
- package/dist/runtime/server/routes/realtime/history.get.mjs +15 -0
- package/dist/runtime/server/routes/realtime/presence.get.d.ts +6 -0
- package/dist/runtime/server/routes/realtime/presence.get.mjs +27 -0
- package/dist/runtime/server/routes/realtime/state.get.d.ts +5 -0
- package/dist/runtime/server/routes/realtime/state.get.mjs +26 -0
- package/dist/runtime/server/routes/realtime/state.post.d.ts +6 -0
- package/dist/runtime/server/routes/realtime/state.post.mjs +37 -0
- package/dist/runtime/server/routes/realtime/ws.get.d.ts +2 -0
- package/dist/runtime/server/routes/realtime/ws.get.mjs +73 -0
- package/dist/runtime/server/routes/robots.txt.get.d.ts +2 -0
- package/dist/runtime/server/routes/robots.txt.get.mjs +41 -0
- package/dist/runtime/server/routes/rss.xml.get.d.ts +2 -0
- package/dist/runtime/server/routes/rss.xml.get.mjs +2 -0
- package/dist/runtime/server/routes/sitemap.xml.get.d.ts +2 -0
- package/dist/runtime/server/routes/sitemap.xml.get.mjs +84 -0
- package/dist/runtime/server/routes/storage/file/[...key].delete.d.ts +4 -0
- package/dist/runtime/server/routes/storage/file/[...key].delete.mjs +23 -0
- package/dist/runtime/server/routes/storage/file/[...key].get.d.ts +2 -0
- package/dist/runtime/server/routes/storage/file/[...key].get.mjs +23 -0
- package/dist/runtime/server/routes/storage/files.get.d.ts +14 -0
- package/dist/runtime/server/routes/storage/files.get.mjs +11 -0
- package/dist/runtime/server/routes/storage/presigned.post.d.ts +8 -0
- package/dist/runtime/server/routes/storage/presigned.post.mjs +39 -0
- package/dist/runtime/server/routes/storage/sign.post.d.ts +6 -0
- package/dist/runtime/server/routes/storage/sign.post.mjs +24 -0
- package/dist/runtime/server/routes/storage/upload.post.d.ts +22 -0
- package/dist/runtime/server/routes/storage/upload.post.mjs +96 -0
- package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/index.delete.d.ts +8 -0
- package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/index.delete.mjs +39 -0
- package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/verify.post.d.ts +8 -0
- package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/verify.post.mjs +39 -0
- package/dist/runtime/server/routes/tenants/[tenant]/domains/index.get.d.ts +8 -0
- package/dist/runtime/server/routes/tenants/[tenant]/domains/index.get.mjs +20 -0
- package/dist/runtime/server/routes/tenants/[tenant]/domains/index.post.d.ts +8 -0
- package/dist/runtime/server/routes/tenants/[tenant]/domains/index.post.mjs +44 -0
- package/dist/runtime/server/routes/tenants/current.get.d.ts +8 -0
- package/dist/runtime/server/routes/tenants/current.get.mjs +6 -0
- package/dist/runtime/server/tasks/cms/publish.d.ts +4 -0
- package/dist/runtime/server/tasks/cms/publish.mjs +18 -0
- package/dist/runtime/server/utils/agent-store.d.ts +24 -0
- package/dist/runtime/server/utils/agent-store.mjs +53 -0
- package/dist/runtime/server/utils/agents-registry-fallback.d.ts +1 -0
- package/dist/runtime/server/utils/agents-registry-fallback.mjs +1 -0
- package/dist/runtime/server/utils/ai.d.ts +119 -0
- package/dist/runtime/server/utils/ai.mjs +607 -0
- package/dist/runtime/server/utils/analytics-query.d.ts +109 -0
- package/dist/runtime/server/utils/analytics-query.mjs +234 -0
- package/dist/runtime/server/utils/auth.d.ts +60 -0
- package/dist/runtime/server/utils/auth.mjs +361 -0
- package/dist/runtime/server/utils/blob-store.d.ts +13 -0
- package/dist/runtime/server/utils/blob-store.mjs +60 -0
- package/dist/runtime/server/utils/bots.d.ts +21 -0
- package/dist/runtime/server/utils/bots.mjs +491 -0
- package/dist/runtime/server/utils/cache.d.ts +33 -0
- package/dist/runtime/server/utils/cache.mjs +128 -0
- package/dist/runtime/server/utils/cms-events.d.ts +17 -0
- package/dist/runtime/server/utils/cms-events.mjs +80 -0
- package/dist/runtime/server/utils/cms-filter.d.ts +3 -0
- package/dist/runtime/server/utils/cms-filter.mjs +34 -0
- package/dist/runtime/server/utils/cms.d.ts +278 -0
- package/dist/runtime/server/utils/cms.mjs +3268 -0
- package/dist/runtime/server/utils/config.d.ts +27 -0
- package/dist/runtime/server/utils/config.mjs +38 -0
- package/dist/runtime/server/utils/context.d.ts +13 -0
- package/dist/runtime/server/utils/context.mjs +98 -0
- package/dist/runtime/server/utils/crypto.d.ts +16 -0
- package/dist/runtime/server/utils/crypto.mjs +56 -0
- package/dist/runtime/server/utils/dev-logs.d.ts +21 -0
- package/dist/runtime/server/utils/dev-logs.mjs +41 -0
- package/dist/runtime/server/utils/dev-proxy.d.ts +1 -0
- package/dist/runtime/server/utils/dev-proxy.mjs +69 -0
- package/dist/runtime/server/utils/domains.d.ts +46 -0
- package/dist/runtime/server/utils/domains.mjs +318 -0
- package/dist/runtime/server/utils/drizzle.d.ts +10 -0
- package/dist/runtime/server/utils/drizzle.mjs +36 -0
- package/dist/runtime/server/utils/email-templates.d.ts +44 -0
- package/dist/runtime/server/utils/email-templates.mjs +373 -0
- package/dist/runtime/server/utils/feed.d.ts +42 -0
- package/dist/runtime/server/utils/feed.mjs +161 -0
- package/dist/runtime/server/utils/impersonation.d.ts +67 -0
- package/dist/runtime/server/utils/impersonation.mjs +298 -0
- package/dist/runtime/server/utils/jobs.d.ts +70 -0
- package/dist/runtime/server/utils/jobs.mjs +125 -0
- package/dist/runtime/server/utils/kv-store.d.ts +9 -0
- package/dist/runtime/server/utils/kv-store.mjs +32 -0
- package/dist/runtime/server/utils/mail-suppression.d.ts +62 -0
- package/dist/runtime/server/utils/mail-suppression.mjs +328 -0
- package/dist/runtime/server/utils/mail.d.ts +90 -0
- package/dist/runtime/server/utils/mail.mjs +366 -0
- package/dist/runtime/server/utils/notifications.d.ts +51 -0
- package/dist/runtime/server/utils/notifications.mjs +215 -0
- package/dist/runtime/server/utils/organization.d.ts +54 -0
- package/dist/runtime/server/utils/organization.mjs +354 -0
- package/dist/runtime/server/utils/passwordless.d.ts +48 -0
- package/dist/runtime/server/utils/passwordless.mjs +179 -0
- package/dist/runtime/server/utils/payments.d.ts +121 -0
- package/dist/runtime/server/utils/payments.mjs +1067 -0
- package/dist/runtime/server/utils/queue-fallback.d.ts +2 -0
- package/dist/runtime/server/utils/queue-fallback.mjs +2 -0
- package/dist/runtime/server/utils/queue.d.ts +4 -0
- package/dist/runtime/server/utils/queue.mjs +3 -0
- package/dist/runtime/server/utils/rag.d.ts +25 -0
- package/dist/runtime/server/utils/rag.mjs +333 -0
- package/dist/runtime/server/utils/ratelimit.d.ts +45 -0
- package/dist/runtime/server/utils/ratelimit.mjs +182 -0
- package/dist/runtime/server/utils/realtime.d.ts +110 -0
- package/dist/runtime/server/utils/realtime.mjs +197 -0
- package/dist/runtime/server/utils/schema-fallback.d.ts +3 -0
- package/dist/runtime/server/utils/schema-fallback.mjs +2 -0
- package/dist/runtime/server/utils/session.d.ts +72 -0
- package/dist/runtime/server/utils/session.mjs +287 -0
- package/dist/runtime/server/utils/sso.d.ts +49 -0
- package/dist/runtime/server/utils/sso.mjs +131 -0
- package/dist/runtime/server/utils/storage.d.ts +111 -0
- package/dist/runtime/server/utils/storage.mjs +654 -0
- package/dist/runtime/server/utils/tenant.d.ts +44 -0
- package/dist/runtime/server/utils/tenant.mjs +285 -0
- package/dist/runtime/server/utils/totp.d.ts +33 -0
- package/dist/runtime/server/utils/totp.mjs +112 -0
- package/dist/runtime/server/utils/tracker.d.ts +72 -0
- package/dist/runtime/server/utils/tracker.mjs +139 -0
- package/dist/runtime/server/utils/turnstile.d.ts +17 -0
- package/dist/runtime/server/utils/turnstile.mjs +68 -0
- package/dist/runtime/server/utils/vapid.d.ts +35 -0
- package/dist/runtime/server/utils/vapid.mjs +211 -0
- package/dist/runtime/storage.d.ts +1 -0
- package/dist/runtime/storage.mjs +0 -0
- package/dist/runtime/types/ai.d.ts +68 -0
- package/dist/runtime/types/ai.mjs +0 -0
- package/dist/runtime/types/analytics.d.ts +30 -0
- package/dist/runtime/types/analytics.mjs +0 -0
- package/dist/runtime/types/auth-globals.d.ts +14 -0
- package/dist/runtime/types/auth.d.ts +153 -0
- package/dist/runtime/types/auth.mjs +0 -0
- package/dist/runtime/types/browser.d.ts +29 -0
- package/dist/runtime/types/browser.mjs +0 -0
- package/dist/runtime/types/d1.d.ts +44 -0
- package/dist/runtime/types/d1.mjs +0 -0
- package/dist/runtime/types/drizzle.d.ts +13 -0
- package/dist/runtime/types/drizzle.mjs +0 -0
- package/dist/runtime/types/durable-object.d.ts +51 -0
- package/dist/runtime/types/durable-object.mjs +0 -0
- package/dist/runtime/types/email.d.ts +66 -0
- package/dist/runtime/types/email.mjs +0 -0
- package/dist/runtime/types/hyperdrive.d.ts +18 -0
- package/dist/runtime/types/hyperdrive.mjs +0 -0
- package/dist/runtime/types/imports.d.ts +58 -0
- package/dist/runtime/types/index.d.ts +156 -0
- package/dist/runtime/types/index.mjs +13 -0
- package/dist/runtime/types/queue.d.ts +67 -0
- package/dist/runtime/types/queue.mjs +0 -0
- package/dist/runtime/types/r2.d.ts +108 -0
- package/dist/runtime/types/r2.mjs +0 -0
- package/dist/runtime/types/ratelimit.d.ts +21 -0
- package/dist/runtime/types/ratelimit.mjs +0 -0
- package/dist/runtime/types/vectorize.d.ts +74 -0
- package/dist/runtime/types/vectorize.mjs +0 -0
- package/dist/runtime/vectorize.d.ts +21 -0
- package/dist/runtime/vectorize.mjs +53 -0
- package/dist/types.d.ts +2750 -0
- package/dist/types.mjs +1 -0
- package/dist/utils/agents.d.ts +8 -0
- package/dist/utils/auth-schema.d.ts +11 -0
- package/dist/utils/bindings.d.ts +16 -0
- package/dist/utils/cms-schema.d.ts +1 -0
- package/dist/utils/cms-sources.d.ts +62 -0
- package/dist/utils/drizzle.d.ts +42 -0
- package/dist/utils/jobs.d.ts +8 -0
- package/dist/utils/local-db.d.ts +28 -0
- package/dist/utils/notifications-schema.d.ts +15 -0
- package/dist/utils/payments-schema.d.ts +11 -0
- package/dist/utils/pkg.d.ts +15 -0
- package/dist/utils/queue.d.ts +8 -0
- package/dist/utils/tenants-schema.d.ts +11 -0
- package/package.json +104 -0
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { createError } from "nuxt/server";
|
|
2
|
+
import { getDomainCache, getMultitenantConfig, normalizeDomain } from "./domains.mjs";
|
|
3
|
+
const devTenantsStore = /* @__PURE__ */ new Map();
|
|
4
|
+
devTenantsStore.set("default", {
|
|
5
|
+
id: "tenant_default",
|
|
6
|
+
slug: "default",
|
|
7
|
+
name: "Default Organization",
|
|
8
|
+
plan: "pro",
|
|
9
|
+
createdAt: Date.now(),
|
|
10
|
+
updatedAt: Date.now()
|
|
11
|
+
});
|
|
12
|
+
const DEFAULT_RESERVED_SLUGS = [
|
|
13
|
+
"admin",
|
|
14
|
+
"api",
|
|
15
|
+
"app",
|
|
16
|
+
"auth",
|
|
17
|
+
"cms",
|
|
18
|
+
"dashboard",
|
|
19
|
+
"mail",
|
|
20
|
+
"static",
|
|
21
|
+
"studio",
|
|
22
|
+
"www"
|
|
23
|
+
];
|
|
24
|
+
export function extractHostname(event) {
|
|
25
|
+
const req = event.node?.req;
|
|
26
|
+
const rawHost = req?.headers?.["x-forwarded-host"] || req?.headers?.host || "localhost";
|
|
27
|
+
const host = Array.isArray(rawHost) ? rawHost[0] : rawHost;
|
|
28
|
+
return host.split(":")[0].toLowerCase().trim();
|
|
29
|
+
}
|
|
30
|
+
export function extractSubdomain(host, rootDomains) {
|
|
31
|
+
for (const root of rootDomains) {
|
|
32
|
+
const cleanRoot = root.toLowerCase().trim();
|
|
33
|
+
if (host === cleanRoot || host === `www.${cleanRoot}`) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
if (host.endsWith(`.${cleanRoot}`)) {
|
|
37
|
+
const sub = host.slice(0, host.length - cleanRoot.length - 1);
|
|
38
|
+
if (!sub.includes(".")) {
|
|
39
|
+
return sub;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
let tenantsMigrated = false;
|
|
46
|
+
async function ensureTenantsTableMigrated(db) {
|
|
47
|
+
if (tenantsMigrated || !db) return;
|
|
48
|
+
try {
|
|
49
|
+
await db.run("ALTER TABLE _qarpeo_tenants ADD COLUMN organization_id TEXT");
|
|
50
|
+
} catch {
|
|
51
|
+
}
|
|
52
|
+
tenantsMigrated = true;
|
|
53
|
+
}
|
|
54
|
+
export async function getTenantBySlug(slug, event) {
|
|
55
|
+
const cleanSlug = slug.toLowerCase().trim();
|
|
56
|
+
for (const t of devTenantsStore.values()) {
|
|
57
|
+
if (t.slug.toLowerCase() === cleanSlug) return t;
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
const db = event?.context?.db;
|
|
61
|
+
if (db) {
|
|
62
|
+
await ensureTenantsTableMigrated(db);
|
|
63
|
+
const rows = await db.all(`SELECT * FROM _qarpeo_tenants WHERE slug = ? LIMIT 1`, [cleanSlug]);
|
|
64
|
+
if (rows?.[0]) {
|
|
65
|
+
const row = rows[0];
|
|
66
|
+
const rec = {
|
|
67
|
+
id: row.id,
|
|
68
|
+
slug: row.slug,
|
|
69
|
+
name: row.name,
|
|
70
|
+
plan: row.plan || "free",
|
|
71
|
+
organizationId: row.organization_id || void 0,
|
|
72
|
+
customDomain: row.custom_domain,
|
|
73
|
+
logoUrl: row.logo_url,
|
|
74
|
+
metadata: row.metadata_json ? JSON.parse(row.metadata_json) : {},
|
|
75
|
+
createdAt: row.created_at,
|
|
76
|
+
updatedAt: row.updated_at
|
|
77
|
+
};
|
|
78
|
+
devTenantsStore.set(rec.id, rec);
|
|
79
|
+
return rec;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
} catch {
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
export async function getTenantById(id, event) {
|
|
87
|
+
if (devTenantsStore.has(id)) {
|
|
88
|
+
return devTenantsStore.get(id);
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
const db = event?.context?.db;
|
|
92
|
+
if (db) {
|
|
93
|
+
await ensureTenantsTableMigrated(db);
|
|
94
|
+
const rows = await db.all(`SELECT * FROM _qarpeo_tenants WHERE id = ? LIMIT 1`, [id]);
|
|
95
|
+
if (rows?.[0]) {
|
|
96
|
+
const row = rows[0];
|
|
97
|
+
const rec = {
|
|
98
|
+
id: row.id,
|
|
99
|
+
slug: row.slug,
|
|
100
|
+
name: row.name,
|
|
101
|
+
plan: row.plan || "free",
|
|
102
|
+
organizationId: row.organization_id || void 0,
|
|
103
|
+
customDomain: row.custom_domain,
|
|
104
|
+
logoUrl: row.logo_url,
|
|
105
|
+
metadata: row.metadata_json ? JSON.parse(row.metadata_json) : {},
|
|
106
|
+
createdAt: row.created_at,
|
|
107
|
+
updatedAt: row.updated_at
|
|
108
|
+
};
|
|
109
|
+
devTenantsStore.set(rec.id, rec);
|
|
110
|
+
return rec;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
} catch {
|
|
114
|
+
}
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
export async function getTenantByOrganization(orgId, event) {
|
|
118
|
+
if (!orgId) return null;
|
|
119
|
+
for (const t of devTenantsStore.values()) {
|
|
120
|
+
if (t.organizationId && t.organizationId === orgId) return t;
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
const db = event?.context?.db;
|
|
124
|
+
if (db) {
|
|
125
|
+
await ensureTenantsTableMigrated(db);
|
|
126
|
+
const rows = await db.all(`SELECT * FROM _qarpeo_tenants WHERE organization_id = ? LIMIT 1`, [
|
|
127
|
+
orgId
|
|
128
|
+
]);
|
|
129
|
+
if (rows?.[0]) {
|
|
130
|
+
const row = rows[0];
|
|
131
|
+
const rec = {
|
|
132
|
+
id: row.id,
|
|
133
|
+
slug: row.slug,
|
|
134
|
+
name: row.name,
|
|
135
|
+
plan: row.plan || "free",
|
|
136
|
+
organizationId: row.organization_id || void 0,
|
|
137
|
+
customDomain: row.custom_domain,
|
|
138
|
+
logoUrl: row.logo_url,
|
|
139
|
+
metadata: row.metadata_json ? JSON.parse(row.metadata_json) : {},
|
|
140
|
+
createdAt: row.created_at,
|
|
141
|
+
updatedAt: row.updated_at
|
|
142
|
+
};
|
|
143
|
+
devTenantsStore.set(rec.id, rec);
|
|
144
|
+
return rec;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
} catch {
|
|
148
|
+
}
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
export async function saveTenant(tenant, event) {
|
|
152
|
+
devTenantsStore.set(tenant.id, tenant);
|
|
153
|
+
try {
|
|
154
|
+
const db = event?.context?.db;
|
|
155
|
+
if (db) {
|
|
156
|
+
await ensureTenantsTableMigrated(db);
|
|
157
|
+
await db.run(
|
|
158
|
+
`INSERT OR REPLACE INTO _qarpeo_tenants
|
|
159
|
+
(id, slug, name, plan, organization_id, custom_domain, logo_url, metadata_json, created_at, updated_at)
|
|
160
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
161
|
+
[
|
|
162
|
+
tenant.id,
|
|
163
|
+
tenant.slug,
|
|
164
|
+
tenant.name,
|
|
165
|
+
tenant.plan || "free",
|
|
166
|
+
tenant.organizationId || null,
|
|
167
|
+
tenant.customDomain || null,
|
|
168
|
+
tenant.logoUrl || null,
|
|
169
|
+
JSON.stringify(tenant.metadata || {}),
|
|
170
|
+
tenant.createdAt,
|
|
171
|
+
tenant.updatedAt
|
|
172
|
+
]
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
} catch {
|
|
176
|
+
}
|
|
177
|
+
return tenant;
|
|
178
|
+
}
|
|
179
|
+
export async function listTenants(event) {
|
|
180
|
+
try {
|
|
181
|
+
const db = event?.context?.db;
|
|
182
|
+
if (db) {
|
|
183
|
+
await ensureTenantsTableMigrated(db);
|
|
184
|
+
const rows = await db.all(`SELECT * FROM _qarpeo_tenants ORDER BY created_at DESC`);
|
|
185
|
+
if (rows && rows.length > 0) {
|
|
186
|
+
return rows.map((row) => ({
|
|
187
|
+
id: row.id,
|
|
188
|
+
slug: row.slug,
|
|
189
|
+
name: row.name,
|
|
190
|
+
plan: row.plan || "free",
|
|
191
|
+
organizationId: row.organization_id || void 0,
|
|
192
|
+
customDomain: row.custom_domain,
|
|
193
|
+
logoUrl: row.logo_url,
|
|
194
|
+
metadata: row.metadata_json ? JSON.parse(row.metadata_json) : {},
|
|
195
|
+
createdAt: row.created_at,
|
|
196
|
+
updatedAt: row.updated_at
|
|
197
|
+
}));
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
} catch {
|
|
201
|
+
}
|
|
202
|
+
if (devTenantsStore.size === 0) {
|
|
203
|
+
devTenantsStore.set("tenant_default", {
|
|
204
|
+
id: "tenant_default",
|
|
205
|
+
slug: "default",
|
|
206
|
+
name: "Default Organization",
|
|
207
|
+
plan: "pro",
|
|
208
|
+
createdAt: Date.now() - 864e5 * 7,
|
|
209
|
+
updatedAt: Date.now()
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
return Array.from(devTenantsStore.values());
|
|
213
|
+
}
|
|
214
|
+
export async function resolveTenant(event) {
|
|
215
|
+
const req = event.node?.req;
|
|
216
|
+
const headers = req?.headers || {};
|
|
217
|
+
const config = getMultitenantConfig(event);
|
|
218
|
+
const headerName = (config.headerName || "x-tenant-id").toLowerCase();
|
|
219
|
+
const headerVal = headers[headerName];
|
|
220
|
+
if (headerVal && typeof headerVal === "string") {
|
|
221
|
+
const fromId = await getTenantById(headerVal, event);
|
|
222
|
+
if (fromId) {
|
|
223
|
+
setTenant(event, fromId);
|
|
224
|
+
return fromId;
|
|
225
|
+
}
|
|
226
|
+
const fromSlug = await getTenantBySlug(headerVal, event);
|
|
227
|
+
if (fromSlug) {
|
|
228
|
+
setTenant(event, fromSlug);
|
|
229
|
+
return fromSlug;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
const host = extractHostname(event);
|
|
233
|
+
const rawRootDomains = config.rootDomains || [];
|
|
234
|
+
const rootDomains = (Array.isArray(rawRootDomains) ? rawRootDomains : [rawRootDomains]).filter(
|
|
235
|
+
Boolean
|
|
236
|
+
);
|
|
237
|
+
const reservedSlugs = config.reservedSlugs || DEFAULT_RESERVED_SLUGS;
|
|
238
|
+
const sub = extractSubdomain(host, rootDomains);
|
|
239
|
+
if (sub && !reservedSlugs.includes(sub)) {
|
|
240
|
+
const tenant = await getTenantBySlug(sub, event);
|
|
241
|
+
if (tenant) {
|
|
242
|
+
setTenant(event, tenant);
|
|
243
|
+
return tenant;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
const normHost = normalizeDomain(host);
|
|
247
|
+
const cachedTenantId = await getDomainCache(normHost, event);
|
|
248
|
+
if (cachedTenantId) {
|
|
249
|
+
const tenant = await getTenantById(cachedTenantId, event);
|
|
250
|
+
if (tenant) {
|
|
251
|
+
setTenant(event, tenant);
|
|
252
|
+
return tenant;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
if (process.env.NODE_ENV !== "production" && host === "localhost") {
|
|
256
|
+
const def = devTenantsStore.get("tenant_default") || null;
|
|
257
|
+
if (def) {
|
|
258
|
+
setTenant(event, def);
|
|
259
|
+
return def;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
264
|
+
export function setTenant(event, tenant) {
|
|
265
|
+
if (!event.context) {
|
|
266
|
+
;
|
|
267
|
+
event.context = {};
|
|
268
|
+
}
|
|
269
|
+
;
|
|
270
|
+
event.context.tenant = tenant;
|
|
271
|
+
}
|
|
272
|
+
export function getTenant(event) {
|
|
273
|
+
return event?.context?.tenant || null;
|
|
274
|
+
}
|
|
275
|
+
export function useTenant(event) {
|
|
276
|
+
const tenant = getTenant(event);
|
|
277
|
+
if (!tenant) {
|
|
278
|
+
throw createError({
|
|
279
|
+
statusCode: 404,
|
|
280
|
+
statusMessage: "Tenant Not Found",
|
|
281
|
+
message: "The requested tenant organization could not be found for this domain."
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
return tenant;
|
|
285
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { timingSafeEqualString } from "./crypto";
|
|
2
|
+
export { timingSafeEqualString };
|
|
3
|
+
export declare function generateBase32Secret(length?: number): string;
|
|
4
|
+
export declare function base32ToBytes(base32: string): Uint8Array;
|
|
5
|
+
export declare function generateTOTPCode(secret: string, timeStep?: number): Promise<string>;
|
|
6
|
+
/** Validates a 6-digit TOTP code with +/- 1 step drift tolerance (90-second validity). */
|
|
7
|
+
export declare function verifyTOTPCode(secret: string, userCode: string, timeStep?: number): Promise<boolean>;
|
|
8
|
+
export declare function hashBackupCode(code: string): Promise<string>;
|
|
9
|
+
export declare function generateBackupCodes(count?: number): Promise<{
|
|
10
|
+
rawCodes: string[];
|
|
11
|
+
hashedCodes: string[];
|
|
12
|
+
}>;
|
|
13
|
+
/** Verifies a cleartext backup code against a list of SHA-256 hashed codes in constant time. */
|
|
14
|
+
export declare function verifyBackupCode(rawCode: string, hashedCodes: string[]): Promise<{
|
|
15
|
+
valid: boolean;
|
|
16
|
+
matchingHash?: string;
|
|
17
|
+
}>;
|
|
18
|
+
/** Builds standard otpauth URL for Google Authenticator / 1Password. */
|
|
19
|
+
export declare function buildOTPAuthURL(options: {
|
|
20
|
+
issuer: string;
|
|
21
|
+
accountName: string;
|
|
22
|
+
secret: string;
|
|
23
|
+
}): string;
|
|
24
|
+
/**
|
|
25
|
+
* Generates the otpauth:// URL for a TOTP secret. The client is responsible for rendering the QR
|
|
26
|
+
* code from this URL (e.g. via qrcode-vue or a native QR renderer) — the server returns the URL
|
|
27
|
+
* rather than an SVG so authenticator apps always receive a clean, scannable code.
|
|
28
|
+
*/
|
|
29
|
+
export declare function generateTOTPUrl(options: {
|
|
30
|
+
issuer: string;
|
|
31
|
+
accountName: string;
|
|
32
|
+
secret: string;
|
|
33
|
+
}): string;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { timingSafeEqualString } from "./crypto.mjs";
|
|
2
|
+
export { timingSafeEqualString };
|
|
3
|
+
const BASE32_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
|
4
|
+
export function generateBase32Secret(length = 20) {
|
|
5
|
+
const randomBytes = new Uint8Array(length);
|
|
6
|
+
crypto.getRandomValues(randomBytes);
|
|
7
|
+
let secret = "";
|
|
8
|
+
for (let i = 0; i < randomBytes.length; i++) {
|
|
9
|
+
secret += BASE32_ALPHABET[randomBytes[i] % 32];
|
|
10
|
+
}
|
|
11
|
+
return secret;
|
|
12
|
+
}
|
|
13
|
+
export function base32ToBytes(base32) {
|
|
14
|
+
const cleaned = base32.toUpperCase().replace(/=+$/, "");
|
|
15
|
+
let bits = 0;
|
|
16
|
+
let value = 0;
|
|
17
|
+
const output = [];
|
|
18
|
+
for (let i = 0; i < cleaned.length; i++) {
|
|
19
|
+
const idx = BASE32_ALPHABET.indexOf(cleaned[i]);
|
|
20
|
+
if (idx === -1) continue;
|
|
21
|
+
value = value << 5 | idx;
|
|
22
|
+
bits += 5;
|
|
23
|
+
if (bits >= 8) {
|
|
24
|
+
output.push(value >>> bits - 8 & 255);
|
|
25
|
+
bits -= 8;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return new Uint8Array(output);
|
|
29
|
+
}
|
|
30
|
+
export async function generateTOTPCode(secret, timeStep = 30) {
|
|
31
|
+
const keyBytes = base32ToBytes(secret);
|
|
32
|
+
const counter = Math.floor(Date.now() / 1e3 / timeStep);
|
|
33
|
+
const counterBuffer = new ArrayBuffer(8);
|
|
34
|
+
const view = new DataView(counterBuffer);
|
|
35
|
+
view.setBigUint64(0, BigInt(counter));
|
|
36
|
+
const cryptoKey = await crypto.subtle.importKey(
|
|
37
|
+
"raw",
|
|
38
|
+
keyBytes,
|
|
39
|
+
{ name: "HMAC", hash: { name: "SHA-1" } },
|
|
40
|
+
false,
|
|
41
|
+
["sign"]
|
|
42
|
+
);
|
|
43
|
+
const signature = await crypto.subtle.sign("HMAC", cryptoKey, counterBuffer);
|
|
44
|
+
const sigBytes = new Uint8Array(signature);
|
|
45
|
+
const offset = sigBytes[sigBytes.length - 1] & 15;
|
|
46
|
+
const codeInt = (sigBytes[offset] & 127) << 24 | (sigBytes[offset + 1] & 255) << 16 | (sigBytes[offset + 2] & 255) << 8 | sigBytes[offset + 3] & 255;
|
|
47
|
+
const otp = codeInt % 1e6;
|
|
48
|
+
return otp.toString().padStart(6, "0");
|
|
49
|
+
}
|
|
50
|
+
export async function verifyTOTPCode(secret, userCode, timeStep = 30) {
|
|
51
|
+
const cleanCode = userCode.trim();
|
|
52
|
+
if (cleanCode.length !== 6) return false;
|
|
53
|
+
const keyBytes = base32ToBytes(secret);
|
|
54
|
+
const currentStep = Math.floor(Date.now() / 1e3 / timeStep);
|
|
55
|
+
const cryptoKey = await crypto.subtle.importKey(
|
|
56
|
+
"raw",
|
|
57
|
+
keyBytes,
|
|
58
|
+
{ name: "HMAC", hash: { name: "SHA-1" } },
|
|
59
|
+
false,
|
|
60
|
+
["sign"]
|
|
61
|
+
);
|
|
62
|
+
for (const stepOffset of [-1, 0, 1]) {
|
|
63
|
+
const step = currentStep + stepOffset;
|
|
64
|
+
const counterBuffer = new ArrayBuffer(8);
|
|
65
|
+
const view = new DataView(counterBuffer);
|
|
66
|
+
view.setBigUint64(0, BigInt(step));
|
|
67
|
+
const signature = await crypto.subtle.sign("HMAC", cryptoKey, counterBuffer);
|
|
68
|
+
const sigBytes = new Uint8Array(signature);
|
|
69
|
+
const offset = sigBytes[sigBytes.length - 1] & 15;
|
|
70
|
+
const codeInt = (sigBytes[offset] & 127) << 24 | (sigBytes[offset + 1] & 255) << 16 | (sigBytes[offset + 2] & 255) << 8 | sigBytes[offset + 3] & 255;
|
|
71
|
+
const expectedCode = (codeInt % 1e6).toString().padStart(6, "0");
|
|
72
|
+
if (expectedCode === cleanCode) {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
export async function hashBackupCode(code) {
|
|
79
|
+
const clean = code.trim().toUpperCase();
|
|
80
|
+
const encoder = new TextEncoder();
|
|
81
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", encoder.encode(clean));
|
|
82
|
+
return Array.from(new Uint8Array(hashBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
83
|
+
}
|
|
84
|
+
export async function generateBackupCodes(count = 8) {
|
|
85
|
+
const rawCodes = [];
|
|
86
|
+
const hashedCodes = [];
|
|
87
|
+
for (let i = 0; i < count; i++) {
|
|
88
|
+
const bytes = new Uint8Array(5);
|
|
89
|
+
crypto.getRandomValues(bytes);
|
|
90
|
+
const code = Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("").slice(0, 8).toUpperCase();
|
|
91
|
+
rawCodes.push(code);
|
|
92
|
+
hashedCodes.push(await hashBackupCode(code));
|
|
93
|
+
}
|
|
94
|
+
return { rawCodes, hashedCodes };
|
|
95
|
+
}
|
|
96
|
+
export async function verifyBackupCode(rawCode, hashedCodes) {
|
|
97
|
+
const inputHash = await hashBackupCode(rawCode);
|
|
98
|
+
for (const storedHash of hashedCodes) {
|
|
99
|
+
if (timingSafeEqualString(inputHash, storedHash)) {
|
|
100
|
+
return { valid: true, matchingHash: storedHash };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return { valid: false };
|
|
104
|
+
}
|
|
105
|
+
export function buildOTPAuthURL(options) {
|
|
106
|
+
const { issuer, accountName, secret } = options;
|
|
107
|
+
const label = encodeURIComponent(`${issuer}:${accountName}`);
|
|
108
|
+
return `otpauth://totp/${label}?secret=${secret}&issuer=${encodeURIComponent(issuer)}&algorithm=SHA1&digits=6&period=30`;
|
|
109
|
+
}
|
|
110
|
+
export function generateTOTPUrl(options) {
|
|
111
|
+
return buildOTPAuthURL(options);
|
|
112
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Tracker.ts Tier 2 Analytics — structured event tracking helpers backed by Cloudflare
|
|
3
|
+
* Analytics Engine. Wraps the raw `cf.analytics` binding with fixed blob/double schema for
|
|
4
|
+
* consistent querying. Schema (fixed slots): blobs[0] — event type: "pageview" | custom name
|
|
5
|
+
* blobs[1] — path blobs[2] — referrer blobs[3] — country (from CF-IPCountry header) blobs[4] —
|
|
6
|
+
* device type: "mobile" | "desktop" | "bot" blobs[5] — user agent (truncated to 256 chars)
|
|
7
|
+
* blobs[6] — privacy-safe session ID (SHA-256 of IP + UA, base36, no PII stored) blobs[7] —
|
|
8
|
+
* authenticated user ID (if available) doubles[0] — response time ms (0 if not known) doubles[1]
|
|
9
|
+
* — HTTP status code (0 if not applicable) indexes[0] — site ID / hostname for multi-site
|
|
10
|
+
* filtering
|
|
11
|
+
*/
|
|
12
|
+
import type { RequestEvent } from "nuxt/server";
|
|
13
|
+
export interface TrackPageviewOptions {
|
|
14
|
+
/** Override the path (defaults to event URL path). */
|
|
15
|
+
path?: string;
|
|
16
|
+
/** Override the referrer (defaults to Referer header). */
|
|
17
|
+
referrer?: string;
|
|
18
|
+
/** Authenticated user ID to associate with this pageview. */
|
|
19
|
+
userId?: string;
|
|
20
|
+
/** Response time in milliseconds. */
|
|
21
|
+
responseTime?: number;
|
|
22
|
+
/** HTTP status code. */
|
|
23
|
+
status?: number;
|
|
24
|
+
/** Override the site ID (defaults to runtimeConfig or hostname). */
|
|
25
|
+
siteId?: string;
|
|
26
|
+
/** CF AE binding name override. */
|
|
27
|
+
binding?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface TrackEventOptions {
|
|
30
|
+
/** Key-value metadata attached as additional blob data (serialised as JSON in blobs[8]). */
|
|
31
|
+
meta?: Record<string, string | number | boolean>;
|
|
32
|
+
/** Authenticated user ID. */
|
|
33
|
+
userId?: string;
|
|
34
|
+
/** Site ID. */
|
|
35
|
+
siteId?: string;
|
|
36
|
+
/** CF AE binding name override. */
|
|
37
|
+
binding?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Track a pageview event against the Cloudflare Analytics Engine. Safe to call fire-and-forget —
|
|
41
|
+
* never throws or blocks response.
|
|
42
|
+
*
|
|
43
|
+
* @param event H3 request event
|
|
44
|
+
* @param options Optional tracking overrides
|
|
45
|
+
*/
|
|
46
|
+
export declare function trackPageview(event: RequestEvent, options?: TrackPageviewOptions): void;
|
|
47
|
+
/**
|
|
48
|
+
* Track a named custom business event against the Cloudflare Analytics Engine. Safe to call
|
|
49
|
+
* fire-and-forget — never throws or blocks response.
|
|
50
|
+
*
|
|
51
|
+
* @param event H3 request event
|
|
52
|
+
* @param name Event name (e.g. "signup", "checkout", "upgrade")
|
|
53
|
+
* @param options Optional metadata and overrides
|
|
54
|
+
*/
|
|
55
|
+
export declare function trackEvent(event: RequestEvent, name: string, options?: TrackEventOptions): void;
|
|
56
|
+
/**
|
|
57
|
+
* Returns a tracker instance bound to the current H3 event. Useful when you want to call
|
|
58
|
+
* `trackPageview` / `trackEvent` multiple times without passing the event every time.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ;```ts
|
|
62
|
+
* const tracker = useTracker(event)
|
|
63
|
+
* tracker.trackPageview()
|
|
64
|
+
* tracker.trackEvent("signup", { meta: { plan: "pro" } })
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare function useTracker(event: RequestEvent): {
|
|
68
|
+
/** Track a pageview for the current request. */
|
|
69
|
+
trackPageview: (options?: TrackPageviewOptions) => void;
|
|
70
|
+
/** Track a custom named event. */
|
|
71
|
+
trackEvent: (name: string, options?: TrackEventOptions) => void;
|
|
72
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { getAnalyticsBinding } from "../../analytics.mjs";
|
|
3
|
+
function buildSessionId(ip, ua) {
|
|
4
|
+
return createHash("sha256").update(`${ip}|${ua}`).digest("base64url").slice(0, 16);
|
|
5
|
+
}
|
|
6
|
+
function detectDevice(ua) {
|
|
7
|
+
const lc = ua.toLowerCase();
|
|
8
|
+
if (/bot|crawl|spider|slurp|facebookexternalhit|twitterbot|whatsapp|linkedinbot/i.test(lc))
|
|
9
|
+
return "bot";
|
|
10
|
+
if (/mobile|android|iphone|ipad|ipod|blackberry|windows phone/i.test(lc)) return "mobile";
|
|
11
|
+
return "desktop";
|
|
12
|
+
}
|
|
13
|
+
function extractPath(url) {
|
|
14
|
+
try {
|
|
15
|
+
return new URL(url).pathname;
|
|
16
|
+
} catch {
|
|
17
|
+
return url.split("?")[0] || "/";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function resolveSiteId(event, override) {
|
|
21
|
+
if (override) return override;
|
|
22
|
+
try {
|
|
23
|
+
const rc = event.context?.nitro?.runtimeConfig ?? event.$config;
|
|
24
|
+
const configured = rc?.qarpeo?.analytics?.siteId;
|
|
25
|
+
if (configured) return configured;
|
|
26
|
+
} catch {
|
|
27
|
+
}
|
|
28
|
+
return event.node?.req?.headers?.host || "unknown";
|
|
29
|
+
}
|
|
30
|
+
function resolveAnalyticsBinding(event, override) {
|
|
31
|
+
if (override) return override;
|
|
32
|
+
try {
|
|
33
|
+
const rc = event.context?.nitro?.runtimeConfig ?? event.$config;
|
|
34
|
+
return rc?.qarpeo?.analytics?.binding || "ANALYTICS";
|
|
35
|
+
} catch {
|
|
36
|
+
return "ANALYTICS";
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export function trackPageview(event, options = {}) {
|
|
40
|
+
try {
|
|
41
|
+
const req = event.node?.req;
|
|
42
|
+
const headers = req?.headers || {};
|
|
43
|
+
const getHeader = (name) => (Array.isArray(headers[name]) ? headers[name][0] : headers[name]) || "";
|
|
44
|
+
const ua = getHeader("user-agent").slice(0, 256);
|
|
45
|
+
const ip = getHeader("cf-connecting-ip") || getHeader("x-forwarded-for").split(",")[0].trim() || req?.socket?.remoteAddress || "unknown";
|
|
46
|
+
const country = getHeader("cf-ipcountry") || "XX";
|
|
47
|
+
const referrer = options.referrer ?? getHeader("referer");
|
|
48
|
+
const path = options.path ?? extractPath(req?.url || "/");
|
|
49
|
+
const device = detectDevice(ua);
|
|
50
|
+
const sessionId = buildSessionId(ip, ua);
|
|
51
|
+
const siteId = resolveSiteId(event, options.siteId);
|
|
52
|
+
const bindingName = resolveAnalyticsBinding(event, options.binding);
|
|
53
|
+
const ae = getAnalyticsBinding(bindingName, event);
|
|
54
|
+
ae.writeDataPoint({
|
|
55
|
+
blobs: [
|
|
56
|
+
"pageview",
|
|
57
|
+
// [0] event type
|
|
58
|
+
path,
|
|
59
|
+
// [1] path
|
|
60
|
+
referrer,
|
|
61
|
+
// [2] referrer
|
|
62
|
+
country,
|
|
63
|
+
// [3] country
|
|
64
|
+
device,
|
|
65
|
+
// [4] device
|
|
66
|
+
ua,
|
|
67
|
+
// [5] user agent
|
|
68
|
+
sessionId,
|
|
69
|
+
// [6] session fingerprint
|
|
70
|
+
options.userId || ""
|
|
71
|
+
// [7] user ID
|
|
72
|
+
],
|
|
73
|
+
doubles: [
|
|
74
|
+
options.responseTime ?? 0,
|
|
75
|
+
// [0] response time ms
|
|
76
|
+
options.status ?? 0
|
|
77
|
+
// [1] HTTP status code
|
|
78
|
+
],
|
|
79
|
+
indexes: [siteId]
|
|
80
|
+
// [0] site ID
|
|
81
|
+
});
|
|
82
|
+
} catch {
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export function trackEvent(event, name, options = {}) {
|
|
86
|
+
try {
|
|
87
|
+
const req = event.node?.req;
|
|
88
|
+
const headers = req?.headers || {};
|
|
89
|
+
const getHeader = (h) => (Array.isArray(headers[h]) ? headers[h][0] : headers[h]) || "";
|
|
90
|
+
const ua = getHeader("user-agent").slice(0, 256);
|
|
91
|
+
const ip = getHeader("cf-connecting-ip") || getHeader("x-forwarded-for").split(",")[0].trim() || "unknown";
|
|
92
|
+
const country = getHeader("cf-ipcountry") || "XX";
|
|
93
|
+
const path = extractPath(req?.url || "/");
|
|
94
|
+
const device = detectDevice(ua);
|
|
95
|
+
const sessionId = buildSessionId(ip, ua);
|
|
96
|
+
const siteId = resolveSiteId(event, options.siteId);
|
|
97
|
+
const bindingName = resolveAnalyticsBinding(event, options.binding);
|
|
98
|
+
const metaJson = options.meta ? JSON.stringify(options.meta).slice(0, 512) : "";
|
|
99
|
+
const ae = getAnalyticsBinding(bindingName, event);
|
|
100
|
+
ae.writeDataPoint({
|
|
101
|
+
blobs: [
|
|
102
|
+
name,
|
|
103
|
+
// [0] event type / name
|
|
104
|
+
path,
|
|
105
|
+
// [1] path where event occurred
|
|
106
|
+
"",
|
|
107
|
+
// [2] referrer (n/a for events)
|
|
108
|
+
country,
|
|
109
|
+
// [3] country
|
|
110
|
+
device,
|
|
111
|
+
// [4] device
|
|
112
|
+
ua,
|
|
113
|
+
// [5] user agent
|
|
114
|
+
sessionId,
|
|
115
|
+
// [6] session fingerprint
|
|
116
|
+
options.userId || "",
|
|
117
|
+
// [7] user ID
|
|
118
|
+
metaJson
|
|
119
|
+
// [8] metadata JSON
|
|
120
|
+
],
|
|
121
|
+
doubles: [
|
|
122
|
+
0,
|
|
123
|
+
// [0] response time (n/a)
|
|
124
|
+
0
|
|
125
|
+
// [1] status code (n/a)
|
|
126
|
+
],
|
|
127
|
+
indexes: [siteId]
|
|
128
|
+
});
|
|
129
|
+
} catch {
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
export function useTracker(event) {
|
|
133
|
+
return {
|
|
134
|
+
/** Track a pageview for the current request. */
|
|
135
|
+
trackPageview: (options = {}) => trackPageview(event, options),
|
|
136
|
+
/** Track a custom named event. */
|
|
137
|
+
trackEvent: (name, options = {}) => trackEvent(event, name, options)
|
|
138
|
+
};
|
|
139
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface TurnstileVerificationResult {
|
|
2
|
+
success: boolean;
|
|
3
|
+
errorCodes?: string[];
|
|
4
|
+
challengeTs?: string;
|
|
5
|
+
hostname?: string;
|
|
6
|
+
action?: string;
|
|
7
|
+
cdata?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Validates a Cloudflare Turnstile token using Cloudflare's siteverify API.
|
|
11
|
+
* Reads secret key from NUXT_TURNSTILE_SECRET_KEY, TURNSTILE_SECRET_KEY, or qarpeo.auth.turnstile.secretKey.
|
|
12
|
+
*/
|
|
13
|
+
export declare function verifyTurnstileToken(event: any, token?: string, remoteIp?: string): Promise<TurnstileVerificationResult>;
|
|
14
|
+
/**
|
|
15
|
+
* Enforces Cloudflare Turnstile verification. Throws 403 Forbidden if invalid.
|
|
16
|
+
*/
|
|
17
|
+
export declare function requireTurnstile(event: any, token?: string): Promise<void>;
|