@egbe-ai/opencode 0.0.0-stage → 0.1.8
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 +4 -0
- package/README.md +124 -2
- package/index.js +5 -0
- package/package.json +55 -4
- package/plugin.js +230 -0
- package/session-log.js +315 -0
- package/skills/.egbe-catalog/manifest.json +1 -0
- package/skills/egbe-os-analytics/SKILL.md +499 -0
- package/skills/egbe-os-analytics/canonical-events.v1.json +256 -0
- package/skills/egbe-os-analytics/references/session-funnel.md +130 -0
- package/skills/egbe-os-analytics/references/workflows/activation-tracking.md +147 -0
- package/skills/egbe-os-analytics/references/workflows/landing-click-tracking.md +209 -0
- package/skills/egbe-os-analytics/references/workflows/payment-lifecycle-tracking.md +122 -0
- package/skills/egbe-os-analytics/references/workflows/product-funnel-tracking.md +77 -0
- package/skills/egbe-os-analytics/references/workflows/signup-lifecycle-tracking.md +208 -0
- package/skills/egbe-os-analytics/scripts/umami_funnel.py +927 -0
- package/skills/egbe-os-apollo-lead-finder/SKILL.md +135 -0
- package/skills/egbe-os-apollo-lead-finder/references/operations.md +240 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/enrich.js +6 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/enrich.sh +4 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/find-leads.js +6 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/find-leads.sh +4 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/lib/apollo-client.js +343 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/lib/connection-identity.js +17 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/lib/helpers.js +127 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/lib/places-filters.js +217 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/lib/sourcing.js +153 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/places-leads.js +653 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/places-leads.sh +4 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/search.js +6 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/search.sh +4 -0
- package/skills/egbe-os-campaign-landing-page/SKILL.md +95 -0
- package/skills/egbe-os-campaign-landing-page/agents/openai.yaml +4 -0
- package/skills/egbe-os-campaign-landing-page/references/leads-calendar-and-tracking.md +66 -0
- package/skills/egbe-os-campaign-landing-page/references/os-wiring.md +58 -0
- package/skills/egbe-os-campaign-landing-page/references/qa.md +40 -0
- package/skills/egbe-os-campaign-landing-page/references/routing.md +32 -0
- package/skills/egbe-os-db/SKILL.md +174 -0
- package/skills/egbe-os-deploy/SKILL.md +412 -0
- package/skills/egbe-os-design/SKILL.md +182 -0
- package/skills/egbe-os-design-landing-page/SKILL.md +117 -0
- package/skills/egbe-os-design-landing-page/agents/openai.yaml +4 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/.dockerignore +11 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/AGENTS.md +31 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/Dockerfile +21 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/eslint.config.mjs +18 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/next.config.ts +11 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/package.json +36 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/postcss.config.mjs +7 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/public/.gitkeep +1 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/sentry.edge.config.ts +13 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/sentry.server.config.ts +13 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/app/global-error.tsx +19 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/app/globals.css +22 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/app/layout.tsx +21 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/app/page.tsx +3 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/app/privacy/page.tsx +28 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/components/egbe-analytics.tsx +39 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/instrumentation-client.ts +15 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/instrumentation.ts +13 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/lib/egbe-observability.generated.ts +20 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/lib/utils.ts +6 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/tsconfig.json +34 -0
- package/skills/egbe-os-design-landing-page/references/application-preparation.md +44 -0
- package/skills/egbe-os-design-landing-page/references/page-inputs.md +22 -0
- package/skills/egbe-os-destination-readiness/SKILL.md +132 -0
- package/skills/egbe-os-destination-readiness/references/checks.md +130 -0
- package/skills/egbe-os-destination-readiness/references/network-requirements.md +34 -0
- package/skills/egbe-os-destination-readiness/references/report.md +116 -0
- package/skills/egbe-os-domains/SKILL.md +189 -0
- package/skills/egbe-os-errors/SKILL.md +259 -0
- package/skills/egbe-os-git/SKILL.md +275 -0
- package/skills/egbe-os-git/references/issues.md +33 -0
- package/skills/egbe-os-google-ads/SKILL.md +163 -0
- package/skills/egbe-os-google-ads/references/artifacts.md +133 -0
- package/skills/egbe-os-google-ads/references/campaigns.md +157 -0
- package/skills/egbe-os-google-ads/references/conversions.md +153 -0
- package/skills/egbe-os-google-ads/references/delivery.md +128 -0
- package/skills/egbe-os-google-ads/references/keyword-ideas.md +40 -0
- package/skills/egbe-os-google-ads/references/reporting.md +105 -0
- package/skills/egbe-os-google-ads/references/search-assets.md +219 -0
- package/skills/egbe-os-google-ads/references/server-conversions.md +119 -0
- package/skills/egbe-os-google-auth/SKILL.md +285 -0
- package/skills/egbe-os-google-auth/agents/openai.yaml +4 -0
- package/skills/egbe-os-gtm-knowledge/SKILL.md +151 -0
- package/skills/egbe-os-images/SKILL.md +163 -0
- package/skills/egbe-os-images/references/stock-images.md +21 -0
- package/skills/egbe-os-instantly-campaign-launcher/SKILL.md +127 -0
- package/skills/egbe-os-instantly-campaign-launcher/references/instantly-ops.md +260 -0
- package/skills/egbe-os-instantly-campaign-launcher/references/observation-and-scheduling.md +188 -0
- package/skills/egbe-os-instantly-campaign-launcher/references/reply-handling.md +116 -0
- package/skills/egbe-os-instantly-campaign-launcher/references/run-spec-template.json +65 -0
- package/skills/egbe-os-instantly-campaign-launcher/references/run-state.md +145 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/conclude-campaign.js +158 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/install-crons.js +956 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/launch-campaign.js +2008 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/campaign-metrics.js +124 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/confirmed-opt-outs.js +208 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/connection-identity.js +17 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/create-once.js +23 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/gtm-identity.js +125 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/helpers.js +545 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/html-body.js +266 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/instantly-client.js +328 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/outreach-db.js +370 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/recipient-exclusion/index.js +86 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/replenish-test-harness.js +53 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/reply-queue.js +67 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/run-config.js +103 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/sender-selection.js +105 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/monitor-campaign.js +607 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/outreach-report.js +147 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/replenish-leads.js +619 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/reply-worker.js +258 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/run-cron-job.js +32 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/send-reply.js +260 -0
- package/skills/egbe-os-linkedin-ads/SKILL.md +114 -0
- package/skills/egbe-os-linkedin-ads/references/destination-requirements.md +30 -0
- package/skills/egbe-os-linkedin-ads/references/runtime/api-reference.md +154 -0
- package/skills/egbe-os-linkedin-ads/references/runtime/artifacts.md +63 -0
- package/skills/egbe-os-linkedin-ads/references/workflows/build-paused.md +44 -0
- package/skills/egbe-os-linkedin-ads/references/workflows/conversions.md +88 -0
- package/skills/egbe-os-linkedin-ads/references/workflows/launch-and-pause.md +49 -0
- package/skills/egbe-os-linkedin-ads/references/workflows/monitoring.md +35 -0
- package/skills/egbe-os-linkedin-ads/references/workflows/readiness.md +63 -0
- package/skills/egbe-os-linkedin-ads/references/workflows/targeting-and-creative.md +52 -0
- package/skills/egbe-os-llm/SKILL.md +160 -0
- package/skills/egbe-os-mail/SKILL.md +180 -0
- package/skills/egbe-os-me/SKILL.md +119 -0
- package/skills/egbe-os-meta-ads/SKILL.md +114 -0
- package/skills/egbe-os-meta-ads/references/creative/creative-specs.md +15 -0
- package/skills/egbe-os-meta-ads/references/creative/talking-head.md +35 -0
- package/skills/egbe-os-meta-ads/references/destination-requirements.md +30 -0
- package/skills/egbe-os-meta-ads/references/runtime/api-reference.md +436 -0
- package/skills/egbe-os-meta-ads/references/runtime/artifacts.md +51 -0
- package/skills/egbe-os-meta-ads/references/runtime/insights-reference.md +187 -0
- package/skills/egbe-os-meta-ads/references/runtime/pixel-install.md +196 -0
- package/skills/egbe-os-meta-ads/references/runtime/shared-analytics-attribution.md +16 -0
- package/skills/egbe-os-meta-ads/references/workflows/build-paused.md +36 -0
- package/skills/egbe-os-meta-ads/references/workflows/launch-ready.md +16 -0
- package/skills/egbe-os-meta-ads/references/workflows/launch.md +23 -0
- package/skills/egbe-os-meta-ads/references/workflows/monitoring.md +72 -0
- package/skills/egbe-os-meta-ads/references/workflows/pause.md +17 -0
- package/skills/egbe-os-meta-ads/references/workflows/recovery.md +23 -0
- package/skills/egbe-os-meta-ads/scripts/check-pixel.py +229 -0
- package/skills/egbe-os-meta-ads/scripts/validate-meta-artifacts.py +187 -0
- package/skills/egbe-os-notifications/SKILL.md +78 -0
- package/skills/egbe-os-openai-ads/SKILL.md +149 -0
- package/skills/egbe-os-openai-ads/references/creative/chat-card.md +51 -0
- package/skills/egbe-os-openai-ads/references/destination-requirements.md +29 -0
- package/skills/egbe-os-openai-ads/references/runtime/api-reference.md +219 -0
- package/skills/egbe-os-openai-ads/references/runtime/artifacts.md +169 -0
- package/skills/egbe-os-openai-ads/references/workflows/build-paused.md +40 -0
- package/skills/egbe-os-openai-ads/references/workflows/conversions.md +40 -0
- package/skills/egbe-os-openai-ads/references/workflows/creative-assembly.md +24 -0
- package/skills/egbe-os-openai-ads/references/workflows/launch.md +27 -0
- package/skills/egbe-os-openai-ads/references/workflows/monitoring.md +54 -0
- package/skills/egbe-os-openai-ads/references/workflows/pause.md +22 -0
- package/skills/egbe-os-openai-ads/references/workflows/readiness.md +37 -0
- package/skills/egbe-os-openai-ads/references/workflows/tracking.md +32 -0
- package/skills/egbe-os-openai-ads/scripts/validate-openai-artifacts.py +271 -0
- package/skills/egbe-os-organic-trend-watch/SKILL.md +139 -0
- package/skills/egbe-os-organic-trend-watch/agents/openai.yaml +4 -0
- package/skills/egbe-os-organic-trend-watch/references/analysis-and-adaptation.md +54 -0
- package/skills/egbe-os-organic-trend-watch/references/collection-and-analysis.md +117 -0
- package/skills/egbe-os-organic-trend-watch/references/output-contract.md +133 -0
- package/skills/egbe-os-organic-trend-watch/references/provider-contract.md +169 -0
- package/skills/egbe-os-organic-trend-watch/references/runtime-contract.md +204 -0
- package/skills/egbe-os-organic-trend-watch/references/visual-analysis-prompt.md +17 -0
- package/skills/egbe-os-organic-trend-watch/scripts/_analysis.py +612 -0
- package/skills/egbe-os-organic-trend-watch/scripts/_contract.py +1133 -0
- package/skills/egbe-os-organic-trend-watch/scripts/_provider_inputs.py +165 -0
- package/skills/egbe-os-organic-trend-watch/scripts/analyze-visual-evidence.py +315 -0
- package/skills/egbe-os-organic-trend-watch/scripts/build-provider-inputs.py +88 -0
- package/skills/egbe-os-organic-trend-watch/scripts/connection_identity.py +22 -0
- package/skills/egbe-os-organic-trend-watch/scripts/egbe_artifacts.py +24 -0
- package/skills/egbe-os-organic-trend-watch/scripts/finalize-receipt.py +106 -0
- package/skills/egbe-os-organic-trend-watch/scripts/normalize-videos.py +647 -0
- package/skills/egbe-os-organic-trend-watch/scripts/prepare-visual-evidence.py +324 -0
- package/skills/egbe-os-organic-trend-watch/scripts/render-result.py +30 -0
- package/skills/egbe-os-organic-trend-watch/scripts/run-apify.py +723 -0
- package/skills/egbe-os-organic-trend-watch/scripts/run-state.py +192 -0
- package/skills/egbe-os-organic-trend-watch/scripts/validate-context.py +27 -0
- package/skills/egbe-os-organic-trend-watch/scripts/validate-runtime.py +137 -0
- package/skills/egbe-os-payments/SKILL.md +215 -0
- package/skills/egbe-os-payments/agents/openai.yaml +4 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/.egbe/scaffolds/billing-nextjs-subscription.v1.json +5 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/AGENTS.append.md +13 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/db/migrations/1000_egbe_billing.sql +66 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/package.fragment.json +12 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/scripts/billing-sync.mjs +162 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/app/account/billing/error.tsx +11 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/app/account/billing/loading.tsx +8 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/app/account/billing/page.tsx +121 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/app/api/billing/checkout/route.ts +102 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/app/api/billing/portal/route.ts +54 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/app/api/billing/status/route.ts +22 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/app/api/payments/webhook/route.ts +65 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/components/egbe-billing/plan-badge.tsx +16 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/billing-sync.test.mjs +58 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/catalog.ts +82 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/checkout-payload.ts +47 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/foundation-contract.test.mjs +59 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/lifecycle.d.ts +16 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/lifecycle.mjs +82 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/lifecycle.test.mjs +94 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/os-client.ts +96 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/plans.json +17 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/repository.ts +325 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/signature.d.ts +6 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/signature.mjs +22 -0
- package/skills/egbe-os-payments/references/contracts/plan-catalog.md +46 -0
- package/skills/egbe-os-payments/references/security/durable-verification.md +64 -0
- package/skills/egbe-os-payments/references/security/server-integration.md +26 -0
- package/skills/egbe-os-payments/references/security/webhook-and-entitlements.md +152 -0
- package/skills/egbe-os-payments/references/ux/billing-experience.md +47 -0
- package/skills/egbe-os-payments/references/workflows/account-billing.md +64 -0
- package/skills/egbe-os-payments/references/workflows/discounts-and-promotion-codes.md +265 -0
- package/skills/egbe-os-payments/references/workflows/one-time-purchase.md +75 -0
- package/skills/egbe-os-payments/references/workflows/product-checkout.md +355 -0
- package/skills/egbe-os-payments/references/workflows/subscription-lifecycle.md +55 -0
- package/skills/egbe-os-playbook/SKILL.md +79 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/channels/email-outreach.md +91 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/channels/google-search.md +40 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/channels/linkedin.md +24 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/channels/meta.md +23 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/channels/openai.md +15 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/channels/reddit.md +56 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/choose-test.md +73 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/evaluate.md +91 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/market.md +96 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/run-test.md +111 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition.md +56 -0
- package/skills/egbe-os-playbook/playbooks/product/business-loop.md +141 -0
- package/skills/egbe-os-playbook/playbooks/product/collaboration.md +26 -0
- package/skills/egbe-os-playbook/playbooks/product/deliver.md +75 -0
- package/skills/egbe-os-playbook/playbooks/product/diagnose.md +80 -0
- package/skills/egbe-os-playbook/playbooks/product/evaluate.md +67 -0
- package/skills/egbe-os-playbook/playbooks/product/experience.md +132 -0
- package/skills/egbe-os-playbook/playbooks/product/loop-examples.md +67 -0
- package/skills/egbe-os-playbook/playbooks/product/offer.md +65 -0
- package/skills/egbe-os-playbook/playbooks/product/value.md +91 -0
- package/skills/egbe-os-playbook/playbooks/product.md +67 -0
- package/skills/egbe-os-playbook/references/catalog.md +127 -0
- package/skills/egbe-os-playbook/references/changes.md +167 -0
- package/skills/egbe-os-playbook/scripts/playbook-changes.py +6 -0
- package/skills/egbe-os-playbook/scripts/playbook_changes/__init__.py +1 -0
- package/skills/egbe-os-playbook/scripts/playbook_changes/cli.py +57 -0
- package/skills/egbe-os-playbook/scripts/playbook_changes/operations.py +137 -0
- package/skills/egbe-os-playbook/scripts/playbook_changes/protocol.py +132 -0
- package/skills/egbe-os-playbook/scripts/playbook_changes/storage.py +180 -0
- package/skills/egbe-os-playbook/scripts/playbook_changes/transport.py +113 -0
- package/skills/egbe-os-product-auth/SKILL.md +151 -0
- package/skills/egbe-os-product-auth/agents/openai.yaml +4 -0
- package/skills/egbe-os-product-auth/assets/db/README.md +102 -0
- package/skills/egbe-os-product-auth/assets/db/create-validation-session.mjs +223 -0
- package/skills/egbe-os-product-auth/assets/db/migrate.mjs +64 -0
- package/skills/egbe-os-product-auth/assets/db/migrations/0001_auth.sql +33 -0
- package/skills/egbe-os-product-auth/assets/db/migrations/0002_auth_identities.sql +16 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-auth-database/AGENTS.append.md +17 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-auth-database/package.fragment.json +10 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-nextjs-postgres/AGENTS.append.md +9 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-nextjs-postgres/package.fragment.json +13 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-nextjs-postgres/src/lib/egbe-product/db.ts +31 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-nextjs-postgres/src/lib/egbe-product/identity.ts +94 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-nextjs-postgres/src/lib/egbe-product/index.ts +3 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-nextjs-postgres/src/lib/egbe-product/session.ts +91 -0
- package/skills/egbe-os-product-auth/references/contracts/live-auth-interface.md +108 -0
- package/skills/egbe-os-product-auth/references/frameworks/nextjs.md +34 -0
- package/skills/egbe-os-product-auth/references/security/session-and-credentials.md +73 -0
- package/skills/egbe-os-product-auth/references/ux/auth-experience.md +58 -0
- package/skills/egbe-os-product-auth/references/workflows/account-recovery.md +22 -0
- package/skills/egbe-os-product-auth/references/workflows/build-auth.md +212 -0
- package/skills/egbe-os-product-auth/references/workflows/google.md +34 -0
- package/skills/egbe-os-product-auth/references/workflows/passwordless-email.md +65 -0
- package/skills/egbe-os-product-build/SKILL.md +111 -0
- package/skills/egbe-os-product-build/agents/openai.yaml +4 -0
- package/skills/egbe-os-product-build/references/capabilities.md +25 -0
- package/skills/egbe-os-product-build/references/engineering.md +72 -0
- package/skills/egbe-os-product-build/references/execution.md +55 -0
- package/skills/egbe-os-product-build/references/foundations.md +93 -0
- package/skills/egbe-os-product-build/references/interface-quality.md +32 -0
- package/skills/egbe-os-product-build/references/workflows/private-review-handoff.md +86 -0
- package/skills/egbe-os-product-build/scripts/scaffold.py +296 -0
- package/skills/egbe-os-product-demo-video/SKILL.md +118 -0
- package/skills/egbe-os-product-demo-video/references/recording.md +32 -0
- package/skills/egbe-os-product-market-research/SKILL.md +159 -0
- package/skills/egbe-os-product-market-research/agents/openai.yaml +4 -0
- package/skills/egbe-os-product-market-research/references/catalog.v1.json +177 -0
- package/skills/egbe-os-product-market-research/references/config/channel-footprint-sources.v1.json +99 -0
- package/skills/egbe-os-product-market-research/references/config/creative-taxonomy.v1.json +367 -0
- package/skills/egbe-os-product-market-research/references/contracts/creative-video.md +75 -0
- package/skills/egbe-os-product-market-research/references/contracts/funnel-teardown.md +235 -0
- package/skills/egbe-os-product-market-research/references/contracts/geography-comparison.md +71 -0
- package/skills/egbe-os-product-market-research/references/contracts/lifecycle-capture.md +119 -0
- package/skills/egbe-os-product-market-research/references/contracts/research-artifacts.md +520 -0
- package/skills/egbe-os-product-market-research/references/contracts/walk-mechanics.v2.json +18 -0
- package/skills/egbe-os-product-market-research/references/prompts/acquisition-channels.md +137 -0
- package/skills/egbe-os-product-market-research/references/prompts/acquisition-channels.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/prompts/competitive-landscape.md +118 -0
- package/skills/egbe-os-product-market-research/references/prompts/competitive-landscape.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/prompts/demand-validation.md +154 -0
- package/skills/egbe-os-product-market-research/references/prompts/demand-validation.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/prompts/market-size-and-dynamics.md +100 -0
- package/skills/egbe-os-product-market-research/references/prompts/market-size-and-dynamics.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/prompts/pricing-and-monetization.md +126 -0
- package/skills/egbe-os-product-market-research/references/prompts/pricing-and-monetization.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/prompts/target-audience.md +98 -0
- package/skills/egbe-os-product-market-research/references/prompts/target-audience.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/prompts/unit-economics.md +217 -0
- package/skills/egbe-os-product-market-research/references/prompts/unit-economics.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/prompts/value-proposition.md +113 -0
- package/skills/egbe-os-product-market-research/references/prompts/value-proposition.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/workflows/acquisition-channels.md +27 -0
- package/skills/egbe-os-product-market-research/references/workflows/channel-footprint.md +163 -0
- package/skills/egbe-os-product-market-research/references/workflows/community-demand.md +100 -0
- package/skills/egbe-os-product-market-research/references/workflows/competitive-landscape.md +27 -0
- package/skills/egbe-os-product-market-research/references/workflows/competitor-ads.md +82 -0
- package/skills/egbe-os-product-market-research/references/workflows/competitor-set.md +300 -0
- package/skills/egbe-os-product-market-research/references/workflows/creative-patterns.md +228 -0
- package/skills/egbe-os-product-market-research/references/workflows/demand-validation.md +27 -0
- package/skills/egbe-os-product-market-research/references/workflows/fleet-prior.md +80 -0
- package/skills/egbe-os-product-market-research/references/workflows/funnel-teardown.md +184 -0
- package/skills/egbe-os-product-market-research/references/workflows/geography-comparison.md +84 -0
- package/skills/egbe-os-product-market-research/references/workflows/keyword-economics.md +122 -0
- package/skills/egbe-os-product-market-research/references/workflows/lifecycle-capture.md +218 -0
- package/skills/egbe-os-product-market-research/references/workflows/local-research.md +55 -0
- package/skills/egbe-os-product-market-research/references/workflows/market-size-and-dynamics.md +27 -0
- package/skills/egbe-os-product-market-research/references/workflows/preview.md +175 -0
- package/skills/egbe-os-product-market-research/references/workflows/pricing-and-monetization.md +27 -0
- package/skills/egbe-os-product-market-research/references/workflows/recommendations.md +35 -0
- package/skills/egbe-os-product-market-research/references/workflows/review-mining.md +76 -0
- package/skills/egbe-os-product-market-research/references/workflows/target-audience.md +27 -0
- package/skills/egbe-os-product-market-research/references/workflows/tiktok-reels-market-trends.md +46 -0
- package/skills/egbe-os-product-market-research/references/workflows/unit-economics.md +27 -0
- package/skills/egbe-os-product-market-research/references/workflows/value-proposition.md +27 -0
- package/skills/egbe-os-product-market-research/scripts/build-organic-trend-context.py +167 -0
- package/skills/egbe-os-product-market-research/scripts/build-preview-context.py +91 -0
- package/skills/egbe-os-product-market-research/scripts/build-research-query.py +225 -0
- package/skills/egbe-os-product-market-research/scripts/channel-footprint-model.py +294 -0
- package/skills/egbe-os-product-market-research/scripts/connection_identity.py +22 -0
- package/skills/egbe-os-product-market-research/scripts/creative-model.py +364 -0
- package/skills/egbe-os-product-market-research/scripts/creative-selection.py +113 -0
- package/skills/egbe-os-product-market-research/scripts/creative-semantics.py +365 -0
- package/skills/egbe-os-product-market-research/scripts/creative-video.py +542 -0
- package/skills/egbe-os-product-market-research/scripts/egbe_artifacts.py +24 -0
- package/skills/egbe-os-product-market-research/scripts/finalize-organic-trend-watch.py +304 -0
- package/skills/egbe-os-product-market-research/scripts/funnel-email-review.py +97 -0
- package/skills/egbe-os-product-market-research/scripts/funnel-model.py +966 -0
- package/skills/egbe-os-product-market-research/scripts/funnel_features.py +50 -0
- package/skills/egbe-os-product-market-research/scripts/geography-comparison-contract.py +172 -0
- package/skills/egbe-os-product-market-research/scripts/geography-comparison.py +169 -0
- package/skills/egbe-os-product-market-research/scripts/keyword-forecast.py +61 -0
- package/skills/egbe-os-product-market-research/scripts/keyword-locale-publication.py +136 -0
- package/skills/egbe-os-product-market-research/scripts/lifecycle-start.py +190 -0
- package/skills/egbe-os-product-market-research/scripts/persist-research-report.py +63 -0
- package/skills/egbe-os-product-market-research/scripts/research-artifact-io.py +281 -0
- package/skills/egbe-os-product-market-research/scripts/research-evidence.py +496 -0
- package/skills/egbe-os-product-market-research/scripts/research-policy.py +33 -0
- package/skills/egbe-os-product-market-research/scripts/research-section-runtime.py +343 -0
- package/skills/egbe-os-product-market-research/scripts/research-section-workflow.py +288 -0
- package/skills/egbe-os-product-market-research/scripts/research_integrity.py +122 -0
- package/skills/egbe-os-product-market-research/scripts/review-research-completion.py +306 -0
- package/skills/egbe-os-product-market-research/scripts/run-acquisition-channels.py +72 -0
- package/skills/egbe-os-product-market-research/scripts/run-channel-footprint.py +2258 -0
- package/skills/egbe-os-product-market-research/scripts/run-community-demand.py +1603 -0
- package/skills/egbe-os-product-market-research/scripts/run-competitive-landscape.py +66 -0
- package/skills/egbe-os-product-market-research/scripts/run-competitor-ads.py +1156 -0
- package/skills/egbe-os-product-market-research/scripts/run-competitor-set.py +2514 -0
- package/skills/egbe-os-product-market-research/scripts/run-creative-patterns.py +2042 -0
- package/skills/egbe-os-product-market-research/scripts/run-demand-validation.py +72 -0
- package/skills/egbe-os-product-market-research/scripts/run-fleet-prior.py +652 -0
- package/skills/egbe-os-product-market-research/scripts/run-funnel-teardown.py +493 -0
- package/skills/egbe-os-product-market-research/scripts/run-keyword-economics.py +1443 -0
- package/skills/egbe-os-product-market-research/scripts/run-lifecycle-capture.py +1543 -0
- package/skills/egbe-os-product-market-research/scripts/run-market-size-and-dynamics.py +66 -0
- package/skills/egbe-os-product-market-research/scripts/run-os-research.py +311 -0
- package/skills/egbe-os-product-market-research/scripts/run-pricing-and-monetization.py +71 -0
- package/skills/egbe-os-product-market-research/scripts/run-review-mining.py +1051 -0
- package/skills/egbe-os-product-market-research/scripts/run-target-audience.py +66 -0
- package/skills/egbe-os-product-market-research/scripts/run-unit-economics.py +71 -0
- package/skills/egbe-os-product-market-research/scripts/run-value-proposition.py +67 -0
- package/skills/egbe-os-product-market-research/scripts/upsert-markdown-section.py +156 -0
- package/skills/egbe-os-product-market-research/scripts/walk-funnels.py +249 -0
- package/skills/egbe-os-product-market-research/scripts/write-preview.py +710 -0
- package/skills/egbe-os-product-market-research/scripts/write-recommendations.py +272 -0
- package/skills/egbe-os-product-report/SKILL.md +150 -0
- package/skills/egbe-os-product-report/references/artifacts.md +84 -0
- package/skills/egbe-os-product-report/references/brief.md +34 -0
- package/skills/egbe-os-product-report/references/daily.md +76 -0
- package/skills/egbe-os-product-report/references/sources.md +68 -0
- package/skills/egbe-os-product-routines/SKILL.md +166 -0
- package/skills/egbe-os-product-routines/references/catalog.md +22 -0
- package/skills/egbe-os-product-routines/references/continuation-check.md +41 -0
- package/skills/egbe-os-product-routines/references/product-reporting.md +163 -0
- package/skills/egbe-os-product-routines/references/run-preset.md +32 -0
- package/skills/egbe-os-quickstart/scripts/egbe-curl.py +357 -0
- package/skills/egbe-os-quiz-funnel/SKILL.md +152 -0
- package/skills/egbe-os-quiz-funnel/agents/openai.yaml +4 -0
- package/skills/egbe-os-quiz-funnel/assets/engine/quiz-engine.d.mts +224 -0
- package/skills/egbe-os-quiz-funnel/assets/engine/quiz-engine.mjs +652 -0
- package/skills/egbe-os-quiz-funnel/assets/engine/quiz-engine.test.mjs +764 -0
- package/skills/egbe-os-quiz-funnel/assets/engine/quiz-history.d.mts +31 -0
- package/skills/egbe-os-quiz-funnel/assets/engine/quiz-history.mjs +87 -0
- package/skills/egbe-os-quiz-funnel/assets/engine/quiz-history.test.mjs +265 -0
- package/skills/egbe-os-quiz-funnel/assets/engine/quiz-reference.test.mjs +254 -0
- package/skills/egbe-os-quiz-funnel/assets/examples/egbe-docs/product/quizzes/books-checkup/QUIZ.md +195 -0
- package/skills/egbe-os-quiz-funnel/assets/examples/egbe-docs/product/quizzes/books-checkup/quiz.json +421 -0
- package/skills/egbe-os-quiz-funnel/assets/examples/egbe-docs/product/quizzes/books-checkup/quiz.public.json +369 -0
- package/skills/egbe-os-quiz-funnel/assets/examples/egbe-docs/product/quizzes/books-checkup/validation.json +21 -0
- package/skills/egbe-os-quiz-funnel/assets/reference/index.html +26 -0
- package/skills/egbe-os-quiz-funnel/assets/reference/quiz-bootstrap.js +31 -0
- package/skills/egbe-os-quiz-funnel/assets/reference/quiz-early-actions.mjs +11 -0
- package/skills/egbe-os-quiz-funnel/assets/reference/quiz-first-screen.mjs +32 -0
- package/skills/egbe-os-quiz-funnel/assets/reference/quiz-page.mjs +480 -0
- package/skills/egbe-os-quiz-funnel/assets/reference/quiz.css +264 -0
- package/skills/egbe-os-quiz-funnel/references/competitor-teardown.md +159 -0
- package/skills/egbe-os-quiz-funnel/references/conversion-handoff.md +156 -0
- package/skills/egbe-os-quiz-funnel/references/implementation.md +207 -0
- package/skills/egbe-os-quiz-funnel/references/inputs.md +37 -0
- package/skills/egbe-os-quiz-funnel/references/measurement.md +122 -0
- package/skills/egbe-os-quiz-funnel/references/spec-contract.md +335 -0
- package/skills/egbe-os-quiz-funnel/references/verification.md +101 -0
- package/skills/egbe-os-quiz-funnel/references/walk-mechanics.v2.json +18 -0
- package/skills/egbe-os-quiz-funnel/scripts/compile-quiz-spec.py +1869 -0
- package/skills/egbe-os-quiz-funnel/scripts/prepare-research-identity.py +66 -0
- package/skills/egbe-os-reddit-ads/SKILL.md +121 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/bold-statement/schema.json +41 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/bold-statement/template.html +106 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/data-proof/schema.json +61 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/data-proof/template.html +151 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/honest-breakdown/schema.json +91 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/honest-breakdown/template.html +185 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/question-hook/schema.json +51 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/question-hook/template.html +121 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/reddit-post-style/schema.json +87 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/reddit-post-style/template.html +212 -0
- package/skills/egbe-os-reddit-ads/references/creative/html-to-png-pipeline.md +123 -0
- package/skills/egbe-os-reddit-ads/references/creative/static-banner-qa.md +12 -0
- package/skills/egbe-os-reddit-ads/references/creative/static-banner-system.md +16 -0
- package/skills/egbe-os-reddit-ads/references/destination-requirements.md +36 -0
- package/skills/egbe-os-reddit-ads/references/runtime/api-reference.md +435 -0
- package/skills/egbe-os-reddit-ads/references/runtime/artifacts.md +57 -0
- package/skills/egbe-os-reddit-ads/references/runtime/monitoring.md +64 -0
- package/skills/egbe-os-reddit-ads/references/runtime/pixel-and-tracking.md +49 -0
- package/skills/egbe-os-reddit-ads/references/runtime/policies.md +19 -0
- package/skills/egbe-os-reddit-ads/references/runtime/shared-analytics-attribution.md +14 -0
- package/skills/egbe-os-reddit-ads/references/workflows/build-paused.md +35 -0
- package/skills/egbe-os-reddit-ads/references/workflows/launch-ready.md +19 -0
- package/skills/egbe-os-reddit-ads/references/workflows/launch.md +32 -0
- package/skills/egbe-os-reddit-ads/references/workflows/readiness.md +9 -0
- package/skills/egbe-os-reddit-ads/scripts/capture-ad.sh +178 -0
- package/skills/egbe-os-reddit-ads/scripts/validate-reddit-artifacts.py +187 -0
- package/skills/egbe-os-report-ui/SKILL.md +133 -0
- package/skills/egbe-os-report-ui/assets/egbe-wordmark.svg +9 -0
- package/skills/egbe-os-report-ui/assets/examples/components.html +417 -0
- package/skills/egbe-os-report-ui/assets/examples/editorial.html +209 -0
- package/skills/egbe-os-report-ui/assets/scaffold.html +179 -0
- package/skills/egbe-os-report-ui/references/components.md +209 -0
- package/skills/egbe-os-research/SKILL.md +125 -0
- package/skills/egbe-os-saas-unit-economics/SKILL.md +188 -0
- package/skills/egbe-os-scrape/SKILL.md +160 -0
- package/skills/egbe-os-search/SKILL.md +182 -0
- package/skills/egbe-os-search/references/google-places.md +81 -0
- package/skills/egbe-os-support/SKILL.md +149 -0
- package/skills/egbe-os-telemetry/SKILL.md +344 -0
- package/skills/egbe-os-telemetry/references/harnesses/claude-code.md +97 -0
- package/skills/egbe-os-telemetry/references/harnesses/codex.md +22 -0
- package/skills/egbe-os-telemetry/references/harnesses/hermes.md +39 -0
- package/skills/egbe-os-telemetry/references/harnesses/openclaw.md +139 -0
- package/skills/egbe-os-telemetry/references/harnesses/opencode.md +28 -0
- package/skills/egbe-os-tools/SKILL.md +180 -0
- package/skills/egbe-os-tools/references/theona.md +26 -0
- package/skills/egbe-os-wallet/SKILL.md +181 -0
- package/skills/egbe-setup/EGBE.md +484 -0
- package/skills/egbe-setup/SKILL.md +116 -0
- package/skills/egbe-setup/references/project.md +80 -0
- package/state.js +37 -0
- package/update.js +361 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: egbe-os-product-auth
|
|
3
|
+
description: Build or repair accounts, sessions, protected routes and navigation, preserving existing work across account entry.
|
|
4
|
+
metadata:
|
|
5
|
+
egbe-when: "Use when features need accounts; offer when authentication gaps interrupt the customer journey."
|
|
6
|
+
egbe-visible: "true"
|
|
7
|
+
egbe-title: "Customer accounts"
|
|
8
|
+
egbe-description: "Add signup, login, secure sessions and protected pages, while keeping a customer's progress through sign-in."
|
|
9
|
+
egbe-category: "Payments & accounts"
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
<!-- egbe-mcp-connection:v1 -->
|
|
13
|
+
This skill comes with the Egbe plugin. If this project has its own installed copy
|
|
14
|
+
of the skill, use that copy instead. Otherwise make every Egbe API call it
|
|
15
|
+
describes with the Egbe connector: `egbe_read` for GET and `egbe_write` for POST,
|
|
16
|
+
PUT, PATCH and DELETE (with `method`). Pass the API path (for example
|
|
17
|
+
`/me/limits`), query parameters in `query` and the JSON body in `body`. Leave out `OS_URL`, the Authorization header, `.env.local`,
|
|
18
|
+
`egbe-curl.py` and catalog update checks; the connection authenticates and
|
|
19
|
+
identifies the request. Also pass the `business` that `egbe_setup` returned.
|
|
20
|
+
Where this skill sends an `Idempotency-Key` header, pass the same value as
|
|
21
|
+
`idempotency_key` and reuse it when retrying. A result with a `continuation`
|
|
22
|
+
holds one part of a long body; read the next part with `egbe_read`, the same
|
|
23
|
+
`path` and `business`, and that `continuation`.
|
|
24
|
+
Read bundled files beside this `SKILL.md`. For published skill resources on
|
|
25
|
+
Egbe OS, use `egbe_skill`. Follow "Files downloaded on demand" for listed downloads.
|
|
26
|
+
|
|
27
|
+
Publishing works through the connector: commit the app's files with the JSON
|
|
28
|
+
commit requests in `egbe-os-git` ("Without a terminal") and deploy the returned
|
|
29
|
+
commit SHA; no git push or workspace setup is needed. A step that needs a local
|
|
30
|
+
project key or a bundled script, such as a local `npx convex deploy`, needs a
|
|
31
|
+
set-up project workspace. In a persistent
|
|
32
|
+
project workspace that is not set up yet, set it up as the `egbe-setup` skill's
|
|
33
|
+
project setup describes.
|
|
34
|
+
Without such a workspace, or if it refuses, tell the founder that this step needs
|
|
35
|
+
an agent with a set-up project folder, and continue with the rest of the work.
|
|
36
|
+
|
|
37
|
+
If the connector's tools (`egbe_read` and the other `egbe_*` tools) are not
|
|
38
|
+
available, the plugin's connector is not signed in for this agent. Tell
|
|
39
|
+
the founder how to connect it, as the `egbe-setup` skill describes, rather than
|
|
40
|
+
saying Egbe is unavailable.
|
|
41
|
+
|
|
42
|
+
The connector's tools work even where this environment's shell cannot reach
|
|
43
|
+
Egbe: their calls travel through this agent's connection, not through the
|
|
44
|
+
shell's network. A step that runs in the shell, such as a bundled script, a `git
|
|
45
|
+
push` to Egbe's Git endpoint or a deploy upload, needs the shell to reach the
|
|
46
|
+
Egbe host (`os.hz.egbe.dev`). If a proxy or allowlist refuses that request
|
|
47
|
+
before Egbe answers, for example HTTP 403 on CONNECT or curl status `000`, tell
|
|
48
|
+
the founder: they allow that host in this agent's network settings or continue
|
|
49
|
+
with an agent on their own computer. Code can also be published without the
|
|
50
|
+
shell by committing through the connector (`egbe-os-git`, "Without a terminal").
|
|
51
|
+
Until the shell step or that commit and its deploy succeed, do not report the
|
|
52
|
+
work as published: a preview in this agent or on this computer is not an Egbe
|
|
53
|
+
deployment.
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
# Product Auth
|
|
57
|
+
|
|
58
|
+
Build authentication as part of the existing product experience, not as an
|
|
59
|
+
isolated pair of forms.
|
|
60
|
+
|
|
61
|
+
Before planning changes, inspect the repository `AGENTS.md`. When it contains
|
|
62
|
+
`EGBE:PRODUCT-FOUNDATION`, the canonical Postgres pool, migrations, durable
|
|
63
|
+
users/sessions storage, server-only session primitives, protected-route helper,
|
|
64
|
+
and private validation-session helper are scaffold-owned and already present.
|
|
65
|
+
Reuse them. Build only the selected account-entry integrations, account UX,
|
|
66
|
+
navigation, continuation, and concrete product bindings;
|
|
67
|
+
do not copy, replace, or create a parallel DB/session core.
|
|
68
|
+
|
|
69
|
+
For a new custom Node/Postgres integration,
|
|
70
|
+
[Product Build's foundations](../egbe-os-product-build/references/foundations.md)
|
|
71
|
+
describe the optional `--auth-db` installer for the
|
|
72
|
+
same shipped schema, migrations and private validation-session helper without
|
|
73
|
+
Next.js modules. Its `EGBE:AUTH-DATABASE` marker identifies only those database
|
|
74
|
+
assets; the application still owns its request-time session and account-entry
|
|
75
|
+
implementation. Preserve a working library's own schema/migration system.
|
|
76
|
+
|
|
77
|
+
## Through the Egbe connector
|
|
78
|
+
|
|
79
|
+
Through the connector you can change and publish the app with `egbe-os-git`
|
|
80
|
+
("Without a terminal") and `egbe-os-deploy`. Rendered-page and interactive
|
|
81
|
+
checks need a browser: use this environment's own browser tools, or a set-up
|
|
82
|
+
project workspace. In a persistent project workspace not set up yet, call
|
|
83
|
+
`egbe_local_setup`. Without either, read pages with `egbe-os-scrape` and HTTP
|
|
84
|
+
responses, report signup, login and logout as unverified, and tell the founder
|
|
85
|
+
which check remains.
|
|
86
|
+
|
|
87
|
+
## Core Workflow
|
|
88
|
+
|
|
89
|
+
For every egbe-os-product-auth implementation, read all of these references before changing code:
|
|
90
|
+
|
|
91
|
+
1. [references/workflows/build-auth.md](references/workflows/build-auth.md)
|
|
92
|
+
2. [references/contracts/live-auth-interface.md](references/contracts/live-auth-interface.md)
|
|
93
|
+
3. [references/security/session-and-credentials.md](references/security/session-and-credentials.md)
|
|
94
|
+
4. [references/ux/auth-experience.md](references/ux/auth-experience.md)
|
|
95
|
+
|
|
96
|
+
For a Next.js product, also read
|
|
97
|
+
[references/frameworks/nextjs.md](references/frameworks/nextjs.md). For another
|
|
98
|
+
stack, apply the same live and security contracts using its established server
|
|
99
|
+
and routing patterns.
|
|
100
|
+
|
|
101
|
+
Implement the methods selected in the existing requirements or task. Preserve a
|
|
102
|
+
suitable working method; a bounded repair does not add providers or redesign
|
|
103
|
+
account entry. If a material access decision is missing, explain the gap and
|
|
104
|
+
propose a suitable option with its reason before dependent implementation. This
|
|
105
|
+
technical workflow does not require a new plan or a playbook review.
|
|
106
|
+
|
|
107
|
+
- When Google is selected, follow
|
|
108
|
+
[references/workflows/google.md](references/workflows/google.md).
|
|
109
|
+
- When email sign-in links are selected, follow
|
|
110
|
+
[references/workflows/passwordless-email.md](references/workflows/passwordless-email.md).
|
|
111
|
+
- For email/password, use the shared credential and session contract below.
|
|
112
|
+
|
|
113
|
+
Read [references/workflows/account-recovery.md](references/workflows/account-recovery.md)
|
|
114
|
+
only when password recovery or separate email verification is required.
|
|
115
|
+
|
|
116
|
+
## Sources Of Truth
|
|
117
|
+
|
|
118
|
+
- Use the Egbe OS `egbe-os-deploy` skill for attached Postgres and deployment.
|
|
119
|
+
- Use the live Egbe OS `auth` capability skill for Google identity. Products
|
|
120
|
+
keep no Google client secret and browser code never receives `OS_API_KEY`.
|
|
121
|
+
- Use the Egbe OS `egbe-os-mail` skill for email delivery when the selected auth flow
|
|
122
|
+
actually requires email.
|
|
123
|
+
- Use the Egbe OS `egbe-os-analytics` skill for canonical event names and delivery.
|
|
124
|
+
Do not define or emit signup event catalogs in this skill.
|
|
125
|
+
- Reuse a maintained auth library already present when it supports the local
|
|
126
|
+
account/session contract. Never replace an explicitly selected or suitable
|
|
127
|
+
working method merely because another is easier to implement or verify.
|
|
128
|
+
|
|
129
|
+
## Completion
|
|
130
|
+
|
|
131
|
+
For a full implementation, verify every selected method on the live product:
|
|
132
|
+
fresh account entry, repeat login to the same local account, applicable identity
|
|
133
|
+
linking, authenticated continuation, refresh, signed-in navigation, logout and
|
|
134
|
+
protected-route denial. A bounded repair verifies the affected method and shared
|
|
135
|
+
dependencies it can change; it does not expand the account-entry set. Email-link
|
|
136
|
+
proof requires receipt and use of the actual live message. One working method
|
|
137
|
+
does not complete a full implementation with another agreed method still broken;
|
|
138
|
+
do not silently remove that method from scope. Source inspection, provider
|
|
139
|
+
acceptance and redirect-only forms are not account-entry proof.
|
|
140
|
+
|
|
141
|
+
If a required identity, consent or live check needs the founder, keep Auth
|
|
142
|
+
incomplete and use EGBE's “Resume unfinished work” guidance. Record the exact
|
|
143
|
+
pending check and how
|
|
144
|
+
to resume in existing working notes; give the founder the safe product location
|
|
145
|
+
and one clear next action. A deferral does not complete the pending proof, and a
|
|
146
|
+
later "done" still requires live verification.
|
|
147
|
+
|
|
148
|
+
After that real account-entry proof, prepare the workflow's private reusable
|
|
149
|
+
validation identity when dependent Product or Billing work needs it, through the
|
|
150
|
+
product's authoritative server-side session mechanism. This is authenticated
|
|
151
|
+
setup, not proof of Auth behavior and never a public test-login path.
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Baseline auth schema (canonical fixture)
|
|
2
|
+
|
|
3
|
+
Shipped inside the `egbe-os-product-auth` skill bundle. The `build-auth` workflow (§3
|
|
4
|
+
"Prepare Durable State") applies this as the **starting point** for durable auth
|
|
5
|
+
state, so the canonical users, sessions, and provider bindings are never
|
|
6
|
+
re-derived by hand on every product. The agent adds only product-specific
|
|
7
|
+
columns/tables on top.
|
|
8
|
+
|
|
9
|
+
Use this for the **custom Node/Postgres path** — selected provider, email/password
|
|
10
|
+
or passwordless methods implemented against attached Postgres with `pg` and raw
|
|
11
|
+
SQL. If the product adopts an ORM or auth library with its own migration ledger (Prisma,
|
|
12
|
+
Drizzle, a batteries-included auth lib), do **not** apply this raw SQL — it would
|
|
13
|
+
drift against the ORM's migration table. Instead create the same users,
|
|
14
|
+
sessions, and unique provider-subject binding via that library's migration
|
|
15
|
+
mechanism. See build-auth.md §3 for the branch.
|
|
16
|
+
|
|
17
|
+
## Files
|
|
18
|
+
- `migrations/0001_auth.sql` — the universal user/session tables. Idempotent.
|
|
19
|
+
- `migrations/0002_auth_identities.sql` — provider-subject links used by Google
|
|
20
|
+
and future verified identity providers. Idempotent.
|
|
21
|
+
- `migrate.mjs` — concurrency-safe runner (advisory-locked). Applies each SQL
|
|
22
|
+
file once, tracked in a `schema_migrations` table. Only dep is `pg`.
|
|
23
|
+
- `create-validation-session.mjs` — creates or reuses one private, short-lived
|
|
24
|
+
validation identity after the real account-entry journey has been proven.
|
|
25
|
+
It can load the resulting cookie into an isolated `agent-browser` session so
|
|
26
|
+
later Product and Billing work can start from authenticated state without
|
|
27
|
+
replaying account entry.
|
|
28
|
+
|
|
29
|
+
## Tables
|
|
30
|
+
|
|
31
|
+
`users(id uuid pk, email text, password_hash text null, created_at, updated_at)`
|
|
32
|
+
- Uniqueness is enforced on `lower(email)` (case-insensitive). Insert the email
|
|
33
|
+
as typed; the index normalizes. Return one generic invalid-credentials
|
|
34
|
+
response for both unknown email and wrong password.
|
|
35
|
+
- `password_hash` is nullable so OAuth/passwordless identities can be added
|
|
36
|
+
later. For email/password, set it with Argon2id / scrypt / bcrypt (see the
|
|
37
|
+
`session-and-credentials` contract). For passwordless email, leave it null;
|
|
38
|
+
never fill it with a random placeholder merely to imitate password auth.
|
|
39
|
+
|
|
40
|
+
`sessions(id uuid pk, user_id uuid fk, token_hash text, expires_at, created_at, revoked_at null)`
|
|
41
|
+
- Store a **hash** of the opaque, cryptographically-random session token in
|
|
42
|
+
`token_hash`, never the token itself.
|
|
43
|
+
- In a new custom Node/Postgres profile, the default token lookup is SHA-256
|
|
44
|
+
hexadecimal in `sessions.token_hash` and the default cookie name is
|
|
45
|
+
`egbe_session`. The product's normal request-time session resolver and the
|
|
46
|
+
validation helper must use the same token and cookie contract.
|
|
47
|
+
- When an existing working resolver already uses the same authoritative
|
|
48
|
+
`users`/`sessions` state and SHA-256 token lookup under another valid cookie
|
|
49
|
+
name, preserve that cookie name. Pass it to the helper with `--cookie-name`;
|
|
50
|
+
do not rename a working product session solely to fit the fixture default.
|
|
51
|
+
- Revoke by setting `revoked_at`. Check expiry AND `revoked_at is null` on every
|
|
52
|
+
protected request. On logout, revoke the server record before clearing the
|
|
53
|
+
cookie.
|
|
54
|
+
|
|
55
|
+
`auth_identities(id uuid pk, user_id uuid fk, provider, subject, email_at_link, created_at, updated_at)`
|
|
56
|
+
- `(provider, subject)` is unique and authoritative. Email is verified linking
|
|
57
|
+
context and may change at the provider.
|
|
58
|
+
- A verified provider email may link an existing local user. Never erase that
|
|
59
|
+
user's password or passwordless state when adding a provider identity.
|
|
60
|
+
|
|
61
|
+
## Running
|
|
62
|
+
Run during a controlled build/deploy step (never a public route). Requires
|
|
63
|
+
`DATABASE_URL`; safe to run repeatedly and concurrently:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
node db/migrate.mjs # or wire it as: npm run db:migrate
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
After the Auth section has proved real account entry, create or reuse the
|
|
70
|
+
private validation identity for dependent Product or Billing work. Set
|
|
71
|
+
`PRIVATE_STATE_DIR` to a private directory outside the product repository and
|
|
72
|
+
shared reports (for a new validation run, `mktemp -d` creates one):
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
node db/create-validation-session.mjs \
|
|
76
|
+
--origin "$APP_URL" \
|
|
77
|
+
--state "${PRIVATE_STATE_DIR}/${APP_SLUG}.json" \
|
|
78
|
+
--browser-session "validation-${APP_SLUG}"
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
For an existing compatible resolver whose real cookie is, for example,
|
|
82
|
+
`wp_session`, add `--cookie-name "wp_session"`. Omit the flag for a new product
|
|
83
|
+
using the `egbe_session` default. Always take the value from the real
|
|
84
|
+
request-time resolver; never guess a cookie name from this documentation.
|
|
85
|
+
|
|
86
|
+
The helper requires `DATABASE_URL`. Its state file contains the only raw token,
|
|
87
|
+
is written with mode `0600`, and must stay outside the product repository and
|
|
88
|
+
shared reports. The database receives only the token hash. The helper prints
|
|
89
|
+
only non-secret status and may be run again to reuse an unexpired, unrevoked
|
|
90
|
+
session.
|
|
91
|
+
|
|
92
|
+
This identity is setup for verifying authenticated Product and Billing
|
|
93
|
+
behavior. It is not evidence that signup, login, email delivery, credential
|
|
94
|
+
exchange, logout, or recovery works. Those remain Auth-owned live proofs. Do
|
|
95
|
+
not expose a public validation login route or add a runtime bypass.
|
|
96
|
+
|
|
97
|
+
## Extending
|
|
98
|
+
Add later migrations as `migrations/000N_<name>.sql` — the runner applies new
|
|
99
|
+
files in order, once each. Product-specific columns/tables (e.g. an ownership
|
|
100
|
+
link that preserves a pre-signup result, or profile fields) go in such a later
|
|
101
|
+
migration. Do **not** edit `0001_auth.sql` or `0002_auth_identities.sql` after
|
|
102
|
+
they have shipped.
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/** Create or reuse one private validation identity in canonical Product Auth. */
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
5
|
+
import { chmod, mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
6
|
+
import { dirname, resolve } from "node:path";
|
|
7
|
+
import { pathToFileURL } from "node:url";
|
|
8
|
+
|
|
9
|
+
export const DEFAULT_COOKIE_NAME = "egbe_session";
|
|
10
|
+
const DEFAULT_TTL_HOURS = 24;
|
|
11
|
+
const MIN_REUSE_MS = 5 * 60 * 1000;
|
|
12
|
+
|
|
13
|
+
export function hashSessionToken(token) {
|
|
14
|
+
return createHash("sha256").update(String(token), "utf8").digest("hex");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function normalizedOrigin(value) {
|
|
18
|
+
const parsed = new URL(String(value || ""));
|
|
19
|
+
if (!new Set(["http:", "https:"]).has(parsed.protocol)) {
|
|
20
|
+
throw new Error("--origin must be an HTTP(S) product origin");
|
|
21
|
+
}
|
|
22
|
+
return parsed.origin;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function positiveHours(value) {
|
|
26
|
+
const hours = Number(value || DEFAULT_TTL_HOURS);
|
|
27
|
+
if (!Number.isFinite(hours) || hours <= 0 || hours > 168) {
|
|
28
|
+
throw new Error("--ttl-hours must be between 0 and 168");
|
|
29
|
+
}
|
|
30
|
+
return hours;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function parseArgs(argv) {
|
|
34
|
+
const values = {};
|
|
35
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
36
|
+
const key = argv[index];
|
|
37
|
+
if (!key.startsWith("--") || index + 1 >= argv.length) {
|
|
38
|
+
throw new Error(`invalid argument: ${key}`);
|
|
39
|
+
}
|
|
40
|
+
values[key.slice(2)] = argv[index + 1];
|
|
41
|
+
index += 1;
|
|
42
|
+
}
|
|
43
|
+
if (!values.origin) throw new Error("--origin is required");
|
|
44
|
+
if (!values.state) throw new Error("--state is required");
|
|
45
|
+
const cookieName = String(values["cookie-name"] || DEFAULT_COOKIE_NAME).trim();
|
|
46
|
+
if (!/^[A-Za-z0-9_-]{1,64}$/.test(cookieName)) {
|
|
47
|
+
throw new Error("--cookie-name is invalid");
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
origin: normalizedOrigin(values.origin),
|
|
51
|
+
statePath: resolve(values.state),
|
|
52
|
+
browserSession: String(values["browser-session"] || "").trim(),
|
|
53
|
+
cookieName,
|
|
54
|
+
ttlHours: positiveHours(values["ttl-hours"]),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async function readPrivateState(path) {
|
|
59
|
+
try {
|
|
60
|
+
const value = JSON.parse(await readFile(path, "utf8"));
|
|
61
|
+
return value && typeof value === "object" ? value : null;
|
|
62
|
+
} catch {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export async function writePrivateState(path, value) {
|
|
68
|
+
const parent = dirname(path);
|
|
69
|
+
await mkdir(parent, { recursive: true, mode: 0o700 });
|
|
70
|
+
await chmod(parent, 0o700);
|
|
71
|
+
const temporary = `${path}.${process.pid}.${randomBytes(4).toString("hex")}.tmp`;
|
|
72
|
+
await writeFile(temporary, `${JSON.stringify(value, null, 2)}\n`, { mode: 0o600 });
|
|
73
|
+
await chmod(temporary, 0o600);
|
|
74
|
+
await rename(temporary, path);
|
|
75
|
+
await chmod(path, 0o600);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function newValidationEmail() {
|
|
79
|
+
return `egbe-validation+${randomBytes(10).toString("hex")}@example.invalid`;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function stateMatches(value, { origin, cookieName, now }) {
|
|
83
|
+
return Boolean(
|
|
84
|
+
value
|
|
85
|
+
&& value.version === 1
|
|
86
|
+
&& value.origin === origin
|
|
87
|
+
&& value.cookie_name === cookieName
|
|
88
|
+
&& typeof value.email === "string"
|
|
89
|
+
&& typeof value.session_token === "string"
|
|
90
|
+
&& value.session_token.length >= 32
|
|
91
|
+
&& Date.parse(value.expires_at || "") > now.getTime() + MIN_REUSE_MS,
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export async function ensureValidationSession(
|
|
96
|
+
client,
|
|
97
|
+
{ origin, cookieName = DEFAULT_COOKIE_NAME, ttlHours = DEFAULT_TTL_HOURS, state = null, now = new Date() },
|
|
98
|
+
) {
|
|
99
|
+
if (stateMatches(state, { origin, cookieName, now })) {
|
|
100
|
+
const existing = await client.query(
|
|
101
|
+
`select 1
|
|
102
|
+
from users u
|
|
103
|
+
join sessions s on s.user_id = u.id
|
|
104
|
+
where lower(u.email) = lower($1)
|
|
105
|
+
and s.token_hash = $2
|
|
106
|
+
and s.revoked_at is null
|
|
107
|
+
and s.expires_at > $3`,
|
|
108
|
+
[state.email, hashSessionToken(state.session_token), now.toISOString()],
|
|
109
|
+
);
|
|
110
|
+
if (existing.rowCount > 0) return { state, reused: true };
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const email = state?.origin === origin && state?.email
|
|
114
|
+
? String(state.email)
|
|
115
|
+
: newValidationEmail();
|
|
116
|
+
const sessionToken = randomBytes(32).toString("base64url");
|
|
117
|
+
const tokenHash = hashSessionToken(sessionToken);
|
|
118
|
+
const expiresAt = new Date(now.getTime() + ttlHours * 60 * 60 * 1000);
|
|
119
|
+
|
|
120
|
+
await client.query("begin");
|
|
121
|
+
try {
|
|
122
|
+
const user = await client.query(
|
|
123
|
+
`insert into users (email, password_hash)
|
|
124
|
+
values ($1, null)
|
|
125
|
+
on conflict ((lower(email))) do update set updated_at = now()
|
|
126
|
+
returning id`,
|
|
127
|
+
[email],
|
|
128
|
+
);
|
|
129
|
+
const userId = user.rows[0]?.id;
|
|
130
|
+
if (!userId) throw new Error("validation user could not be resolved");
|
|
131
|
+
await client.query(
|
|
132
|
+
`update sessions
|
|
133
|
+
set revoked_at = coalesce(revoked_at, now())
|
|
134
|
+
where user_id = $1 and revoked_at is null`,
|
|
135
|
+
[userId],
|
|
136
|
+
);
|
|
137
|
+
await client.query(
|
|
138
|
+
`insert into sessions (user_id, token_hash, expires_at)
|
|
139
|
+
values ($1, $2, $3)`,
|
|
140
|
+
[userId, tokenHash, expiresAt.toISOString()],
|
|
141
|
+
);
|
|
142
|
+
await client.query("commit");
|
|
143
|
+
} catch (error) {
|
|
144
|
+
await client.query("rollback").catch(() => {});
|
|
145
|
+
throw error;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return {
|
|
149
|
+
reused: false,
|
|
150
|
+
state: {
|
|
151
|
+
version: 1,
|
|
152
|
+
origin,
|
|
153
|
+
email,
|
|
154
|
+
cookie_name: cookieName,
|
|
155
|
+
session_token: sessionToken,
|
|
156
|
+
expires_at: expiresAt.toISOString(),
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export function loadBrowserSession(state, browserSession, runner = spawnSync) {
|
|
162
|
+
if (!browserSession) return;
|
|
163
|
+
const binary = process.env.EGBE_AGENT_BROWSER_BIN || "agent-browser";
|
|
164
|
+
const common = ["--session", browserSession];
|
|
165
|
+
for (const args of [
|
|
166
|
+
[...common, "open", state.origin],
|
|
167
|
+
[...common, "cookies", "set", state.cookie_name, state.session_token],
|
|
168
|
+
]) {
|
|
169
|
+
const result = runner(binary, args, {
|
|
170
|
+
encoding: "utf8",
|
|
171
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
172
|
+
});
|
|
173
|
+
if (result.error || result.status !== 0) {
|
|
174
|
+
throw new Error("agent-browser could not load the validation session");
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export function publicResult({ reused, statePath, browserSession }) {
|
|
180
|
+
return {
|
|
181
|
+
ok: true,
|
|
182
|
+
reused,
|
|
183
|
+
state_path: statePath,
|
|
184
|
+
browser_session: browserSession || null,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
async function main() {
|
|
189
|
+
const options = parseArgs(process.argv.slice(2));
|
|
190
|
+
const databaseUrl = String(process.env.DATABASE_URL || "");
|
|
191
|
+
if (!databaseUrl) throw new Error("DATABASE_URL is not set");
|
|
192
|
+
const imported = await import("pg");
|
|
193
|
+
const Client = imported.default?.Client || imported.Client;
|
|
194
|
+
if (!Client) throw new Error("pg Client is unavailable");
|
|
195
|
+
|
|
196
|
+
const client = new Client({ connectionString: databaseUrl });
|
|
197
|
+
await client.connect();
|
|
198
|
+
try {
|
|
199
|
+
const previous = await readPrivateState(options.statePath);
|
|
200
|
+
const result = await ensureValidationSession(client, {
|
|
201
|
+
origin: options.origin,
|
|
202
|
+
cookieName: options.cookieName,
|
|
203
|
+
ttlHours: options.ttlHours,
|
|
204
|
+
state: previous,
|
|
205
|
+
});
|
|
206
|
+
await writePrivateState(options.statePath, result.state);
|
|
207
|
+
loadBrowserSession(result.state, options.browserSession);
|
|
208
|
+
process.stdout.write(`${JSON.stringify(publicResult({
|
|
209
|
+
reused: result.reused,
|
|
210
|
+
statePath: options.statePath,
|
|
211
|
+
browserSession: options.browserSession,
|
|
212
|
+
}))}\n`);
|
|
213
|
+
} finally {
|
|
214
|
+
await client.end();
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (import.meta.url === pathToFileURL(process.argv[1] || "").href) {
|
|
219
|
+
main().catch((error) => {
|
|
220
|
+
process.stderr.write(`create-validation-session failed: ${String(error?.message || error)}\n`);
|
|
221
|
+
process.exitCode = 1;
|
|
222
|
+
});
|
|
223
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Idempotent, concurrency-safe migration runner for the attached Postgres.
|
|
3
|
+
//
|
|
4
|
+
// Applies db/migrations/*.sql in filename order, once each, inside a transaction,
|
|
5
|
+
// guarded by a Postgres advisory lock so parallel boots/deploys can't race. Run
|
|
6
|
+
// it during a controlled build/deploy step (e.g. `npm run db:migrate`), NEVER
|
|
7
|
+
// from a public route. Requires DATABASE_URL. Safe to run repeatedly.
|
|
8
|
+
//
|
|
9
|
+
// Only dependency is `pg` (already needed to talk to the attached Postgres).
|
|
10
|
+
import { readdir, readFile } from "node:fs/promises";
|
|
11
|
+
import { dirname, join } from "node:path";
|
|
12
|
+
import { fileURLToPath } from "node:url";
|
|
13
|
+
import pg from "pg";
|
|
14
|
+
|
|
15
|
+
const LOCK_KEY = 776352; // fixed key: every runner of this app takes the same lock
|
|
16
|
+
const migrationsDir = join(dirname(fileURLToPath(import.meta.url)), "migrations");
|
|
17
|
+
|
|
18
|
+
async function main() {
|
|
19
|
+
const connectionString = process.env.DATABASE_URL;
|
|
20
|
+
if (!connectionString) throw new Error("DATABASE_URL is not set");
|
|
21
|
+
|
|
22
|
+
const client = new pg.Client({ connectionString });
|
|
23
|
+
await client.connect();
|
|
24
|
+
let locked = false;
|
|
25
|
+
try {
|
|
26
|
+
await client.query("select pg_advisory_lock($1)", [LOCK_KEY]);
|
|
27
|
+
locked = true;
|
|
28
|
+
|
|
29
|
+
await client.query(
|
|
30
|
+
`create table if not exists schema_migrations (
|
|
31
|
+
name text primary key,
|
|
32
|
+
applied_at timestamptz not null default now()
|
|
33
|
+
)`,
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const files = (await readdir(migrationsDir)).filter((f) => f.endsWith(".sql")).sort();
|
|
37
|
+
for (const name of files) {
|
|
38
|
+
const applied = await client.query("select 1 from schema_migrations where name = $1", [name]);
|
|
39
|
+
if (applied.rowCount) {
|
|
40
|
+
console.log(`skip ${name}`);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const sql = await readFile(join(migrationsDir, name), "utf8");
|
|
44
|
+
await client.query("begin");
|
|
45
|
+
try {
|
|
46
|
+
await client.query(sql);
|
|
47
|
+
await client.query("insert into schema_migrations(name) values ($1)", [name]);
|
|
48
|
+
await client.query("commit");
|
|
49
|
+
console.log(`applied ${name}`);
|
|
50
|
+
} catch (err) {
|
|
51
|
+
await client.query("rollback");
|
|
52
|
+
throw err;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
} finally {
|
|
56
|
+
if (locked) await client.query("select pg_advisory_unlock($1)", [LOCK_KEY]).catch(() => {});
|
|
57
|
+
await client.end();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
main().catch((err) => {
|
|
62
|
+
console.error(err);
|
|
63
|
+
process.exit(1);
|
|
64
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
-- Baseline auth schema (canonical fixture — see ../README.md).
|
|
2
|
+
-- Idempotent: safe to run repeatedly. Owns ONLY the universal auth tables
|
|
3
|
+
-- (users + sessions) that every product needs identically. Product-specific
|
|
4
|
+
-- ownership links (associating a pre-signup result with a user) are added by the
|
|
5
|
+
-- product-auth workflow as a LATER migration — do not edit this file for those.
|
|
6
|
+
|
|
7
|
+
-- users: normalized-unique email + optional password hash.
|
|
8
|
+
create table if not exists users (
|
|
9
|
+
id uuid primary key default gen_random_uuid(),
|
|
10
|
+
email text not null,
|
|
11
|
+
password_hash text, -- null allowed for OAuth/passwordless identities
|
|
12
|
+
created_at timestamptz not null default now(),
|
|
13
|
+
updated_at timestamptz not null default now()
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
-- Case-insensitive email uniqueness. Insert the email as typed; the index
|
|
17
|
+
-- normalizes. (Do not also add a plain unique(email) — that would be redundant
|
|
18
|
+
-- and reject only exact-case dupes.)
|
|
19
|
+
create unique index if not exists users_email_lower_key on users (lower(email));
|
|
20
|
+
|
|
21
|
+
-- sessions: opaque server-side sessions, revocable, with explicit expiry.
|
|
22
|
+
create table if not exists sessions (
|
|
23
|
+
id uuid primary key default gen_random_uuid(),
|
|
24
|
+
user_id uuid not null references users(id) on delete cascade,
|
|
25
|
+
token_hash text not null, -- store a HASH of the opaque token, never the token itself
|
|
26
|
+
expires_at timestamptz not null,
|
|
27
|
+
created_at timestamptz not null default now(),
|
|
28
|
+
revoked_at timestamptz -- non-null => revoked; check alongside expiry on every request
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
create unique index if not exists sessions_token_hash_key on sessions (token_hash);
|
|
32
|
+
create index if not exists sessions_user_id_idx on sessions (user_id);
|
|
33
|
+
create index if not exists sessions_expires_at_idx on sessions (expires_at);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
-- External identities are product-owned. Provider subject, not email, is the
|
|
2
|
+
-- immutable authority. Idempotent and safe after 0001_auth.sql.
|
|
3
|
+
create table if not exists auth_identities (
|
|
4
|
+
id uuid primary key default gen_random_uuid(),
|
|
5
|
+
user_id uuid not null references users(id) on delete cascade,
|
|
6
|
+
provider text not null,
|
|
7
|
+
subject text not null,
|
|
8
|
+
email_at_link text not null,
|
|
9
|
+
created_at timestamptz not null default now(),
|
|
10
|
+
updated_at timestamptz not null default now()
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
create unique index if not exists auth_identities_provider_subject_key
|
|
14
|
+
on auth_identities (provider, subject);
|
|
15
|
+
create index if not exists auth_identities_user_id_idx
|
|
16
|
+
on auth_identities (user_id);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Auth database foundation
|
|
2
|
+
|
|
3
|
+
Reuse `db/migrations/0001_auth.sql`, `db/migrations/0002_auth_identities.sql`,
|
|
4
|
+
`db/migrate.mjs` and `db/create-validation-session.mjs`. Add product-specific
|
|
5
|
+
migrations after the shipped ones; do not edit or duplicate them.
|
|
6
|
+
|
|
7
|
+
These are the shared custom Node/Postgres database assets, not a complete auth
|
|
8
|
+
implementation. The application must implement the selected account-entry,
|
|
9
|
+
request-time session resolution, protected access, logout and recovery behavior
|
|
10
|
+
under the Product Auth contracts. Preserve an established auth library and its
|
|
11
|
+
own migration system instead of installing a parallel schema.
|
|
12
|
+
|
|
13
|
+
Run `npm run db:migrate` during a controlled build/deploy step with the attached
|
|
14
|
+
`DATABASE_URL`, never from a public route. The database-only installation does
|
|
15
|
+
not change the application's start command. Prepare private validation sessions
|
|
16
|
+
only after proving the real account-entry journey, matching the application's
|
|
17
|
+
cookie name and SHA-256 token lookup as described in `db/README.md`.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Product foundation
|
|
2
|
+
|
|
3
|
+
This repository includes the Postgres account/session foundation.
|
|
4
|
+
|
|
5
|
+
- Reuse `db/migrations/0001_auth.sql`, `db/migrations/0002_auth_identities.sql`, `db/migrate.mjs`, and `src/lib/egbe-product/*`; do not replace, relocate, or duplicate them.
|
|
6
|
+
- Add product-specific migrations after `0002_auth_identities.sql`. Do not edit either shipped migration.
|
|
7
|
+
- Implement the selected account-entry methods and applicable recovery behavior and auth UX on the provided users, identities, sessions, and server-only helpers. Use Egbe OS when Google is selected; the foundation does not require Google or an additional email method.
|
|
8
|
+
- Keep the cookie name `egbe_session` and SHA-256 token lookup so the private validation-session helper and the real request path share one contract.
|
|
9
|
+
- `npm start` applies migrations before the Next.js runtime starts. Never run migrations from a public route.
|