@heyo-sh/heyo-cms 0.0.0-stage → 0.2.0
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 +44 -2
- package/dist/access/index.d.ts +9 -0
- package/dist/access/index.d.ts.map +1 -0
- package/dist/access/permissions.d.ts +54 -0
- package/dist/access/permissions.d.ts.map +1 -0
- package/dist/adapters/astro.d.ts +45 -0
- package/dist/adapters/astro.d.ts.map +1 -0
- package/dist/adapters/astro.js +1 -0
- package/dist/adapters/deliver.d.ts +26 -0
- package/dist/adapters/deliver.d.ts.map +1 -0
- package/dist/adapters/next.d.ts +45 -0
- package/dist/adapters/next.d.ts.map +1 -0
- package/dist/adapters/next.js +1 -0
- package/dist/adapters/nuxt.d.ts +51 -0
- package/dist/adapters/nuxt.d.ts.map +1 -0
- package/dist/adapters/nuxt.js +1 -0
- package/dist/adapters/react-router.d.ts +36 -0
- package/dist/adapters/react-router.d.ts.map +1 -0
- package/dist/adapters/react-router.js +1 -0
- package/dist/adapters/sveltekit.d.ts +41 -0
- package/dist/adapters/sveltekit.d.ts.map +1 -0
- package/dist/adapters/sveltekit.js +1 -0
- package/dist/ai/assistant/context.d.ts +64 -0
- package/dist/ai/assistant/context.d.ts.map +1 -0
- package/dist/ai/assistant/limits.d.ts +10 -0
- package/dist/ai/assistant/limits.d.ts.map +1 -0
- package/dist/ai/assistant/plans.d.ts +83 -0
- package/dist/ai/assistant/plans.d.ts.map +1 -0
- package/dist/ai/assistant/prompt.d.ts +22 -0
- package/dist/ai/assistant/prompt.d.ts.map +1 -0
- package/dist/ai/assistant/run.d.ts +59 -0
- package/dist/ai/assistant/run.d.ts.map +1 -0
- package/dist/ai/assistant/runtime.d.ts +35 -0
- package/dist/ai/assistant/runtime.d.ts.map +1 -0
- package/dist/ai/assistant/schema.d.ts +66 -0
- package/dist/ai/assistant/schema.d.ts.map +1 -0
- package/dist/ai/assistant/tools.d.ts +41 -0
- package/dist/ai/assistant/tools.d.ts.map +1 -0
- package/dist/ai/assistant/values.d.ts +33 -0
- package/dist/ai/assistant/values.d.ts.map +1 -0
- package/dist/ai/crypto.d.ts +12 -0
- package/dist/ai/crypto.d.ts.map +1 -0
- package/dist/ai/index.d.ts +19 -0
- package/dist/ai/index.d.ts.map +1 -0
- package/dist/ai/pi.d.ts +89 -0
- package/dist/ai/pi.d.ts.map +1 -0
- package/dist/ai/registry.d.ts +66 -0
- package/dist/ai/registry.d.ts.map +1 -0
- package/dist/ai/service.d.ts +31 -0
- package/dist/ai/service.d.ts.map +1 -0
- package/dist/ai/variant-translation.d.ts +6 -0
- package/dist/ai/variant-translation.d.ts.map +1 -0
- package/dist/ai.d.ts +12 -0
- package/dist/ai.d.ts.map +1 -0
- package/dist/ai.js +1 -0
- package/dist/auth/config.d.ts +65 -0
- package/dist/auth/config.d.ts.map +1 -0
- package/dist/auth/crypto.d.ts +44 -0
- package/dist/auth/crypto.d.ts.map +1 -0
- package/dist/auth/index.d.ts +15 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/oauth.d.ts +93 -0
- package/dist/auth/oauth.d.ts.map +1 -0
- package/dist/auth/service.d.ts +38 -0
- package/dist/auth/service.d.ts.map +1 -0
- package/dist/auth/totp.d.ts +34 -0
- package/dist/auth/totp.d.ts.map +1 -0
- package/dist/auth.d.ts +9 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +30 -0
- package/dist/client/index.d.ts +51 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/types.d.ts +363 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client.d.ts +46 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +1 -0
- package/dist/config.d.ts +31 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +1 -0
- package/dist/content/export.d.ts +28 -0
- package/dist/content/export.d.ts.map +1 -0
- package/dist/content/import.d.ts +65 -0
- package/dist/content/import.d.ts.map +1 -0
- package/dist/content/records.d.ts +73 -0
- package/dist/content/records.d.ts.map +1 -0
- package/dist/content.d.ts +12 -0
- package/dist/content.d.ts.map +1 -0
- package/dist/content.js +1 -0
- package/dist/db/d1.d.ts +29 -0
- package/dist/db/d1.d.ts.map +1 -0
- package/dist/db/d1.js +1 -0
- package/dist/db/mongodb.d.ts +128 -0
- package/dist/db/mongodb.d.ts.map +1 -0
- package/dist/db/mongodb.js +2 -0
- package/dist/db/postgres.d.ts +37 -0
- package/dist/db/postgres.d.ts.map +1 -0
- package/dist/db/postgres.js +1 -0
- package/dist/db/sql/adapter.d.ts +57 -0
- package/dist/db/sql/adapter.d.ts.map +1 -0
- package/dist/db/sql/compile.d.ts +50 -0
- package/dist/db/sql/compile.d.ts.map +1 -0
- package/dist/db/sql/ddl.d.ts +34 -0
- package/dist/db/sql/ddl.d.ts.map +1 -0
- package/dist/db/sql/dialect.d.ts +37 -0
- package/dist/db/sql/dialect.d.ts.map +1 -0
- package/dist/db/sql/driver.d.ts +34 -0
- package/dist/db/sql/driver.d.ts.map +1 -0
- package/dist/db/sql/introspect.d.ts +15 -0
- package/dist/db/sql/introspect.d.ts.map +1 -0
- package/dist/db/sqlite.d.ts +50 -0
- package/dist/db/sqlite.d.ts.map +1 -0
- package/dist/db/sqlite.js +1 -0
- package/dist/defaults.d.ts +5 -0
- package/dist/defaults.d.ts.map +1 -0
- package/dist/duration.d.ts +12 -0
- package/dist/duration.d.ts.map +1 -0
- package/dist/editor/builtin.d.ts +45 -0
- package/dist/editor/builtin.d.ts.map +1 -0
- package/dist/editor/index.d.ts +14 -0
- package/dist/editor/index.d.ts.map +1 -0
- package/dist/editor/markdown.d.ts +19 -0
- package/dist/editor/markdown.d.ts.map +1 -0
- package/dist/editor/registry.d.ts +30 -0
- package/dist/editor/registry.d.ts.map +1 -0
- package/dist/editor/serialize.d.ts +41 -0
- package/dist/editor/serialize.d.ts.map +1 -0
- package/dist/editor.d.ts +10 -0
- package/dist/editor.d.ts.map +1 -0
- package/dist/editor.js +1 -0
- package/dist/engine/access.d.ts +33 -0
- package/dist/engine/access.d.ts.map +1 -0
- package/dist/engine/activity.d.ts +16 -0
- package/dist/engine/activity.d.ts.map +1 -0
- package/dist/engine/cursor.d.ts +19 -0
- package/dist/engine/cursor.d.ts.map +1 -0
- package/dist/engine/documents.d.ts +81 -0
- package/dist/engine/documents.d.ts.map +1 -0
- package/dist/engine/engine.d.ts +295 -0
- package/dist/engine/engine.d.ts.map +1 -0
- package/dist/engine/field-access.d.ts +21 -0
- package/dist/engine/field-access.d.ts.map +1 -0
- package/dist/engine/hooks.d.ts +58 -0
- package/dist/engine/hooks.d.ts.map +1 -0
- package/dist/engine/index.d.ts +20 -0
- package/dist/engine/index.d.ts.map +1 -0
- package/dist/engine/jobs.d.ts +63 -0
- package/dist/engine/jobs.d.ts.map +1 -0
- package/dist/engine/locales.d.ts +40 -0
- package/dist/engine/locales.d.ts.map +1 -0
- package/dist/engine/outbox.d.ts +81 -0
- package/dist/engine/outbox.d.ts.map +1 -0
- package/dist/engine/relations.d.ts +60 -0
- package/dist/engine/relations.d.ts.map +1 -0
- package/dist/engine/scoped-db.d.ts +13 -0
- package/dist/engine/scoped-db.d.ts.map +1 -0
- package/dist/engine/slugs.d.ts +124 -0
- package/dist/engine/slugs.d.ts.map +1 -0
- package/dist/engine/trash.d.ts +25 -0
- package/dist/engine/trash.d.ts.map +1 -0
- package/dist/errors.d.ts +42 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/fields/builtin.d.ts +169 -0
- package/dist/fields/builtin.d.ts.map +1 -0
- package/dist/fields/index.d.ts +3 -0
- package/dist/fields/index.d.ts.map +1 -0
- package/dist/fields/registry.d.ts +35 -0
- package/dist/fields/registry.d.ts.map +1 -0
- package/dist/fields.d.ts +9 -0
- package/dist/fields.d.ts.map +1 -0
- package/dist/fields.js +1 -0
- package/dist/http/guard.d.ts +45 -0
- package/dist/http/guard.d.ts.map +1 -0
- package/dist/http/handler.d.ts +31 -0
- package/dist/http/handler.d.ts.map +1 -0
- package/dist/http/index.d.ts +13 -0
- package/dist/http/index.d.ts.map +1 -0
- package/dist/http/openapi.d.ts +5 -0
- package/dist/http/openapi.d.ts.map +1 -0
- package/dist/http/params.d.ts +32 -0
- package/dist/http/params.d.ts.map +1 -0
- package/dist/http/request-db.d.ts +19 -0
- package/dist/http/request-db.d.ts.map +1 -0
- package/dist/http/respond.d.ts +48 -0
- package/dist/http/respond.d.ts.map +1 -0
- package/dist/http/rich-text.d.ts +41 -0
- package/dist/http/rich-text.d.ts.map +1 -0
- package/dist/http/router.d.ts +55 -0
- package/dist/http/router.d.ts.map +1 -0
- package/dist/http/routes/access.d.ts +13 -0
- package/dist/http/routes/access.d.ts.map +1 -0
- package/dist/http/routes/admin.d.ts +28 -0
- package/dist/http/routes/admin.d.ts.map +1 -0
- package/dist/http/routes/ai.d.ts +26 -0
- package/dist/http/routes/ai.d.ts.map +1 -0
- package/dist/http/routes/auth.d.ts +13 -0
- package/dist/http/routes/auth.d.ts.map +1 -0
- package/dist/http/routes/documents.d.ts +24 -0
- package/dist/http/routes/documents.d.ts.map +1 -0
- package/dist/http/routes/generate.d.ts +5 -0
- package/dist/http/routes/generate.d.ts.map +1 -0
- package/dist/http/routes/media.d.ts +58 -0
- package/dist/http/routes/media.d.ts.map +1 -0
- package/dist/http/routes/panel.d.ts +20 -0
- package/dist/http/routes/panel.d.ts.map +1 -0
- package/dist/http/routes/system.d.ts +25 -0
- package/dist/http/routes/system.d.ts.map +1 -0
- package/dist/http/routes/webhooks.d.ts +17 -0
- package/dist/http/routes/webhooks.d.ts.map +1 -0
- package/dist/http/spec.d.ts +28 -0
- package/dist/http/spec.d.ts.map +1 -0
- package/dist/http.d.ts +17 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +1 -0
- package/dist/i18n/index.d.ts +12 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/names.d.ts +25 -0
- package/dist/i18n/names.d.ts.map +1 -0
- package/dist/ids.d.ts +28 -0
- package/dist/ids.d.ts.map +1 -0
- package/dist/index-2ddk43me.js +2 -0
- package/dist/index-2prbs05k.js +2 -0
- package/dist/index-385ggnge.js +2 -0
- package/dist/index-466cwb0b.js +2 -0
- package/dist/index-4qrep5f0.js +26 -0
- package/dist/index-67e458ws.js +2 -0
- package/dist/index-6m1kjq9g.js +2 -0
- package/dist/index-6w10rch0.js +3 -0
- package/dist/index-761dec5z.js +2 -0
- package/dist/index-8nzmqy0f.js +2 -0
- package/dist/index-8x2em6c8.js +14 -0
- package/dist/index-91fa1gzf.js +2 -0
- package/dist/index-9g2n7xa6.js +2 -0
- package/dist/index-a8jcwqsf.js +2 -0
- package/dist/index-abfzb1ve.js +2 -0
- package/dist/index-cv0hpz3d.js +2 -0
- package/dist/index-ebtj6ebd.js +0 -0
- package/dist/index-g041kfa5.js +18 -0
- package/dist/index-g4crf47y.js +0 -0
- package/dist/index-hbx67b20.js +7 -0
- package/dist/index-hpast878.js +40 -0
- package/dist/index-kc1j3h6z.js +2 -0
- package/dist/index-p2cqsmvw.js +2 -0
- package/dist/index-rg9tpg3p.js +5 -0
- package/dist/index-rw0hze6x.js +2 -0
- package/dist/index-s9x07zb3.js +2 -0
- package/dist/index-sgdnp83t.js +2 -0
- package/dist/index-szaq03qq.js +2 -0
- package/dist/index-vkwzdfte.js +5 -0
- package/dist/index-vzhxn50e.js +2 -0
- package/dist/index-x72d1hzh.js +2 -0
- package/dist/index-y8kzzn94.js +2 -0
- package/dist/index-ypcmns0v.js +2 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/jobs/runner.d.ts +77 -0
- package/dist/jobs/runner.d.ts.map +1 -0
- package/dist/jobs.d.ts +11 -0
- package/dist/jobs.d.ts.map +1 -0
- package/dist/jobs.js +1 -0
- package/dist/media/cloudflare.d.ts +58 -0
- package/dist/media/cloudflare.d.ts.map +1 -0
- package/dist/media/document.d.ts +29 -0
- package/dist/media/document.d.ts.map +1 -0
- package/dist/media/gc.d.ts +46 -0
- package/dist/media/gc.d.ts.map +1 -0
- package/dist/media/index.d.ts +20 -0
- package/dist/media/index.d.ts.map +1 -0
- package/dist/media/pipeline.d.ts +55 -0
- package/dist/media/pipeline.d.ts.map +1 -0
- package/dist/media/probe.d.ts +6 -0
- package/dist/media/probe.d.ts.map +1 -0
- package/dist/media/service.d.ts +26 -0
- package/dist/media/service.d.ts.map +1 -0
- package/dist/media/sharp.d.ts +28 -0
- package/dist/media/sharp.d.ts.map +1 -0
- package/dist/media/strip.d.ts +16 -0
- package/dist/media/strip.d.ts.map +1 -0
- package/dist/media/urls.d.ts +77 -0
- package/dist/media/urls.d.ts.map +1 -0
- package/dist/media/usages.d.ts +77 -0
- package/dist/media/usages.d.ts.map +1 -0
- package/dist/media/variants.d.ts +61 -0
- package/dist/media/variants.d.ts.map +1 -0
- package/dist/migrations.d.ts +115 -0
- package/dist/migrations.d.ts.map +1 -0
- package/dist/migrations.js +1 -0
- package/dist/panel.d.ts +31 -0
- package/dist/panel.d.ts.map +1 -0
- package/dist/plugins/indexnow.d.ts +82 -0
- package/dist/plugins/indexnow.d.ts.map +1 -0
- package/dist/plugins.d.ts +9 -0
- package/dist/plugins.d.ts.map +1 -0
- package/dist/plugins.js +1 -0
- package/dist/query.d.ts +40 -0
- package/dist/query.d.ts.map +1 -0
- package/dist/query.js +1 -0
- package/dist/run-bjge3v8e.js +6 -0
- package/dist/schema/describe.d.ts +19 -0
- package/dist/schema/describe.d.ts.map +1 -0
- package/dist/schema/index.d.ts +5 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/plan.d.ts +20 -0
- package/dist/schema/plan.d.ts.map +1 -0
- package/dist/schema/snapshot.d.ts +24 -0
- package/dist/schema/snapshot.d.ts.map +1 -0
- package/dist/schema/system.d.ts +31 -0
- package/dist/schema/system.d.ts.map +1 -0
- package/dist/schema.d.ts +7 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +1 -0
- package/dist/slugify.d.ts +31 -0
- package/dist/slugify.d.ts.map +1 -0
- package/dist/storage/bytes.d.ts +17 -0
- package/dist/storage/bytes.d.ts.map +1 -0
- package/dist/storage/http.d.ts +43 -0
- package/dist/storage/http.d.ts.map +1 -0
- package/dist/storage/local.d.ts +31 -0
- package/dist/storage/local.d.ts.map +1 -0
- package/dist/storage/providers.d.ts +95 -0
- package/dist/storage/providers.d.ts.map +1 -0
- package/dist/storage/sign.d.ts +53 -0
- package/dist/storage/sign.d.ts.map +1 -0
- package/dist/strings.d.ts +13 -0
- package/dist/strings.d.ts.map +1 -0
- package/dist/telemetry.d.ts +137 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +1 -0
- package/dist/types/activity.d.ts +68 -0
- package/dist/types/activity.d.ts.map +1 -0
- package/dist/types/actor.d.ts +26 -0
- package/dist/types/actor.d.ts.map +1 -0
- package/dist/types/ai.d.ts +357 -0
- package/dist/types/ai.d.ts.map +1 -0
- package/dist/types/api.d.ts +268 -0
- package/dist/types/api.d.ts.map +1 -0
- package/dist/types/auth.d.ts +310 -0
- package/dist/types/auth.d.ts.map +1 -0
- package/dist/types/config.d.ts +647 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/database.d.ts +75 -0
- package/dist/types/database.d.ts.map +1 -0
- package/dist/types/editor.d.ts +166 -0
- package/dist/types/editor.d.ts.map +1 -0
- package/dist/types/events.d.ts +72 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/fields.d.ts +142 -0
- package/dist/types/fields.d.ts.map +1 -0
- package/dist/types/hooks.d.ts +142 -0
- package/dist/types/hooks.d.ts.map +1 -0
- package/dist/types/index.d.ts +25 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/instance.d.ts +263 -0
- package/dist/types/instance.d.ts.map +1 -0
- package/dist/types/jobs.d.ts +78 -0
- package/dist/types/jobs.d.ts.map +1 -0
- package/dist/types/json.d.ts +24 -0
- package/dist/types/json.d.ts.map +1 -0
- package/dist/types/locales.d.ts +30 -0
- package/dist/types/locales.d.ts.map +1 -0
- package/dist/types/media.d.ts +342 -0
- package/dist/types/media.d.ts.map +1 -0
- package/dist/types/panel.d.ts +249 -0
- package/dist/types/panel.d.ts.map +1 -0
- package/dist/types/plugin.d.ts +194 -0
- package/dist/types/plugin.d.ts.map +1 -0
- package/dist/types/query.d.ts +101 -0
- package/dist/types/query.d.ts.map +1 -0
- package/dist/types/schema.d.ts +203 -0
- package/dist/types/schema.d.ts.map +1 -0
- package/dist/types/storage.d.ts +61 -0
- package/dist/types/storage.d.ts.map +1 -0
- package/dist/types/telemetry.d.ts +14 -0
- package/dist/types/telemetry.d.ts.map +1 -0
- package/dist/types/trash.d.ts +42 -0
- package/dist/types/trash.d.ts.map +1 -0
- package/dist/types/webhooks.d.ts +133 -0
- package/dist/types/webhooks.d.ts.map +1 -0
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/uploads.d.ts +22 -0
- package/dist/uploads.d.ts.map +1 -0
- package/dist/uploads.js +9 -0
- package/dist/webhooks/index.d.ts +10 -0
- package/dist/webhooks/index.d.ts.map +1 -0
- package/dist/webhooks/job.d.ts +17 -0
- package/dist/webhooks/job.d.ts.map +1 -0
- package/dist/webhooks/service.d.ts +53 -0
- package/dist/webhooks/service.d.ts.map +1 -0
- package/dist/webhooks/sign.d.ts +26 -0
- package/dist/webhooks/sign.d.ts.map +1 -0
- package/dist/webhooks.d.ts +10 -0
- package/dist/webhooks.d.ts.map +1 -0
- package/dist/webhooks.js +1 -0
- package/package.json +187 -4
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every cryptographic primitive the auth layer needs, on Web Crypto alone.
|
|
3
|
+
*
|
|
4
|
+
* No `node:crypto`, no native dependency, no `bcrypt` build step: the same
|
|
5
|
+
* code has to run on Node, Bun, Cloudflare Workers and Vercel's edge runtime,
|
|
6
|
+
* and an auth package that only works on one of them would quietly undo the
|
|
7
|
+
* "zero framework coupling" promise at the deployment layer.
|
|
8
|
+
*/
|
|
9
|
+
export declare function hashPassword(password: string): Promise<string>;
|
|
10
|
+
/**
|
|
11
|
+
* Verifies a password against a stored hash.
|
|
12
|
+
*
|
|
13
|
+
* Reads the iteration count from the stored value instead of assuming the
|
|
14
|
+
* current one, so raising the cost later does not invalidate every existing
|
|
15
|
+
* password.
|
|
16
|
+
*/
|
|
17
|
+
export declare function verifyPassword(password: string, stored: string | null | undefined): Promise<boolean>;
|
|
18
|
+
/**
|
|
19
|
+
* A secret nobody can guess: 32 bytes of CSPRNG, URL-safe.
|
|
20
|
+
*
|
|
21
|
+
* Used for session tokens, API keys, invitations, magic links and OAuth
|
|
22
|
+
* state. One generator means one place to be wrong about entropy.
|
|
23
|
+
*/
|
|
24
|
+
export declare function randomToken(bytes?: number): string;
|
|
25
|
+
/**
|
|
26
|
+
* What goes in the database when the plaintext goes to the user.
|
|
27
|
+
*
|
|
28
|
+
* SHA-256 rather than PBKDF2 on purpose: these are 256-bit random secrets, not
|
|
29
|
+
* passwords, so there is nothing to brute-force and the lookup has to be a
|
|
30
|
+
* single indexed read on every request.
|
|
31
|
+
*/
|
|
32
|
+
export declare function hashToken(token: string): Promise<string>;
|
|
33
|
+
/**
|
|
34
|
+
* Comparison whose duration does not depend on where the strings differ.
|
|
35
|
+
*
|
|
36
|
+
* A fast `===` on a token hash leaks the prefix one byte at a time to anyone
|
|
37
|
+
* willing to measure.
|
|
38
|
+
*/
|
|
39
|
+
export declare function timingSafeEqual(left: string, right: string): boolean;
|
|
40
|
+
export declare function base64url(bytes: Uint8Array): string;
|
|
41
|
+
export declare function fromBase64url(value: string): Uint8Array;
|
|
42
|
+
/** SHA-256 of a string, base64url — the PKCE challenge, and nothing else. */
|
|
43
|
+
export declare function sha256Base64Url(value: string): Promise<string>;
|
|
44
|
+
//# sourceMappingURL=crypto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../src/auth/crypto.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAeH,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAIpE;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAChC,OAAO,CAAC,OAAO,CAAC,CAOlB;AAsBD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,SAAK,GAAG,MAAM,CAE9C;AAED;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAM9D;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAOpE;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAInD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAQvD;AAQD,6EAA6E;AAC7E,wBAAsB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAMpE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Editor authentication: configuration builders and the runtime behind
|
|
3
|
+
* `cms.auth`.
|
|
4
|
+
*
|
|
5
|
+
* The CMS has accounts for the people who edit content and for the machines
|
|
6
|
+
* that call its API, and for nobody else — the application being built brings
|
|
7
|
+
* its own identity layer (section 0). Everything here is Web Crypto and the
|
|
8
|
+
* database adapter, so the same sign-in works on Node, Bun and Workers.
|
|
9
|
+
*/
|
|
10
|
+
export { cmsUsers, oidc, type CmsUsersOptions, type OidcOptions } from "./config";
|
|
11
|
+
export { apiKeyPrefix, createAuth, sessionCookieName, type AuthServiceOptions, } from "./service";
|
|
12
|
+
export { base64url, hashPassword, hashToken, randomToken, verifyPassword, } from "./crypto";
|
|
13
|
+
export { generateTotpSecret, totpCode, totpUri, verifyTotp } from "./totp";
|
|
14
|
+
export { builtinProviders, decodeIdToken, type OAuthProfile, type OAuthProvider, } from "./oauth";
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,eAAe,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAClF,OAAO,EACL,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,KAAK,kBAAkB,GACxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,SAAS,EACT,YAAY,EACZ,SAAS,EACT,WAAW,EACX,cAAc,GACf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAC3E,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,KAAK,YAAY,EACjB,KAAK,aAAa,GACnB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { JsonObject } from "../types/json";
|
|
2
|
+
/**
|
|
3
|
+
* OAuth 2.0 and OpenID Connect, as plain functions.
|
|
4
|
+
*
|
|
5
|
+
* Nothing here touches the database or the configuration: a provider is a
|
|
6
|
+
* record of endpoints plus a function that turns whatever the provider
|
|
7
|
+
* returns into the three things the CMS needs — a stable id, an email and a
|
|
8
|
+
* display name. Adding a provider is therefore a literal, not a subclass.
|
|
9
|
+
*/
|
|
10
|
+
export interface OAuthProfile {
|
|
11
|
+
/** Stable at the provider. Never the email: emails get reassigned. */
|
|
12
|
+
id: string;
|
|
13
|
+
email: string | null;
|
|
14
|
+
name: string | null;
|
|
15
|
+
avatarUrl: string | null;
|
|
16
|
+
/** Everything the provider said, for `oidc().mapRoles`. */
|
|
17
|
+
claims: JsonObject;
|
|
18
|
+
}
|
|
19
|
+
export interface OAuthTokens {
|
|
20
|
+
accessToken: string;
|
|
21
|
+
idToken?: string;
|
|
22
|
+
tokenType?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface OAuthEndpoints {
|
|
25
|
+
authorization: string;
|
|
26
|
+
token: string;
|
|
27
|
+
userinfo?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface OAuthProvider {
|
|
30
|
+
id: string;
|
|
31
|
+
endpoints: OAuthEndpoints;
|
|
32
|
+
scope: string;
|
|
33
|
+
/** Proof Key for Code Exchange. Off for GitHub, which does not accept it. */
|
|
34
|
+
pkce: boolean;
|
|
35
|
+
profile(tokens: OAuthTokens, fetchImpl: FetchLike): Promise<OAuthProfile>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Just the call signature, not `typeof fetch`.
|
|
39
|
+
*
|
|
40
|
+
* Runtimes decorate the global with their own extras — Bun adds `preconnect`
|
|
41
|
+
* — and typing against the global would make a hand-written test double fail
|
|
42
|
+
* to compile for a reason that has nothing to do with HTTP.
|
|
43
|
+
*/
|
|
44
|
+
export type FetchLike = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
45
|
+
/**
|
|
46
|
+
* The three providers the plan names.
|
|
47
|
+
*
|
|
48
|
+
* Google and Microsoft are OpenID Connect, so the profile comes from the
|
|
49
|
+
* id_token and needs no second round trip. GitHub is plain OAuth 2 and hides
|
|
50
|
+
* a verified address behind a separate endpoint when the public profile has
|
|
51
|
+
* none, which is the common case for a work account.
|
|
52
|
+
*/
|
|
53
|
+
export declare const builtinProviders: Record<string, OAuthProvider>;
|
|
54
|
+
/** The shape every OIDC provider agrees on, including a custom issuer. */
|
|
55
|
+
export declare function oidcProfile(claims: JsonObject): OAuthProfile;
|
|
56
|
+
/**
|
|
57
|
+
* Reads an id_token without verifying its signature.
|
|
58
|
+
*
|
|
59
|
+
* Allowed, and only allowed, because of how it arrives: the authorization code
|
|
60
|
+
* flow fetches it from the token endpoint over TLS, with the client
|
|
61
|
+
* authenticating itself — OpenID Connect Core 3.1.3.7 explicitly permits
|
|
62
|
+
* skipping signature validation on that path. A token that reached us any
|
|
63
|
+
* other way must never be passed to this function.
|
|
64
|
+
*/
|
|
65
|
+
export declare function decodeIdToken(token: string): JsonObject;
|
|
66
|
+
export declare function discoverOidc(issuer: string, fetchImpl: FetchLike): Promise<OAuthEndpoints>;
|
|
67
|
+
export interface AuthorizeUrlOptions {
|
|
68
|
+
endpoints: OAuthEndpoints;
|
|
69
|
+
clientId: string;
|
|
70
|
+
redirectUri: string;
|
|
71
|
+
scope: string;
|
|
72
|
+
state: string;
|
|
73
|
+
/** The S256 challenge; omitted for providers that reject PKCE. */
|
|
74
|
+
codeChallenge?: string;
|
|
75
|
+
extra?: Record<string, string>;
|
|
76
|
+
}
|
|
77
|
+
export declare function buildAuthorizeUrl(options: AuthorizeUrlOptions): string;
|
|
78
|
+
/** The PKCE pair: a verifier to keep, a challenge to publish. */
|
|
79
|
+
export declare function pkcePair(verifier: string): Promise<{
|
|
80
|
+
verifier: string;
|
|
81
|
+
challenge: string;
|
|
82
|
+
}>;
|
|
83
|
+
export interface ExchangeOptions {
|
|
84
|
+
endpoints: OAuthEndpoints;
|
|
85
|
+
clientId: string;
|
|
86
|
+
clientSecret: string;
|
|
87
|
+
code: string;
|
|
88
|
+
redirectUri: string;
|
|
89
|
+
codeVerifier?: string;
|
|
90
|
+
fetchImpl: FetchLike;
|
|
91
|
+
}
|
|
92
|
+
export declare function exchangeCode(options: ExchangeOptions): Promise<OAuthTokens>;
|
|
93
|
+
//# sourceMappingURL=oauth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../src/auth/oauth.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD;;;;;;;GAOG;AAEH,MAAM,WAAW,YAAY;IAC3B,sEAAsE;IACtE,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,2DAA2D;IAC3D,MAAM,EAAE,UAAU,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,cAAc,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,6EAA6E;IAC7E,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CAC3E;AAED;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GAAG,CACtB,KAAK,EAAE,WAAW,GAAG,GAAG,EACxB,IAAI,CAAC,EAAE,WAAW,KACf,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEvB;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAyE1D,CAAC;AAEF,0EAA0E;AAC1E,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,YAAY,CAQ5D;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAavD;AAWD,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC,cAAc,CAAC,CA8BzB;AAED,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,cAAc,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,kEAAkE;IAClE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAetE;AAED,iEAAiE;AACjE,wBAAsB,QAAQ,CAC5B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAElD;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,cAAc,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,SAAS,CAAC;CACtB;AAED,wBAAsB,YAAY,CAChC,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,WAAW,CAAC,CAuCtB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { CmsAuth } from "../types/auth";
|
|
2
|
+
import type { ResolvedCmsConfig } from "../types/config";
|
|
3
|
+
import type { DatabaseAdapter } from "../types/database";
|
|
4
|
+
import type { Tx } from "../types/query";
|
|
5
|
+
import type { BufferedEvent, OutboxEntryMeta } from "../engine/outbox";
|
|
6
|
+
import { type FetchLike } from "./oauth";
|
|
7
|
+
/** The cookie the panel uses. Named here so stage 7 cannot invent a second. */
|
|
8
|
+
export declare const sessionCookieName = "heyo_cms_session";
|
|
9
|
+
/**
|
|
10
|
+
* API keys announce themselves.
|
|
11
|
+
*
|
|
12
|
+
* One `Authorization: Bearer` header carries either a session token or a
|
|
13
|
+
* machine key, and the prefix is what tells them apart without a database
|
|
14
|
+
* round trip against both tables.
|
|
15
|
+
*/
|
|
16
|
+
export declare const apiKeyPrefix = "hck_";
|
|
17
|
+
export interface AuthServiceOptions {
|
|
18
|
+
config: ResolvedCmsConfig;
|
|
19
|
+
database: () => Promise<DatabaseAdapter>;
|
|
20
|
+
/** Appends events to the outbox inside the caller's transaction. */
|
|
21
|
+
emit: (tx: Tx, events: BufferedEvent[], meta: OutboxEntryMeta) => Promise<void>;
|
|
22
|
+
/** Schedules delivery once the transaction has committed. */
|
|
23
|
+
deliver: () => void;
|
|
24
|
+
/** Injectable for tests and for runtimes with a bound fetch. */
|
|
25
|
+
fetch?: FetchLike;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Editor authentication and RBAC.
|
|
29
|
+
*
|
|
30
|
+
* One implementation, used by the local API today and by the REST routes in
|
|
31
|
+
* stage 7 — the same reason `cms.api` exists. Everything is a method on this
|
|
32
|
+
* object rather than a route handler, so a CLI, a seed script and a panel all
|
|
33
|
+
* get identical behaviour, including the parts that are easy to get wrong:
|
|
34
|
+
* single-use tokens, hashed secrets, and a second factor that cannot be
|
|
35
|
+
* skipped by calling a different function.
|
|
36
|
+
*/
|
|
37
|
+
export declare function createAuth(options: AuthServiceOptions): CmsAuth;
|
|
38
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/auth/service.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAEV,OAAO,EAYR,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAGV,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,KAAK,EAAO,EAAE,EAAS,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGvE,OAAO,EAQL,KAAK,SAAS,EAIf,MAAM,SAAS,CAAC;AAUjB,+EAA+E;AAC/E,eAAO,MAAM,iBAAiB,qBAAqB,CAAC;AAEpD;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,SAAS,CAAC;AAoBnC,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;IACzC,oEAAoE;IACpE,IAAI,EAAE,CACJ,EAAE,EAAE,EAAE,EACN,MAAM,EAAE,aAAa,EAAE,EACvB,IAAI,EAAE,eAAe,KAClB,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,6DAA6D;IAC7D,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,gEAAgE;IAChE,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CA0qD/D"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TOTP (RFC 6238), on Web Crypto.
|
|
3
|
+
*
|
|
4
|
+
* Six digits, thirty seconds, HMAC-SHA1 — not because SHA-1 is a good hash in
|
|
5
|
+
* 2026, but because it is what every authenticator app implements, and a
|
|
6
|
+
* second factor nobody can enrol is not a second factor.
|
|
7
|
+
*/
|
|
8
|
+
/** 160 bits, the size RFC 4226 recommends for the HMAC-SHA1 key. */
|
|
9
|
+
export declare function generateTotpSecret(): string;
|
|
10
|
+
/**
|
|
11
|
+
* The `otpauth://` URI an authenticator scans.
|
|
12
|
+
*
|
|
13
|
+
* The issuer appears twice — as a label prefix and as a parameter — which is
|
|
14
|
+
* redundant and is also what every app expects.
|
|
15
|
+
*/
|
|
16
|
+
export declare function totpUri(options: {
|
|
17
|
+
secret: string;
|
|
18
|
+
account: string;
|
|
19
|
+
issuer: string;
|
|
20
|
+
}): string;
|
|
21
|
+
export declare function totpCode(secret: string, at?: number): Promise<string>;
|
|
22
|
+
/**
|
|
23
|
+
* Verifies a code, allowing one step either side.
|
|
24
|
+
*
|
|
25
|
+
* The window is for clock drift between the phone and the server, not for
|
|
26
|
+
* convenience: widening it multiplies the number of codes that are valid at
|
|
27
|
+
* any moment, which is exactly what the second factor is trying to limit.
|
|
28
|
+
*/
|
|
29
|
+
export declare function verifyTotp(secret: string | null | undefined, code: string, options?: {
|
|
30
|
+
at?: number;
|
|
31
|
+
window?: number;
|
|
32
|
+
}): Promise<boolean>;
|
|
33
|
+
export declare function base32Encode(bytes: Uint8Array): string;
|
|
34
|
+
//# sourceMappingURL=totp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"totp.d.ts","sourceRoot":"","sources":["../../src/auth/totp.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,oEAAoE;AACpE,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,MAAM,CAUT;AAED,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,MAAM,EACd,EAAE,SAAa,GACd,OAAO,CAAC,MAAM,CAAC,CAEjB;AAED;;;;;;GAMG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACjC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,GAC7C,OAAO,CAAC,OAAO,CAAC,CAmBlB;AA+BD,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAetD"}
|
package/dist/auth.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@heyo-sh/heyo-cms/auth`.
|
|
3
|
+
*
|
|
4
|
+
* `cmsUsers()` and `oidc()` describe who may sign in; the service behind
|
|
5
|
+
* `cms.auth` does the signing in. Both live here so a configuration file and
|
|
6
|
+
* a route handler import from the same place.
|
|
7
|
+
*/
|
|
8
|
+
export * from "./auth/index";
|
|
9
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,cAAc,CAAC"}
|
package/dist/auth.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./index-6m1kjq9g.js";import{_e}from"./index-sgdnp83t.js";import{Nn,$t,Un,Jn,Qo,cn,be,dn,un}from"./index-2prbs05k.js";import{Pe,pn,we,re,ie}from"./index-p2cqsmvw.js";import{w}from"./index-rw0hze6x.js";import{n}from"./index-x72d1hzh.js";function o(e){if(e.methods.length===0)throw new n("admin.auth.methods","at least one sign-in method is required");for(let[s,t]of[["session",e.session?.expiresIn],["invites",e.invites?.expiresIn],["magicLink",e.magicLink?.expiresIn],["passwordReset",e.passwordReset?.expiresIn],["apiKeys",e.apiKeys?.expiresIn]])if(t)w(t,`admin.auth.${s}.expiresIn`);for(let s of e.apiKeys?.scopes??[])if(!_e(s))throw new n("admin.auth.apiKeys.scopes",`"${s}" is not a scope; use "read", "write", "delete", "*" or "collection:action"`);let i=e.firstUser;if(typeof i==="object"){let s=i.roles;if(s!==void 0&&s.length===0)throw new n("admin.auth.firstUser.roles","the first account needs at least one role")}if(i!==void 0&&i!==!1&&!e.methods.includes("password"))throw new n("admin.auth.firstUser",'the first account signs in with a password; add "password" to methods, or set firstUser: false');let r=e.password?.minLength;if(r!==void 0&&r<8)throw new n("admin.auth.password.minLength","must be at least 8");return{kind:"cms-users",...e}}function a(e){if(!/^https?:\/\//.test(e.issuer))throw new n("admin.auth.sso.issuer","must be an HTTP(S) issuer URL");return{kind:"oidc",...e}}export{dn as apiKeyPrefix,ie as base64url,Nn as builtinProviders,o as cmsUsers,un as createAuth,$t as decodeIdToken,Un as generateTotpSecret,Pe as hashPassword,re as hashToken,a as oidc,we as randomToken,be as sessionCookieName,Qo as totpCode,Jn as totpUri,pn as verifyPassword,cn as verifyTotp};
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AA8DA,wBAAsB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA+B1D"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import"./index-sgdnp83t.js";import"./index-6m1kjq9g.js";import"./index-abfzb1ve.js";import"./index-cv0hpz3d.js";import"./index-g041kfa5.js";import"./index-8x2em6c8.js";import"./index-hpast878.js";import"./index-kc1j3h6z.js";import{an,Dn,qn,Ln}from"./index-vkwzdfte.js";import{Ut,Jt,yn}from"./index-szaq03qq.js";import{Dt,qt,Lt,Ft,Nt}from"./index-rg9tpg3p.js";import"./index-6w10rch0.js";import"./index-91fa1gzf.js";import"./index-2prbs05k.js";import{createRequire as C}from"node:module";var m=C(import.meta.url);import{createReadStream as b,createWriteStream as v}from"node:fs";import{readFile as p,stat as k}from"node:fs/promises";import{isAbsolute as I,resolve as l}from"node:path";import{pathToFileURL as M}from"node:url";import{randomBytes as P}from"node:crypto";var g=`
|
|
3
|
+
heyo-cms generate [--name <name>] write a migration for what changed
|
|
4
|
+
heyo-cms migrate apply pending migrations
|
|
5
|
+
heyo-cms status show applied, pending and unplanned changes
|
|
6
|
+
|
|
7
|
+
heyo-cms create-admin create an editor account from a shell
|
|
8
|
+
--email <address> required unless HEYO_CMS_ADMIN_EMAIL is set
|
|
9
|
+
--password <value> default: generated and printed once
|
|
10
|
+
--name <name> display name
|
|
11
|
+
--roles <a,b> default: admin
|
|
12
|
+
|
|
13
|
+
heyo-cms seed [--file <path>] run the project's seed module
|
|
14
|
+
|
|
15
|
+
heyo-cms export [--out <file>] write content as NDJSON (default: stdout)
|
|
16
|
+
--collections <a,b> default: every collection
|
|
17
|
+
--globals <a,b> default: every global
|
|
18
|
+
--include-trashed include documents in the trash
|
|
19
|
+
|
|
20
|
+
heyo-cms import <file> read an export back ("-" is stdin)
|
|
21
|
+
--on-conflict <skip|update|fail> default: skip
|
|
22
|
+
--dry-run parse and report without writing
|
|
23
|
+
|
|
24
|
+
heyo-cms telemetry print exactly what would be reported
|
|
25
|
+
|
|
26
|
+
--config <path> configuration module (default: ./heyo-cms.config.ts)
|
|
27
|
+
--dir <path> migrations directory (default: the one in the config)
|
|
28
|
+
--env <path> environment file (default: ./.env, then ./.env.local)
|
|
29
|
+
`;async function _(e){let{command:n,positionals:o,flags:t}=N(e);if(!n||n==="help"||t.has("--help"))return console.log(g),n&&n!=="help"?1:0;await U(t.get("--env"));let s=await j(t.get("--config"));switch(n){case"generate":case"migrate":case"status":return await A(n,s,t);case"create-admin":return await d(n,s,await x(s,t));case"seed":return await d(n,s,await O(s,t));case"export":return await d(n,s,await R(s,t));case"import":return await d(n,s,await W(s,o[1],t));case"telemetry":return await D(s);default:return console.error(`Unknown command: ${n}`),console.log(g),1}}async function A(e,n,o){let t=l(o.get("--dir")??n._config.migrationsDirectory),s=new an(t),a=await n.database();if(e==="generate"){let i=await Dn({adapter:a,store:s,target:n.schema,plugins:n._config.plugins.flatMap((c)=>(c.migrations??[]).map((u)=>({plugin:c.id,id:u.id,steps:u.steps}))),...o.get("--name")?{name:o.get("--name")}:{}});if(i.created){console.log(`Wrote ${i.file}`);for(let c of i.summary)console.log(` ${c}`)}for(let c of i.plugins??[])console.log(`Wrote ${c.file} (plugin migration)`);if(!i.created&&(i.plugins??[]).length===0)console.log("No schema changes. Nothing to generate.");return await d(e,n,0)}if(e==="migrate"){let i=await qn({adapter:a,store:s});if(i.applied.length===0)return console.log(`Up to date (${i.alreadyApplied} migration(s) already applied).`),await d(e,n,0);for(let c of i.applied)console.log(`Applied ${c}`);return await d(e,n,0)}let r=await Ln({adapter:a,store:s,target:n.schema});console.log(`Applied: ${r.applied.length}`);for(let i of r.pending)console.log(` pending ${i}`);for(let i of r.modified)console.log(` MODIFIED ${i} (applied, then edited)`);if(r.unplanned.length>0)console.log(` ${r.unplanned.length} change(s) in the configuration have no migration yet; run "heyo-cms generate".`);return r.pending.length>0||r.modified.length>0||r.unplanned.length>0?1:0}async function x(e,n){let o=n.get("--email")??process.env.HEYO_CMS_ADMIN_EMAIL;if(!o)return console.error("An address is required: heyo-cms create-admin --email you@example.com"),1;let t=n.get("--password")??process.env.HEYO_CMS_ADMIN_PASSWORD,s=t??E(),a=(n.get("--roles")??"admin").split(",").map((c)=>c.trim()).filter((c)=>c.length>0),r=await e.auth.users.byEmail(o);if(r)return console.error(`${o} already has an account (${r.status}). Use the panel, or cms.auth.users.setPassword().`),1;let i=await e.auth.users.create({email:o,password:s,roles:a,status:"active",...n.get("--name")?{name:n.get("--name")}:{}});if(await e.drainEvents(),console.log(`Created ${i.email} with role(s) ${i.roles.join(", ")}.`),!t)console.log(`Password: ${s}`),console.log("This is the only time it is shown.");return console.log(`Sign in at ${e._config.basePath}${e._config.admin.path}.`),0}function E(){return P(24).toString("base64url")}var S=["heyo-cms.seed.ts","heyo-cms.seed.js","seed.ts","src/heyo-cms.seed.ts"];async function O(e,n){let o=n.get("--file")?l(n.get("--file")):await y(S,"seed module"),t=await h(o),s=t.seed??t.default;if(typeof s!=="function")return console.error(`${o} does not export a seed. Add \`export async function seed(cms) { ... }\`.`),1;return await s(e),await e.drainEvents(),console.log(`Seeded from ${o}.`),0}async function R(e,n){let o=n.get("--out"),t=o?F(l(o)):Y(),s=0,a=0;try{for await(let r of Ft(e,{...f(n,"--collections","collections"),...f(n,"--globals","globals"),...n.has("--include-trashed")?{includeTrashed:!0}:{}})){if(r.kind==="document")s+=1;if(r.kind==="global")a+=1;await t.line(Lt(r))}}finally{await t.close()}return console.error(`Exported ${s} document(s) and ${a} global(s).`),0}async function W(e,n,o){if(!n)return console.error('A file is required: heyo-cms import content.ndjson (or "-").'),1;let t=o.get("--on-conflict")??"skip";if(!["skip","update","fail"].includes(t))return console.error(`--on-conflict takes skip, update or fail; got ${t}.`),1;let s={onConflict:t,...o.has("--dry-run")?{dryRun:!0}:{}},a=n==="-"?H():q(l(n)),r=await Nt(e,Dt(qt(a)),s),i=s.dryRun?"Would import":"Imported";if(console.log(`${i} ${r.documents.created} new and ${r.documents.updated} updated document(s), ${r.globals.updated} global(s).`),r.documents.skipped>0)console.log(`Skipped ${r.documents.skipped} document(s).`);for(let c of r.errors)console.error(` ${c}`);return r.errors.length>0?1:0}async function D(e){let n=Ut(e._config.telemetry),o=Jt("telemetry",e,await w());return console.log(n.enabled?"Telemetry: on":"Telemetry: off"),console.log(` ${n.reason}`),console.log(""),console.log(" What a command would send, in full:"),console.log(""),console.log(JSON.stringify(o,null,2)),console.log(""),console.log(" Turn it off with any of:"),console.log(" HEYO_TELEMETRY_DISABLED=1"),console.log(" DO_NOT_TRACK=1"),console.log(" telemetry: { enabled: false } in heyo-cms.config.ts"),console.log(""),0}async function d(e,n,o){try{await yn({event:e,cms:n,version:await w(),...n._config.telemetry?{config:n._config.telemetry}:{}})}catch{}return o}function N(e){let n=new Map,o=[];for(let t=0;t<e.length;t+=1){let s=e[t];if(!s.startsWith("--")){o.push(s);continue}let a=e[t+1];if(a!==void 0&&!a.startsWith("--"))n.set(s,a),t+=1;else n.set(s,"true")}return{command:o[0],positionals:o,flags:n}}function f(e,n,o){let t=e.get(n);if(!t||t==="true")return{};return{[o]:t.split(",").map((s)=>s.trim()).filter((s)=>s.length>0)}}var T=["heyo-cms.config.ts","heyo-cms.config.js","heyo-cms.config.mjs","src/heyo-cms.config.ts","app/heyo-cms.config.ts"];async function j(e){let n=e?l(e):await y(T,"configuration"),o=await h(n),t=o.cms??o.default;if(!L(t))throw Error(`${n} does not export a CMS. Add \`export const cms = heyoCms({ ... })\`.`);return t}async function h(e){return await(I(e)?import(M(e).href):import(e))}async function y(e,n){for(let o of e){let t=l(o);try{return await k(t),t}catch{}}throw Error(`No ${n} found. Looked for ${e.join(", ")}. Use --config or --file.`)}function L(e){return typeof e==="object"&&e!==null&&"_config"in e&&"schema"in e&&typeof e.database==="function"}async function U(e){let n=e?[l(e)]:[l(".env"),l(".env.local")];for(let o of n){let t;try{t=await p(o,"utf8")}catch{if(e)throw Error(`No environment file at ${o}.`);continue}for(let s of t.split(`
|
|
30
|
+
`)){let a=/^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)$/.exec(s);if(!a)continue;let[,r,i]=a;if(process.env[r]!==void 0)continue;let c=i.trim(),u=/^(["'])([\s\S]*)\1$/.exec(c);process.env[r]=u?u[2]:c.split(" #")[0].trim()}}}async function w(){try{let e=await p(new URL("../package.json",import.meta.url),"utf8");return JSON.parse(e).version??"0.0.0"}catch{return"0.0.0"}}function F(e){let n=v(e,{encoding:"utf8"});return{line:(o)=>new Promise((t,s)=>{n.write(o,(a)=>a?s(a):t())}),close:()=>new Promise((o)=>n.end(()=>o()))}}function Y(){return{line:(e)=>new Promise((n,o)=>{process.stdout.write(e,(t)=>t?o(t):n())}),close:async()=>{}}}async function*q(e){let n=b(e,{encoding:"utf8"});for await(let o of n)yield o}async function*H(){process.stdin.setEncoding("utf8");for await(let e of process.stdin)yield e}if(m.main==m.module)_(process.argv.slice(2)).then((e)=>{process.exitCode=e}).catch((e)=>{console.error(e instanceof Error?e.message:String(e)),process.exitCode=1});export{_ as main};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { CmsPlugin } from "../types/plugin";
|
|
2
|
+
import type { CmsClient, PluginExtensions } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* The typed client.
|
|
5
|
+
*
|
|
6
|
+
* The public entry point picks up the project's registered CMS type, so
|
|
7
|
+
* `heyoCmsClient()` is typed without importing server configuration into the
|
|
8
|
+
* browser bundle. `heyoCmsClient<typeof cms>()` remains available for a
|
|
9
|
+
* project with more than one CMS. The methods
|
|
10
|
+
* mirror `cms.api` exactly, because the routes they call are three lines
|
|
11
|
+
* around `cms.api`: code written against the local API moves to the client by
|
|
12
|
+
* changing the object it is called on.
|
|
13
|
+
*
|
|
14
|
+
* What it is not: an ORM, a cache or a state manager. It is `fetch` with the
|
|
15
|
+
* URL building, the error shape and the 204 convention taken care of, and it
|
|
16
|
+
* is tiny on purpose — this ships to browsers.
|
|
17
|
+
*/
|
|
18
|
+
export interface CmsClientOptions<TPlugins extends readonly CmsPlugin<unknown>[] = []> {
|
|
19
|
+
/**
|
|
20
|
+
* Where the handler is mounted.
|
|
21
|
+
*
|
|
22
|
+
* Defaults to the same-origin `/api/heyo-cms` mount in a browser. Set this
|
|
23
|
+
* for a custom mount or a CMS on another origin, e.g.
|
|
24
|
+
* `https://cms.acme.dev/api/heyo-cms`.
|
|
25
|
+
*/
|
|
26
|
+
baseUrl?: string;
|
|
27
|
+
/**
|
|
28
|
+
* A session token or an API key.
|
|
29
|
+
*
|
|
30
|
+
* A function is resolved per request, which is what makes a rotating key or
|
|
31
|
+
* a token read out of a cookie store work without rebuilding the client.
|
|
32
|
+
* Omit it in a browser: the session cookie is sent automatically.
|
|
33
|
+
*/
|
|
34
|
+
token?: string | (() => string | null | undefined | Promise<string | null | undefined>);
|
|
35
|
+
headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
|
|
36
|
+
/** Injectable so a test, a Worker or a framework's own `fetch` can be used. */
|
|
37
|
+
fetch?: typeof fetch;
|
|
38
|
+
/** Defaults to `same-origin`, which is what a cookie session needs. */
|
|
39
|
+
credentials?: RequestCredentials;
|
|
40
|
+
/**
|
|
41
|
+
* The plugins whose client extensions should be installed.
|
|
42
|
+
*
|
|
43
|
+
* Passed rather than discovered: the configuration lives on the server and
|
|
44
|
+
* the client is a browser bundle, so the only way the extension types can
|
|
45
|
+
* reach it is through this list.
|
|
46
|
+
*/
|
|
47
|
+
plugins?: TPlugins;
|
|
48
|
+
}
|
|
49
|
+
export declare function heyoCmsClient<TCms = import("../types/instance").CmsInstance, const TPlugins extends readonly CmsPlugin<unknown>[] = []>(options?: CmsClientOptions<TPlugins>): CmsClient<TCms> & PluginExtensions<TPlugins>;
|
|
50
|
+
export type * from "./types";
|
|
51
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EASV,SAAS,EACT,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;GAcG;AAEH,MAAM,WAAW,gBAAgB,CAC/B,QAAQ,SAAS,SAAS,SAAS,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE;IAEnD;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC;IACxF,OAAO,CAAC,EACJ,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACtB,CAAC,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IACrE,+EAA+E;IAC/E,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,uEAAuE;IACvE,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,QAAQ,CAAC;CACpB;AAED,wBAAgB,aAAa,CAC3B,IAAI,GAAG,OAAO,mBAAmB,EAAE,WAAW,EAC9C,KAAK,CAAC,QAAQ,SAAS,SAAS,SAAS,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,EAEzD,OAAO,GAAE,gBAAgB,CAAC,QAAQ,CAAM,GACvC,SAAS,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAmO9C;AA4TD,mBAAmB,SAAS,CAAC"}
|