@cossackframework/cms 0.0.0 → 0.9.1
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 +145 -2
- package/agent-docs.json +259 -0
- package/app/README.md +78 -0
- package/app/cossack-recipe.json +43 -0
- package/app/src/auth-bot-check.ts +32 -0
- package/app/src/auth-bot-token.ts +11 -0
- package/app/src/auth-input.ts +35 -0
- package/app/src/auth-options.ts +18 -0
- package/app/src/auth-providers.ts +16 -0
- package/app/src/auth.ts +1082 -0
- package/app/src/brand.ts +68 -0
- package/app/src/cms/ai.ts +54 -0
- package/app/src/cms/analytics.ts +33 -0
- package/app/src/cms/block-errors.ts +55 -0
- package/app/src/cms/block-inserter.ts +111 -0
- package/app/src/cms/block-panel.ts +68 -0
- package/app/src/cms/block-rows.ts +44 -0
- package/app/src/cms/block-tree.ts +585 -0
- package/app/src/cms/blocks.css +708 -0
- package/app/src/cms/builder.ts +126 -0
- package/app/src/cms/cache.ts +44 -0
- package/app/src/cms/carousel.client.ts +52 -0
- package/app/src/cms/collab/presence.ts +69 -0
- package/app/src/cms/collab/rich-text-collab.client.ts +197 -0
- package/app/src/cms/collab/rich-text-notes.client.ts +138 -0
- package/app/src/cms/collab/room.ts +881 -0
- package/app/src/cms/compare.client.ts +47 -0
- package/app/src/cms/condition-control.ts +109 -0
- package/app/src/cms/content-api.ts +143 -0
- package/app/src/cms/content.ts +524 -0
- package/app/src/cms/countdown.client.ts +37 -0
- package/app/src/cms/editor-layout-editor.ts +260 -0
- package/app/src/cms/editor-layout-view.ts +37 -0
- package/app/src/cms/editor.ts +381 -0
- package/app/src/cms/entry.ts +26 -0
- package/app/src/cms/feeds.ts +145 -0
- package/app/src/cms/field-controls.ts +222 -0
- package/app/src/cms/field-group-editor.ts +105 -0
- package/app/src/cms/field-group-view.ts +211 -0
- package/app/src/cms/form-view.ts +203 -0
- package/app/src/cms/form.client.ts +203 -0
- package/app/src/cms/guards.ts +27 -0
- package/app/src/cms/handoff.ts +202 -0
- package/app/src/cms/headings.ts +51 -0
- package/app/src/cms/icons.ts +80 -0
- package/app/src/cms/import.client.ts +16 -0
- package/app/src/cms/index.ts +191 -0
- package/app/src/cms/lightbox.client.ts +109 -0
- package/app/src/cms/machine.ts +118 -0
- package/app/src/cms/maintenance.ts +97 -0
- package/app/src/cms/manage.ts +1236 -0
- package/app/src/cms/mcp-tools.ts +388 -0
- package/app/src/cms/mcp.ts +242 -0
- package/app/src/cms/media-chooser.ts +123 -0
- package/app/src/cms/media-usage.ts +57 -0
- package/app/src/cms/middleware.ts +199 -0
- package/app/src/cms/middlewares.ts +13 -0
- package/app/src/cms/network-ui.ts +36 -0
- package/app/src/cms/network-view.ts +38 -0
- package/app/src/cms/notes-announce.ts +65 -0
- package/app/src/cms/notes-rail.ts +207 -0
- package/app/src/cms/notification-rules.ts +66 -0
- package/app/src/cms/recovery.ts +82 -0
- package/app/src/cms/replace.ts +63 -0
- package/app/src/cms/reserved-paths.ts +19 -0
- package/app/src/cms/rich-text-field.ts +325 -0
- package/app/src/cms/rich-text-schema.ts +91 -0
- package/app/src/cms/rich-text.client.ts +255 -0
- package/app/src/cms/search.client.ts +116 -0
- package/app/src/cms/seo-head.ts +78 -0
- package/app/src/cms/seo.ts +241 -0
- package/app/src/cms/settings-draft.ts +218 -0
- package/app/src/cms/settings-file.ts +127 -0
- package/app/src/cms/settings-form.ts +180 -0
- package/app/src/cms/settings-languages.ts +125 -0
- package/app/src/cms/settings-nav.ts +102 -0
- package/app/src/cms/settings-network.ts +151 -0
- package/app/src/cms/settings-permalinks.ts +114 -0
- package/app/src/cms/settings-scroll.ts +10 -0
- package/app/src/cms/settings-search.ts +77 -0
- package/app/src/cms/settings-section.ts +38 -0
- package/app/src/cms/share.client.ts +27 -0
- package/app/src/cms/site-editing.ts +219 -0
- package/app/src/cms/site-editor.client.ts +1008 -0
- package/app/src/cms/site-editor.ts +99 -0
- package/app/src/cms/site-export.ts +60 -0
- package/app/src/cms/site-forms.ts +143 -0
- package/app/src/cms/site-import.ts +28 -0
- package/app/src/cms/site-session.ts +36 -0
- package/app/src/cms/site-taskbar.ts +77 -0
- package/app/src/cms/site-view.ts +1014 -0
- package/app/src/cms/site.ts +1322 -0
- package/app/src/cms/sitemaps.ts +131 -0
- package/app/src/cms/stat.client.ts +56 -0
- package/app/src/cms/style-controls.ts +252 -0
- package/app/src/cms/tabs.client.ts +36 -0
- package/app/src/cms/taskbar.ts +134 -0
- package/app/src/cms/term-icons.ts +10 -0
- package/app/src/cms/traffic.ts +26 -0
- package/app/src/cms/ui.ts +170 -0
- package/app/src/cms/updates.ts +124 -0
- package/app/src/cms/uploads.ts +26 -0
- package/app/src/cms/worker.ts +13 -0
- package/app/src/config/auth.ts +30 -0
- package/app/src/config/cms.ts +18 -0
- package/app/src/dashboard/access.ts +344 -0
- package/app/src/dashboard/agent-icons.ts +44 -0
- package/app/src/dashboard/app-passwords.ts +74 -0
- package/app/src/dashboard/avatar-field.ts +58 -0
- package/app/src/dashboard/bulk.ts +53 -0
- package/app/src/dashboard/head.ts +29 -0
- package/app/src/dashboard/icons.ts +15 -0
- package/app/src/dashboard/list-table.ts +120 -0
- package/app/src/dashboard/modules/roles.ts +15 -0
- package/app/src/dashboard/modules/sessions.ts +15 -0
- package/app/src/dashboard/modules/settings.ts +15 -0
- package/app/src/dashboard/modules/users.ts +18 -0
- package/app/src/dashboard/page.ts +67 -0
- package/app/src/dashboard/registry.ts +13 -0
- package/app/src/dashboard/session-list.ts +98 -0
- package/app/src/dashboard/tabs.ts +26 -0
- package/app/src/dashboard/time-ago.ts +16 -0
- package/app/src/dashboard/types.ts +40 -0
- package/app/src/dashboard/user-sections.ts +172 -0
- package/app/src/lib/permissions.ts +84 -0
- package/app/src/middlewares/auth.ts +117 -0
- package/app/src/pages/(site)/[...path]/index.ts +609 -0
- package/app/src/pages/(site)/feed/[...rest]/index.ts +13 -0
- package/app/src/pages/(site)/feed/index.ts +12 -0
- package/app/src/pages/(site)/index.ts +11 -0
- package/app/src/pages/(site)/indexnow/[file]/index.ts +18 -0
- package/app/src/pages/(site)/layout.ts +219 -0
- package/app/src/pages/(site)/llms.txt/index.ts +23 -0
- package/app/src/pages/(site)/manifest.webmanifest/index.ts +29 -0
- package/app/src/pages/(site)/media/[id]/[name]/index.ts +59 -0
- package/app/src/pages/(site)/preview/[collection]/[id]/index.ts +115 -0
- package/app/src/pages/(site)/robots.txt/index.ts +29 -0
- package/app/src/pages/(site)/search/index.ts +36 -0
- package/app/src/pages/(site)/sitemap.xml/index.ts +26 -0
- package/app/src/pages/(site)/sitemaps/[file]/index.ts +33 -0
- package/app/src/pages/api/auth/session.ts +48 -0
- package/app/src/pages/api/cms/appearance/areas/[name].ts +12 -0
- package/app/src/pages/api/cms/appearance/areas/index.ts +6 -0
- package/app/src/pages/api/cms/appearance/locations/[location].ts +6 -0
- package/app/src/pages/api/cms/appearance/locations/index.ts +6 -0
- package/app/src/pages/api/cms/appearance/menus/[id].ts +12 -0
- package/app/src/pages/api/cms/appearance/menus/index.ts +13 -0
- package/app/src/pages/api/cms/appearance/themes/[name]/activate.ts +6 -0
- package/app/src/pages/api/cms/appearance/themes/index.ts +6 -0
- package/app/src/pages/api/cms/cache/purge.ts +6 -0
- package/app/src/pages/api/cms/collections/index.ts +6 -0
- package/app/src/pages/api/cms/commands/[plugin]/[command].ts +26 -0
- package/app/src/pages/api/cms/comments/[id].ts +9 -0
- package/app/src/pages/api/cms/comments/index.ts +126 -0
- package/app/src/pages/api/cms/comments/queue.ts +6 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/autosave.ts +27 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/blocks/[block].ts +16 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/notes.ts +18 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/publish.ts +11 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/revisions/[revision]/index.ts +6 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/revisions/[revision]/restore.ts +6 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/revisions/index.ts +6 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/unpublish.ts +6 -0
- package/app/src/pages/api/cms/content/[collection]/[entry].ts +42 -0
- package/app/src/pages/api/cms/content/[collection]/index.ts +24 -0
- package/app/src/pages/api/cms/export/[collection].ts +37 -0
- package/app/src/pages/api/cms/forms/[slug]/index.ts +173 -0
- package/app/src/pages/api/cms/forms/[slug]/submissions/[submission]/files/[file].ts +25 -0
- package/app/src/pages/api/cms/forms/[slug]/submissions/export.ts +34 -0
- package/app/src/pages/api/cms/forms/[slug]/submissions/index.ts +24 -0
- package/app/src/pages/api/cms/import/[collection].ts +23 -0
- package/app/src/pages/api/cms/mcp.ts +29 -0
- package/app/src/pages/api/cms/me/index.ts +6 -0
- package/app/src/pages/api/cms/me/recent-blocks.ts +37 -0
- package/app/src/pages/api/cms/me/tokens/[id].ts +6 -0
- package/app/src/pages/api/cms/me/tokens/index.ts +13 -0
- package/app/src/pages/api/cms/media/[id].ts +6 -0
- package/app/src/pages/api/cms/media.ts +26 -0
- package/app/src/pages/api/cms/menus/[location].ts +14 -0
- package/app/src/pages/api/cms/network/sites/[id]/export.ts +15 -0
- package/app/src/pages/api/cms/network/sites/[id]/index.ts +9 -0
- package/app/src/pages/api/cms/network/sites/index.ts +14 -0
- package/app/src/pages/api/cms/notes/[id].ts +13 -0
- package/app/src/pages/api/cms/notes/index.ts +6 -0
- package/app/src/pages/api/cms/payments/webhook.ts +28 -0
- package/app/src/pages/api/cms/plugins/[name]/grant.ts +6 -0
- package/app/src/pages/api/cms/plugins/[name]/revoke.ts +6 -0
- package/app/src/pages/api/cms/plugins/index.ts +6 -0
- package/app/src/pages/api/cms/recovery.ts +29 -0
- package/app/src/pages/api/cms/redirects/index.ts +9 -0
- package/app/src/pages/api/cms/roles/index.ts +6 -0
- package/app/src/pages/api/cms/schema/[collection].ts +13 -0
- package/app/src/pages/api/cms/search.ts +16 -0
- package/app/src/pages/api/cms/settings/[group].ts +9 -0
- package/app/src/pages/api/cms/settings/index.ts +9 -0
- package/app/src/pages/api/cms/site-export.ts +34 -0
- package/app/src/pages/api/cms/taxonomies/index.ts +6 -0
- package/app/src/pages/api/cms/terms/[taxonomy]/[id].ts +12 -0
- package/app/src/pages/api/cms/terms/[taxonomy]/index.ts +9 -0
- package/app/src/pages/api/cms/uploads/[id]/complete.ts +15 -0
- package/app/src/pages/api/cms/uploads/[id]/index.ts +15 -0
- package/app/src/pages/api/cms/uploads/index.ts +26 -0
- package/app/src/pages/api/cms/users/[id]/index.ts +12 -0
- package/app/src/pages/api/cms/users/[id]/meta.ts +40 -0
- package/app/src/pages/api/cms/users/index.ts +12 -0
- package/app/src/pages/api/cms/webhooks/[id].ts +6 -0
- package/app/src/pages/api/cms/webhooks/index.ts +9 -0
- package/app/src/pages/auth/[provider]/callback.ts +11 -0
- package/app/src/pages/auth/[provider]/redirect.ts +9 -0
- package/app/src/pages/auth/forgot-password/index.ts +75 -0
- package/app/src/pages/auth/layout.ts +32 -0
- package/app/src/pages/auth/login/index.ts +198 -0
- package/app/src/pages/auth/magic/index.ts +68 -0
- package/app/src/pages/auth/register/index.ts +117 -0
- package/app/src/pages/auth/reset-password/index.ts +65 -0
- package/app/src/pages/auth/setup/index.ts +194 -0
- package/app/src/pages/auth/two-factor/index.ts +67 -0
- package/app/src/pages/auth/verify/index.ts +62 -0
- package/app/src/pages/dashboard/(cms)/appearance/customize/index.ts +263 -0
- package/app/src/pages/dashboard/(cms)/appearance/dashboard-menu/index.ts +241 -0
- package/app/src/pages/dashboard/(cms)/appearance/index.ts +89 -0
- package/app/src/pages/dashboard/(cms)/appearance/menus/[id]/index.ts +697 -0
- package/app/src/pages/dashboard/(cms)/appearance/menus/index.ts +145 -0
- package/app/src/pages/dashboard/(cms)/appearance/widgets/index.ts +279 -0
- package/app/src/pages/dashboard/(cms)/blocks/index.ts +84 -0
- package/app/src/pages/dashboard/(cms)/calendar/index.ts +92 -0
- package/app/src/pages/dashboard/(cms)/collections/[name]/index.ts +525 -0
- package/app/src/pages/dashboard/(cms)/collections/index.ts +72 -0
- package/app/src/pages/dashboard/(cms)/collections/new/index.ts +66 -0
- package/app/src/pages/dashboard/(cms)/comments/index.ts +237 -0
- package/app/src/pages/dashboard/(cms)/content/[collection]/[id]/index.ts +2382 -0
- package/app/src/pages/dashboard/(cms)/content/[collection]/[id]/revisions/index.ts +126 -0
- package/app/src/pages/dashboard/(cms)/content/[collection]/index.ts +693 -0
- package/app/src/pages/dashboard/(cms)/field-groups/[id]/index.ts +193 -0
- package/app/src/pages/dashboard/(cms)/field-groups/index.ts +65 -0
- package/app/src/pages/dashboard/(cms)/forms/[id]/submissions/[submission]/index.ts +279 -0
- package/app/src/pages/dashboard/(cms)/forms/[id]/submissions/index.ts +170 -0
- package/app/src/pages/dashboard/(cms)/forms/index.ts +171 -0
- package/app/src/pages/dashboard/(cms)/media/[id]/index.ts +317 -0
- package/app/src/pages/dashboard/(cms)/media/index.ts +156 -0
- package/app/src/pages/dashboard/(cms)/media/new/index.ts +9 -0
- package/app/src/pages/dashboard/(cms)/media/summary/index.ts +74 -0
- package/app/src/pages/dashboard/(cms)/my-sites/index.ts +63 -0
- package/app/src/pages/dashboard/(cms)/network/index.ts +53 -0
- package/app/src/pages/dashboard/(cms)/network/plugins/index.ts +110 -0
- package/app/src/pages/dashboard/(cms)/network/sites/[id]/index.ts +243 -0
- package/app/src/pages/dashboard/(cms)/network/sites/index.ts +186 -0
- package/app/src/pages/dashboard/(cms)/network/sites/new/index.ts +77 -0
- package/app/src/pages/dashboard/(cms)/network/themes/index.ts +82 -0
- package/app/src/pages/dashboard/(cms)/network/updates/index.ts +48 -0
- package/app/src/pages/dashboard/(cms)/network/users/[id]/index.ts +176 -0
- package/app/src/pages/dashboard/(cms)/network/users/index.ts +174 -0
- package/app/src/pages/dashboard/(cms)/network/users/new/index.ts +66 -0
- package/app/src/pages/dashboard/(cms)/plugins/index.ts +172 -0
- package/app/src/pages/dashboard/(cms)/profile/public/index.ts +105 -0
- package/app/src/pages/dashboard/(cms)/registrations/index.ts +70 -0
- package/app/src/pages/dashboard/(cms)/settings/index.ts +359 -0
- package/app/src/pages/dashboard/(cms)/settings/json/index.ts +202 -0
- package/app/src/pages/dashboard/(cms)/settings/layout.ts +67 -0
- package/app/src/pages/dashboard/(cms)/taxonomies/[name]/index.ts +85 -0
- package/app/src/pages/dashboard/(cms)/taxonomies/index.ts +98 -0
- package/app/src/pages/dashboard/(cms)/terms/[taxonomy]/[id]/index.ts +244 -0
- package/app/src/pages/dashboard/(cms)/terms/[taxonomy]/index.ts +148 -0
- package/app/src/pages/dashboard/(cms)/tools/activity/index.ts +94 -0
- package/app/src/pages/dashboard/(cms)/tools/automations/index.ts +131 -0
- package/app/src/pages/dashboard/(cms)/tools/cache/index.ts +92 -0
- package/app/src/pages/dashboard/(cms)/tools/export/index.ts +99 -0
- package/app/src/pages/dashboard/(cms)/tools/health/index.ts +189 -0
- package/app/src/pages/dashboard/(cms)/tools/jobs/index.ts +93 -0
- package/app/src/pages/dashboard/(cms)/tools/links/index.ts +115 -0
- package/app/src/pages/dashboard/(cms)/tools/redirects/index.ts +161 -0
- package/app/src/pages/dashboard/(cms)/tools/replace/index.ts +124 -0
- package/app/src/pages/dashboard/(cms)/tools/schema/index.ts +54 -0
- package/app/src/pages/dashboard/(cms)/tools/seo/index.ts +156 -0
- package/app/src/pages/dashboard/(cms)/tools/updates/index.ts +114 -0
- package/app/src/pages/dashboard/(cms)/tools/webhooks/index.ts +182 -0
- package/app/src/pages/dashboard/index.ts +214 -0
- package/app/src/pages/dashboard/layout.ts +320 -0
- package/app/src/pages/dashboard/profile/index.ts +211 -0
- package/app/src/pages/dashboard/profile/security/index.ts +255 -0
- package/app/src/pages/dashboard/roles/[id]/index.ts +116 -0
- package/app/src/pages/dashboard/roles/index.ts +134 -0
- package/app/src/pages/dashboard/roles/new/index.ts +95 -0
- package/app/src/pages/dashboard/sessions/index.ts +105 -0
- package/app/src/pages/dashboard/users/[id]/index.ts +472 -0
- package/app/src/pages/dashboard/users/index.ts +299 -0
- package/app/src/pages/dashboard/users/new/index.ts +123 -0
- package/app/src/passkeys.client.ts +18 -0
- package/app/src/plugins/default-theme/assets/cover.svg +31 -0
- package/app/src/plugins/default-theme/assets/logo.svg +8 -0
- package/app/src/plugins/default-theme/parts/comments.ts +66 -0
- package/app/src/plugins/default-theme/parts/list.ts +38 -0
- package/app/src/plugins/default-theme/parts/media.ts +15 -0
- package/app/src/plugins/default-theme/parts/options.ts +45 -0
- package/app/src/plugins/default-theme/plugin.json +275 -0
- package/app/src/plugins/default-theme/templates/archive.ts +14 -0
- package/app/src/plugins/default-theme/templates/entry-blank.ts +13 -0
- package/app/src/plugins/default-theme/templates/entry.ts +27 -0
- package/app/src/plugins/default-theme/templates/home.ts +8 -0
- package/app/src/plugins/default-theme/templates/layout.ts +40 -0
- package/app/src/plugins/default-theme/templates/not-found.ts +10 -0
- package/app/src/plugins/default-theme/templates/search.ts +32 -0
- package/app/src/services/rbac.ts +65 -0
- package/app/src/services/roles.ts +89 -0
- package/app/src/services/users.ts +173 -0
- package/package.json +114 -2
- package/src/automations.ts +95 -0
- package/src/bindings.ts +138 -0
- package/src/block-references.ts +239 -0
- package/src/block-shape.ts +155 -0
- package/src/blocks.ts +1157 -0
- package/src/cache.ts +54 -0
- package/src/checks.ts +198 -0
- package/src/cloudflare-workers.d.ts +13 -0
- package/src/cloudflare.ts +61 -0
- package/src/collab.ts +372 -0
- package/src/collections.ts +421 -0
- package/src/comments.ts +46 -0
- package/src/cron.ts +95 -0
- package/src/dashboard-menu.ts +105 -0
- package/src/diff.ts +113 -0
- package/src/editor-layout.ts +316 -0
- package/src/errors.ts +50 -0
- package/src/field-groups.ts +498 -0
- package/src/fields.ts +411 -0
- package/src/form-builder.ts +1053 -0
- package/src/forms.ts +109 -0
- package/src/highlight.ts +134 -0
- package/src/hooks.ts +510 -0
- package/src/icon-catalog.ts +55 -0
- package/src/icons.ts +128 -0
- package/src/images.ts +149 -0
- package/src/index.ts +100 -0
- package/src/isolate-core.ts +245 -0
- package/src/isolate.ts +19 -0
- package/src/isolation.ts +69 -0
- package/src/mail.ts +182 -0
- package/src/manifest.ts +476 -0
- package/src/media.ts +193 -0
- package/src/menus.ts +287 -0
- package/src/module.ts +32 -0
- package/src/modules/content.ts +64 -0
- package/src/modules/forms.ts +35 -0
- package/src/node.ts +66 -0
- package/src/notes.ts +237 -0
- package/src/permissions.ts +139 -0
- package/src/plugin-settings.ts +114 -0
- package/src/records.ts +56 -0
- package/src/redirects.ts +59 -0
- package/src/resource.ts +245 -0
- package/src/richtext.ts +402 -0
- package/src/schema-json.ts +112 -0
- package/src/search.ts +89 -0
- package/src/seo.ts +477 -0
- package/src/server/accounts.ts +418 -0
- package/src/server/ai.ts +33 -0
- package/src/server/api-tokens.ts +91 -0
- package/src/server/areas.ts +116 -0
- package/src/server/audit.ts +94 -0
- package/src/server/auth.ts +89 -0
- package/src/server/automations.ts +190 -0
- package/src/server/autosaves.ts +69 -0
- package/src/server/brand-icons.ts +50 -0
- package/src/server/brands.ts +86 -0
- package/src/server/budget.ts +97 -0
- package/src/server/cache.ts +104 -0
- package/src/server/capabilities.ts +333 -0
- package/src/server/cloudflare.ts +92 -0
- package/src/server/comments.ts +237 -0
- package/src/server/drafts.ts +176 -0
- package/src/server/field-groups.ts +88 -0
- package/src/server/files.ts +780 -0
- package/src/server/forms.ts +726 -0
- package/src/server/handoffs.ts +107 -0
- package/src/server/host-schema.ts +312 -0
- package/src/server/host.ts +2892 -0
- package/src/server/images.ts +34 -0
- package/src/server/index.ts +59 -0
- package/src/server/indexnow.ts +91 -0
- package/src/server/isolation.ts +183 -0
- package/src/server/locked.ts +45 -0
- package/src/server/mail.ts +93 -0
- package/src/server/markdown.ts +24 -0
- package/src/server/menus.ts +286 -0
- package/src/server/network-policy.ts +60 -0
- package/src/server/network.ts +665 -0
- package/src/server/notes.ts +275 -0
- package/src/server/outbox.ts +213 -0
- package/src/server/path-moves.ts +33 -0
- package/src/server/payments.ts +59 -0
- package/src/server/previews.ts +62 -0
- package/src/server/purge.ts +140 -0
- package/src/server/reconcile.ts +38 -0
- package/src/server/redirects.ts +183 -0
- package/src/server/repository.ts +1107 -0
- package/src/server/schedules.ts +105 -0
- package/src/server/schema.ts +562 -0
- package/src/server/security.ts +391 -0
- package/src/server/seed.ts +52 -0
- package/src/server/shared-fields.ts +34 -0
- package/src/server/site-export.ts +151 -0
- package/src/server/site-import.ts +482 -0
- package/src/server/site-search.ts +289 -0
- package/src/server/site-settings.ts +286 -0
- package/src/server/sites.ts +243 -0
- package/src/server/stores.ts +314 -0
- package/src/server/stripe.ts +173 -0
- package/src/server/taxonomies.ts +415 -0
- package/src/server/tokens.ts +25 -0
- package/src/server/traffic.ts +118 -0
- package/src/server/users.ts +653 -0
- package/src/server/webhooks.ts +245 -0
- package/src/settings-controls.ts +54 -0
- package/src/settings-document.ts +111 -0
- package/src/settings.ts +426 -0
- package/src/storage/cloudflare.ts +94 -0
- package/src/storage/index.ts +30 -0
- package/src/storage/node.ts +114 -0
- package/src/taxonomy.ts +51 -0
- package/src/theme.ts +1135 -0
- package/src/to-markdown.ts +179 -0
- package/src/updates.ts +126 -0
- package/src/version.ts +2 -0
- package/src/vite.d.ts +25 -0
- package/src/vite.js +199 -0
- package/src/webhooks.ts +107 -0
package/src/redirects.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/** Redirects: their shape and validation. Client-safe; the host stores and matches them. */
|
|
2
|
+
export const REDIRECT_STATUSES = Object.freeze([301, 302, 307, 308, 410] as const);
|
|
3
|
+
export type RedirectStatus = (typeof REDIRECT_STATUSES)[number];
|
|
4
|
+
|
|
5
|
+
export interface Redirect {
|
|
6
|
+
readonly id: string;
|
|
7
|
+
/** A path, or a prefix ending in `/*`. */
|
|
8
|
+
readonly source: string;
|
|
9
|
+
/** A path or an absolute URL; a prefix target can end in `/*` to keep the rest. Empty for 410. */
|
|
10
|
+
readonly target: string;
|
|
11
|
+
readonly status: RedirectStatus;
|
|
12
|
+
readonly prefix: boolean;
|
|
13
|
+
/** Recorded by the host when a URL changed, or made by a person. */
|
|
14
|
+
readonly kind: 'auto' | 'manual';
|
|
15
|
+
readonly note: string;
|
|
16
|
+
readonly hits: number;
|
|
17
|
+
readonly lastHitAt: number | null;
|
|
18
|
+
readonly createdAt: number;
|
|
19
|
+
readonly updatedAt: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface RedirectInput {
|
|
23
|
+
readonly source: string;
|
|
24
|
+
readonly target: string;
|
|
25
|
+
readonly status?: RedirectStatus;
|
|
26
|
+
readonly note?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** A path a redirect can start from. */
|
|
30
|
+
export const REDIRECT_PATH = /^\/[^\s?#]{0,499}$/;
|
|
31
|
+
const PATH = REDIRECT_PATH;
|
|
32
|
+
const URL_TARGET = /^https?:\/\/[^\s]{1,2000}$/;
|
|
33
|
+
|
|
34
|
+
/** A request path without its trailing slash, as sources are stored. */
|
|
35
|
+
export function redirectPath(path: string): string {
|
|
36
|
+
const clean = path.split(/[?#]/)[0]!;
|
|
37
|
+
return clean.length > 1 ? clean.replace(/\/+$/, '') : clean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Problems with a redirect; empty when valid. */
|
|
41
|
+
export function redirectProblems(input: RedirectInput): string[] {
|
|
42
|
+
const problems: string[] = [];
|
|
43
|
+
const status = input.status ?? 301;
|
|
44
|
+
const source = typeof input.source === 'string' ? redirectPath(input.source.trim()) : '';
|
|
45
|
+
const prefix = source.endsWith('/*');
|
|
46
|
+
if (!PATH.test(source) || source === '/' || source === '/*' || (source.includes('*') && !prefix) || source.slice(0, -2).includes('*')) {
|
|
47
|
+
problems.push('The source is a path such as /old-page, or a prefix such as /old/*.');
|
|
48
|
+
}
|
|
49
|
+
if (!REDIRECT_STATUSES.includes(status)) problems.push('The type is 301, 302, 307, 308 or 410.');
|
|
50
|
+
const target = typeof input.target === 'string' ? input.target.trim() : '';
|
|
51
|
+
if (status !== 410) {
|
|
52
|
+
if (!(PATH.test(target) || URL_TARGET.test(target)) || (target.includes('*') && !(prefix && target.endsWith('/*') && !target.slice(0, -2).includes('*')))) {
|
|
53
|
+
problems.push('The target is a path such as /new-page or a full URL; a prefix target can end in /*.');
|
|
54
|
+
} else if (/^\/[/\\]/.test(target)) problems.push('The target is a path on this site, such as /new-page, or a full URL.');
|
|
55
|
+
else if (redirectPath(target) === source) problems.push('The target is the source.');
|
|
56
|
+
}
|
|
57
|
+
if (typeof input.note === 'string' && input.note.length > 200) problems.push('The note can be at most 200 characters.');
|
|
58
|
+
return problems;
|
|
59
|
+
}
|
package/src/resource.ts
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import type { Block } from './blocks';
|
|
2
|
+
import { field, fieldProblems, validateValue, type FieldDeclaration } from './fields';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Who may perform an action.
|
|
6
|
+
* - `public`: anyone, including anonymous visitors.
|
|
7
|
+
* - `authenticated`: any signed-in user.
|
|
8
|
+
* - `owner`: the user who created the record (requires `ownership`).
|
|
9
|
+
* - `{ permission }`: users whose roles grant the permission.
|
|
10
|
+
* - `{ where }`: anyone, on records whose fields equal these values, such as published posts.
|
|
11
|
+
* - `{ any: [...] }`: the first rule that allows wins; owner and where rules combine.
|
|
12
|
+
* - `none`: nobody, except the system principal.
|
|
13
|
+
*/
|
|
14
|
+
export type AccessRule = 'public' | 'authenticated' | 'owner' | 'none' | { readonly permission: string }
|
|
15
|
+
| { readonly where: { readonly [field: string]: string | number | boolean } } | { readonly any: readonly AccessRule[] };
|
|
16
|
+
|
|
17
|
+
export type ResourceAction = 'read' | 'create' | 'update' | 'delete';
|
|
18
|
+
|
|
19
|
+
export type ResourceAccess = { readonly [A in ResourceAction]?: AccessRule };
|
|
20
|
+
|
|
21
|
+
export interface IndexDeclaration {
|
|
22
|
+
readonly name: string;
|
|
23
|
+
readonly fields: readonly string[];
|
|
24
|
+
readonly unique?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Explicit, versioned schema change. Generated upgrades are additive; these run once each, in version order. */
|
|
28
|
+
export type MigrationStep =
|
|
29
|
+
/** Set a value where the field is missing or null. */
|
|
30
|
+
| { readonly version: number; readonly kind: 'backfill'; readonly field: string; readonly value: string | number | boolean }
|
|
31
|
+
/** Copy one field into another where the target is missing. Keep the old field declared until a later `drop`. */
|
|
32
|
+
| { readonly version: number; readonly kind: 'rename'; readonly from: string; readonly to: string }
|
|
33
|
+
/** Apply the declaration's stricter definition of a field (required, check). Fails while records violate it. */
|
|
34
|
+
| { readonly version: number; readonly kind: 'tighten'; readonly field: string }
|
|
35
|
+
/** Remove a field that the declaration no longer lists, from every record and the schema. */
|
|
36
|
+
| { readonly version: number; readonly kind: 'drop'; readonly field: string };
|
|
37
|
+
|
|
38
|
+
export interface ResourceDeclaration {
|
|
39
|
+
/** Lowercase name, unique within its owner, such as `posts`. */
|
|
40
|
+
readonly name: string;
|
|
41
|
+
/** Owner namespace: `cms`, `app` or a plugin name. Assigned by the host when omitted. */
|
|
42
|
+
readonly owner?: string;
|
|
43
|
+
readonly label?: string;
|
|
44
|
+
/** Field shown as the record title in the dashboard. */
|
|
45
|
+
readonly titleField?: string;
|
|
46
|
+
readonly fields: { readonly [name: string]: FieldDeclaration };
|
|
47
|
+
readonly indexes?: readonly IndexDeclaration[];
|
|
48
|
+
readonly access?: ResourceAccess;
|
|
49
|
+
/** Record the creating user and enable `owner` rules. */
|
|
50
|
+
readonly ownership?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* A multiple string field of user IDs who own the record beside its creator, such as an entry's
|
|
53
|
+
* `authors`: `owner` rules match them too. A record without any reads as its creator's alone.
|
|
54
|
+
*/
|
|
55
|
+
readonly coOwners?: string;
|
|
56
|
+
/** Keep a revision snapshot of every write. Default true. */
|
|
57
|
+
readonly revisions?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Store records in a document table without `STRICT`: only system fields are typed in the
|
|
60
|
+
* database and the host validates the declared fields. Adding or changing a field needs no
|
|
61
|
+
* DDL, only index changes. Collections use this.
|
|
62
|
+
*/
|
|
63
|
+
readonly schemaless?: boolean;
|
|
64
|
+
readonly migrations?: readonly MigrationStep[];
|
|
65
|
+
/**
|
|
66
|
+
* The field groups' blocks that lay the fields out, for the conditions on them: a field a
|
|
67
|
+
* condition hides is not required and is cleared on write. Set by the host for collections.
|
|
68
|
+
*/
|
|
69
|
+
readonly layout?: readonly Block[];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface Resource extends ResourceDeclaration {
|
|
73
|
+
readonly owner: string;
|
|
74
|
+
/** `owner/name`. */
|
|
75
|
+
readonly id: string;
|
|
76
|
+
/** RomeDB collection that stores the records. */
|
|
77
|
+
readonly storage: string;
|
|
78
|
+
readonly access: { readonly [A in ResourceAction]: AccessRule };
|
|
79
|
+
readonly ownership: boolean;
|
|
80
|
+
readonly revisions: boolean;
|
|
81
|
+
readonly schemaless: boolean;
|
|
82
|
+
readonly indexes: readonly IndexDeclaration[];
|
|
83
|
+
readonly migrations: readonly MigrationStep[];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export const RESOURCE_NAME = /^[a-z][a-z0-9_]{0,40}$/;
|
|
87
|
+
export const OWNER_NAME = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
|
|
88
|
+
/** Host fields on every resource record, stored next to the declared fields. */
|
|
89
|
+
export const SYSTEM_FIELDS = ['_rev', '_op', '_createdAt', '_updatedAt', '_owner'] as const;
|
|
90
|
+
|
|
91
|
+
export class ResourceDeclarationError extends Error {
|
|
92
|
+
readonly problems: readonly string[];
|
|
93
|
+
constructor(resource: string, problems: readonly string[]) {
|
|
94
|
+
super(`Invalid resource ${resource}: ${problems.join(' ')}`);
|
|
95
|
+
this.name = 'ResourceDeclarationError';
|
|
96
|
+
this.problems = problems;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Declare a resource. The declaration is plain data, so it can travel in a plugin manifest. */
|
|
101
|
+
export function defineResource<const D extends ResourceDeclaration>(declaration: D): D {
|
|
102
|
+
const problems = resourceProblems(declaration);
|
|
103
|
+
if (problems.length) throw new ResourceDeclarationError(declaration.name ?? '(unnamed)', problems);
|
|
104
|
+
return declaration;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export { field };
|
|
108
|
+
|
|
109
|
+
export function resourceProblems(declaration: ResourceDeclaration): string[] {
|
|
110
|
+
const problems: string[] = [];
|
|
111
|
+
if (typeof declaration?.name !== 'string' || !RESOURCE_NAME.test(declaration.name) || declaration.name.includes('__')) problems.push('name must be lowercase letters, digits and single underscores, starting with a letter.');
|
|
112
|
+
if (declaration.owner !== undefined && (!OWNER_NAME.test(declaration.owner) || declaration.owner.length > 64)) problems.push('owner must be a plugin name.');
|
|
113
|
+
if (!declaration.fields || typeof declaration.fields !== 'object') return [...problems, 'fields are required.'];
|
|
114
|
+
const names = Object.keys(declaration.fields);
|
|
115
|
+
if (!names.length) problems.push('declare at least one field.');
|
|
116
|
+
// Field groups add up on a collection.
|
|
117
|
+
const limit = declaration.schemaless ? 160 : 24;
|
|
118
|
+
if (names.length > limit) problems.push(`declare at most ${limit} fields per resource.`);
|
|
119
|
+
const lower = new Set<string>();
|
|
120
|
+
for (const name of names) {
|
|
121
|
+
if (lower.has(name.toLowerCase())) problems.push(`field ${name} differs from another field only by case.`);
|
|
122
|
+
lower.add(name.toLowerCase());
|
|
123
|
+
problems.push(...fieldProblems(name, declaration.fields[name]!));
|
|
124
|
+
}
|
|
125
|
+
if (declaration.titleField !== undefined && !names.includes(declaration.titleField)) problems.push(`titleField ${declaration.titleField} is not a declared field.`);
|
|
126
|
+
for (const name of names) {
|
|
127
|
+
const from = declaration.fields[name]!.slugFrom;
|
|
128
|
+
if (from !== undefined && !['string', 'text'].includes(declaration.fields[from]?.kind as string)) problems.push(`field ${name}: slugFrom ${from} is not a declared string or text field.`);
|
|
129
|
+
for (const other of declaration.fields[name]!.uniqueBy ?? []) {
|
|
130
|
+
const scope = declaration.fields[other];
|
|
131
|
+
if (!scope || scope.multiple || ['json', 'vector', 'text', 'blocks', 'richtext', 'rows'].includes(scope.kind)) problems.push(`field ${name}: uniqueBy ${other} is not a declared single-value field.`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const searchable = names.filter(name => declaration.fields[name]!.search);
|
|
135
|
+
if (searchable.length > 16) problems.push('at most 16 fields can be searched.');
|
|
136
|
+
const indexNames = new Set<string>();
|
|
137
|
+
for (const index of declaration.indexes ?? []) {
|
|
138
|
+
if (!/^[a-z][a-z0-9_]{0,40}$/.test(index.name) || indexNames.has(index.name)) problems.push(`index ${index.name} needs a unique lowercase name.`);
|
|
139
|
+
indexNames.add(index.name);
|
|
140
|
+
if (!index.fields?.length || index.fields.length > 4) problems.push(`index ${index.name} needs 1-4 fields.`);
|
|
141
|
+
for (const name of index.fields ?? []) {
|
|
142
|
+
const declared = declaration.fields[name];
|
|
143
|
+
if (!declared && !(['_createdAt', '_updatedAt', '_owner'] as string[]).includes(name)) problems.push(`index ${index.name} names undeclared field ${name}.`);
|
|
144
|
+
else if (declared && (['json', 'vector', 'text'].includes(declared.kind) || declared.multiple)) problems.push(`index ${index.name} cannot include ${declared.multiple ? 'multiple' : declared.kind} field ${name}.`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (declaration.coOwners !== undefined) {
|
|
148
|
+
const declared = declaration.fields[declaration.coOwners];
|
|
149
|
+
if (declaration.ownership !== true || !declared || declared.kind !== 'string' || declared.multiple !== true || declared.media || declared.taxonomy) problems.push('coOwners names a multiple string field of user IDs and needs ownership: true.');
|
|
150
|
+
}
|
|
151
|
+
for (const action of Object.keys(declaration.access ?? {})) {
|
|
152
|
+
if (!['read', 'create', 'update', 'delete'].includes(action)) problems.push(`access.${action} is not an action.`);
|
|
153
|
+
else problems.push(...ruleProblems(`access.${action}`, declaration.access![action as ResourceAction]!, declaration.ownership === true, declaration.fields));
|
|
154
|
+
}
|
|
155
|
+
const versions = new Set<number>();
|
|
156
|
+
// Steps written before a later drop may name the dropped field.
|
|
157
|
+
const droppedAfter = (name: string, version: number) => (declaration.migrations ?? []).some(step => step.kind === 'drop' && step.field === name && step.version > version);
|
|
158
|
+
const known = (name: string, version: number) => Boolean(declaration.fields[name]) || droppedAfter(name, version);
|
|
159
|
+
for (const step of declaration.migrations ?? []) {
|
|
160
|
+
if (!Number.isSafeInteger(step.version) || step.version < 1 || versions.has(step.version)) problems.push('migration versions must be distinct positive integers.');
|
|
161
|
+
versions.add(step.version);
|
|
162
|
+
if (step.kind === 'backfill' || step.kind === 'tighten') {
|
|
163
|
+
if (!known(step.field, step.version)) problems.push(`migration ${step.version}: ${step.kind} names undeclared field ${step.field}.`);
|
|
164
|
+
} else if (step.kind === 'rename') {
|
|
165
|
+
if (!known(step.from, step.version) || !known(step.to, step.version)) problems.push(`migration ${step.version}: rename needs both ${step.from} and ${step.to} declared until a later drop.`);
|
|
166
|
+
else if (declaration.fields[step.from] && declaration.fields[step.to] && declaration.fields[step.from]!.kind !== declaration.fields[step.to]!.kind) problems.push(`migration ${step.version}: rename needs fields of the same kind.`);
|
|
167
|
+
} else if (step.kind === 'drop') {
|
|
168
|
+
if (declaration.fields[step.field]) problems.push(`migration ${step.version}: drop names ${step.field}, which is still declared.`);
|
|
169
|
+
if (!/^[a-z][a-zA-Z0-9]{0,62}$/.test(step.field)) problems.push(`migration ${step.version}: drop needs a field name.`);
|
|
170
|
+
} else problems.push(`migration ${(step as { version: number }).version}: unknown kind.`);
|
|
171
|
+
}
|
|
172
|
+
return problems;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function ruleProblems(at: string, rule: AccessRule, ownership: boolean, fields: ResourceDeclaration['fields'], depth = 0): string[] {
|
|
176
|
+
if (depth > 4) return [`${at}: rules nest too deeply.`];
|
|
177
|
+
if (rule === 'public' || rule === 'authenticated' || rule === 'none') return [];
|
|
178
|
+
if (rule === 'owner') return ownership ? [] : [`${at}: owner rules need ownership: true.`];
|
|
179
|
+
if (typeof rule === 'object' && rule && 'permission' in rule) return /^[a-z][a-z0-9:/._*-]{0,127}$/.test(rule.permission) ? [] : [`${at}: invalid permission ${rule.permission}.`];
|
|
180
|
+
if (typeof rule === 'object' && rule && 'where' in rule && rule.where && typeof rule.where === 'object') {
|
|
181
|
+
const entries = Object.entries(rule.where);
|
|
182
|
+
if (!entries.length || entries.length > 4) return [`${at}: where rules name 1-4 fields.`];
|
|
183
|
+
return entries.flatMap(([name, value]) => {
|
|
184
|
+
const declared = fields[name];
|
|
185
|
+
if (!declared || !['string', 'enum', 'integer', 'boolean'].includes(declared.kind)) return [`${at}: where names ${name}, which is not a declared string, enum, integer or boolean field.`];
|
|
186
|
+
const error = validateValue(name, declared, value);
|
|
187
|
+
return error ? [`${at}: where ${name} ${error}`] : [];
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
if (typeof rule === 'object' && rule && 'any' in rule && Array.isArray(rule.any) && rule.any.length) return rule.any.flatMap(entry => ruleProblems(at, entry, ownership, fields, depth + 1));
|
|
191
|
+
return [`${at}: unknown rule.`];
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** Collection name for a resource: `r__<owner>__<name>`, with hyphens as underscores. Injective for valid names. */
|
|
195
|
+
export function storageName(owner: string, name: string): string {
|
|
196
|
+
return `r__${owner.replaceAll('-', '_')}__${name}`;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** Permission for an action on a resource: `cms/posts:update`. */
|
|
200
|
+
export function permissionFor(resourceId: string, action: ResourceAction): string {
|
|
201
|
+
return `${resourceId}:${action}`;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** Normalize a declaration for the host: owner, ID, storage name and default rules. */
|
|
205
|
+
export function resolveResource(declaration: ResourceDeclaration, owner = declaration.owner ?? 'app'): Resource {
|
|
206
|
+
const problems = resourceProblems({ ...declaration, owner });
|
|
207
|
+
if (problems.length) throw new ResourceDeclarationError(`${owner}/${declaration.name}`, problems);
|
|
208
|
+
const id = `${owner}/${declaration.name}`;
|
|
209
|
+
const access = Object.fromEntries((['read', 'create', 'update', 'delete'] as const).map(action =>
|
|
210
|
+
[action, declaration.access?.[action] ?? { permission: permissionFor(id, action) }])) as Resource['access'];
|
|
211
|
+
return Object.freeze({
|
|
212
|
+
...declaration,
|
|
213
|
+
owner,
|
|
214
|
+
id,
|
|
215
|
+
storage: storageName(owner, declaration.name),
|
|
216
|
+
access,
|
|
217
|
+
ownership: declaration.ownership === true,
|
|
218
|
+
revisions: declaration.revisions !== false,
|
|
219
|
+
schemaless: declaration.schemaless === true,
|
|
220
|
+
indexes: declaration.indexes ?? [],
|
|
221
|
+
migrations: [...(declaration.migrations ?? [])].sort((a, b) => a.version - b.version),
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** Canonical JSON with sorted keys, for hashing declarations. */
|
|
226
|
+
export function canonicalJson(value: unknown): string {
|
|
227
|
+
if (value === null || typeof value !== 'object') return JSON.stringify(value);
|
|
228
|
+
if (Array.isArray(value)) return `[${value.map(canonicalJson).join(',')}]`;
|
|
229
|
+
return `{${Object.keys(value).sort().filter(key => (value as Record<string, unknown>)[key] !== undefined)
|
|
230
|
+
.map(key => `${JSON.stringify(key)}:${canonicalJson((value as Record<string, unknown>)[key])}`).join(',')}}`;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const HASHES = new WeakMap<Resource, Promise<string>>();
|
|
234
|
+
|
|
235
|
+
/** SHA-256 of the canonical declaration, recorded in the migration ledger. Hashed once per declaration object: the host asks for it on every status check. */
|
|
236
|
+
export function declarationHash(resource: Resource): Promise<string> {
|
|
237
|
+
let hash = HASHES.get(resource);
|
|
238
|
+
if (!hash) {
|
|
239
|
+
const { storage: _storage, ...declaration } = resource;
|
|
240
|
+
hash = crypto.subtle.digest('SHA-256', new TextEncoder().encode(canonicalJson(declaration))).then(digest => [...new Uint8Array(digest)].map(byte => byte.toString(16).padStart(2, '0')).join(''));
|
|
241
|
+
hash.catch(() => HASHES.delete(resource));
|
|
242
|
+
HASHES.set(resource, hash);
|
|
243
|
+
}
|
|
244
|
+
return hash;
|
|
245
|
+
}
|