@kardalum/plugin-sdk 0.19.0 → 0.21.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/CHANGELOG.md +281 -0
- package/README.md +19 -0
- package/dist/admin-section-registry.d.ts +48 -1
- package/dist/admin-section-registry.js +90 -0
- package/dist/built-in-editor-ids.d.ts +1 -1
- package/dist/built-in-editor-ids.js +2 -20
- package/dist/built-in-settings-schemas.d.ts +10 -0
- package/dist/built-in-settings-schemas.js +86 -0
- package/dist/built-in-value-schemas.js +35 -0
- package/dist/built-ins.js +38 -7
- package/dist/capabilities.d.ts +11 -1
- package/dist/capabilities.js +101 -4
- package/dist/cli.d.ts +66 -0
- package/dist/cli.js +22 -0
- package/dist/consent-entry.d.ts +11 -0
- package/dist/consent-entry.js +18 -0
- package/dist/content-library.d.ts +102 -0
- package/dist/content-library.js +15 -0
- package/dist/content-list-extensions.d.ts +50 -0
- package/dist/content-list-extensions.js +11 -0
- package/dist/content-picker/page-picker-sheet.d.ts +15 -0
- package/dist/content-picker/page-picker-sheet.js +105 -0
- package/dist/content-picker/page-picker.d.ts +18 -0
- package/dist/content-picker/page-picker.js +20 -0
- package/dist/content-picker/page-tree.d.ts +25 -0
- package/dist/content-picker/page-tree.js +132 -0
- package/dist/data-type-plugin.d.ts +7 -1
- package/dist/datatype-validation.d.ts +4 -9
- package/dist/datatype-validation.js +147 -1
- package/dist/datatypes-entry.d.ts +1 -0
- package/dist/datatypes-entry.js +2 -0
- package/dist/entitlement-entry.d.ts +1 -1
- package/dist/entitlement-entry.js +1 -1
- package/dist/entitlement-gate.d.ts +14 -0
- package/dist/entitlement-gate.js +64 -7
- package/dist/entitlement-plan.d.ts +6 -0
- package/dist/entitlement-plan.js +10 -0
- package/dist/entitlement-types.d.ts +53 -12
- package/dist/entitlement.d.ts +31 -4
- package/dist/entitlement.js +58 -17
- package/dist/hook-entry.d.ts +5 -0
- package/dist/hook-entry.js +30 -0
- package/dist/host-entry.d.ts +7 -1
- package/dist/host-entry.js +14 -1
- package/dist/index.d.ts +67 -7
- package/dist/index.js +94 -6
- package/dist/mail.d.ts +34 -0
- package/dist/mail.js +1 -0
- package/dist/manifest-entry.d.ts +47 -4
- package/dist/manifest-entry.js +63 -2
- package/dist/manifest-schema.d.ts +993 -40
- package/dist/manifest-schema.js +516 -26
- package/dist/manifest.d.ts +1186 -62
- package/dist/manifest.js +8 -4
- package/dist/media/media-picker.js +31 -18
- package/dist/media/upload-error.d.ts +5 -1
- package/dist/media/upload-error.js +14 -2
- package/dist/media-library.d.ts +32 -0
- package/dist/media-library.js +15 -0
- package/dist/nested-field-host.d.ts +76 -0
- package/dist/nested-field-host.js +90 -0
- package/dist/notify.d.ts +12 -4
- package/dist/notify.js +1 -1
- package/dist/outbound.d.ts +47 -0
- package/dist/outbound.js +1 -0
- package/dist/plugin-context.d.ts +52 -0
- package/dist/plugin-context.js +27 -0
- package/dist/plugin-permissions.d.ts +18 -0
- package/dist/plugin-permissions.js +25 -0
- package/dist/plugin-screen-context.d.ts +262 -9
- package/dist/plugin-screen-context.js +56 -0
- package/dist/providers.d.ts +313 -0
- package/dist/providers.js +74 -0
- package/dist/read-all-pages.d.ts +5 -0
- package/dist/read-all-pages.js +3 -2
- package/dist/render-page.d.ts +15 -0
- package/dist/render-page.js +20 -0
- package/dist/richtext/block-panel.d.ts +12 -1
- package/dist/richtext/block-panel.js +36 -25
- package/dist/richtext/button-view.d.ts +11 -0
- package/dist/richtext/button-view.js +45 -0
- package/dist/richtext/content-guard.d.ts +4 -0
- package/dist/richtext/content-guard.js +27 -0
- package/dist/richtext/editor-handle.d.ts +34 -0
- package/dist/richtext/editor-handle.js +225 -0
- package/dist/richtext/extensions.d.ts +6 -0
- package/dist/richtext/extensions.js +16 -0
- package/dist/richtext/insert-menu.d.ts +6 -1
- package/dist/richtext/insert-menu.js +45 -22
- package/dist/richtext/item-attributes.d.ts +6 -0
- package/dist/richtext/item-attributes.js +19 -0
- package/dist/richtext/item-panel.d.ts +25 -0
- package/dist/richtext/item-panel.js +118 -0
- package/dist/richtext/item-view.d.ts +58 -0
- package/dist/richtext/item-view.js +172 -0
- package/dist/richtext/mark-form.d.ts +10 -0
- package/dist/richtext/mark-form.js +38 -0
- package/dist/richtext/paste-choice.d.ts +9 -0
- package/dist/richtext/paste-choice.js +13 -0
- package/dist/richtext/plugin-items.d.ts +72 -0
- package/dist/richtext/plugin-items.js +562 -0
- package/dist/richtext/plugin-mark-tooltips.d.ts +5 -0
- package/dist/richtext/plugin-mark-tooltips.js +44 -0
- package/dist/richtext/plugin-toolbar.d.ts +57 -0
- package/dist/richtext/plugin-toolbar.js +186 -0
- package/dist/richtext/rich-item-icons.d.ts +5 -0
- package/dist/richtext/rich-item-icons.js +42 -0
- package/dist/richtext/rich-items.d.ts +42 -0
- package/dist/richtext/rich-items.js +68 -0
- package/dist/richtext/rich-text-view-host.d.ts +24 -0
- package/dist/richtext/rich-text-view-host.js +11 -0
- package/dist/richtext/style-listbox.js +6 -4
- package/dist/richtext/toolbar-button.d.ts +16 -0
- package/dist/richtext/toolbar-button.js +9 -0
- package/dist/richtext/url-paste.d.ts +20 -0
- package/dist/richtext/url-paste.js +82 -0
- package/dist/richtext-html-entry.d.ts +5 -0
- package/dist/richtext-html-entry.js +11 -0
- package/dist/sdk-strings.d.ts +344 -0
- package/dist/sdk-strings.js +411 -0
- package/dist/sealing.d.ts +14 -0
- package/dist/sealing.js +1 -0
- package/dist/service-contract.d.ts +17 -0
- package/dist/service-contract.js +39 -0
- package/dist/services.d.ts +114 -0
- package/dist/services.js +1 -0
- package/dist/simple-storage-value-provider.js +24 -24
- package/dist/structured-storage-types.d.ts +429 -9
- package/dist/tailwind.js +10 -5
- package/dist/template-reads.d.ts +16 -0
- package/dist/template-reads.js +21 -0
- package/dist/testing-entry.d.ts +38 -0
- package/dist/testing-entry.js +173 -0
- package/dist/text-entry.d.ts +1 -0
- package/dist/text-entry.js +7 -0
- package/dist/tokens/system-dark.css +1 -0
- package/dist/tokens/tailwind-theme.css +7 -0
- package/dist/tokens/tokens.css +19 -3
- package/dist/tokens/tokens.json +13 -4
- package/dist/uploads.d.ts +43 -0
- package/dist/uploads.js +1 -0
- package/dist/user-library.d.ts +51 -0
- package/dist/user-library.js +15 -0
- package/dist/view-helpers.d.ts +18 -0
- package/dist/view-helpers.js +64 -0
- package/dist/views/asset-view.js +4 -1
- package/dist/views/content-list-preview.js +3 -1
- package/dist/views/content-list-settings-view.js +11 -7
- package/dist/views/content-list-view.d.ts +5 -3
- package/dist/views/content-list-view.js +243 -40
- package/dist/views/content-picker-view.d.ts +3 -0
- package/dist/views/content-picker-view.js +143 -0
- package/dist/views/crop-view.d.ts +4 -6
- package/dist/views/crop-view.js +22 -13
- package/dist/views/date-range-view.js +4 -1
- package/dist/views/file-upload-view.d.ts +5 -7
- package/dist/views/file-upload-view.js +16 -7
- package/dist/views/group-view.d.ts +8 -0
- package/dist/views/group-view.js +123 -0
- package/dist/views/html-view.js +7 -6
- package/dist/views/image-view.js +37 -19
- package/dist/views/link-view.d.ts +3 -0
- package/dist/views/link-view.js +150 -0
- package/dist/views/options-list-view.d.ts +3 -0
- package/dist/views/options-list-view.js +104 -0
- package/dist/views/repeatable-list-view.d.ts +3 -0
- package/dist/views/repeatable-list-view.js +113 -0
- package/dist/views/rich-text-view.d.ts +2 -0
- package/dist/views/rich-text-view.js +208 -35
- package/dist/views/suggest-key.d.ts +17 -0
- package/dist/views/suggest-key.js +55 -0
- package/dist/views/unreadable-rich-text.d.ts +17 -0
- package/dist/views/unreadable-rich-text.js +40 -0
- package/dist/visitors.d.ts +81 -0
- package/dist/visitors.js +1 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-app-hosts.d.ts +21 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-app-hosts.js +39 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-app-redirects.d.ts +2 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-app-redirects.js +31 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-connections.schema.d.ts +334 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-connections.schema.js +254 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-context.schema.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-context.schema.js +10 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.d.ts +10 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.js +5 -0
- package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.d.ts +11 -1
- package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.js +4 -2
- package/node_modules/@kardalum/api-schemas/dist/built-in-editor-ids.d.ts +8 -0
- package/node_modules/@kardalum/api-schemas/dist/built-in-editor-ids.js +38 -0
- package/node_modules/@kardalum/api-schemas/dist/capability-detail.d.ts +65 -0
- package/node_modules/@kardalum/api-schemas/dist/capability-detail.js +144 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +115 -3
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +58 -11
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +137 -2
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.js +178 -2
- package/node_modules/@kardalum/api-schemas/dist/content-path.d.ts +1 -1
- package/node_modules/@kardalum/api-schemas/dist/content-path.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/content-reads.schema.d.ts +213 -0
- package/node_modules/@kardalum/api-schemas/dist/content-reads.schema.js +234 -0
- package/node_modules/@kardalum/api-schemas/dist/content-search.schema.d.ts +50 -0
- package/node_modules/@kardalum/api-schemas/dist/content-search.schema.js +42 -0
- package/node_modules/@kardalum/api-schemas/dist/content-summary.schema.d.ts +37 -0
- package/node_modules/@kardalum/api-schemas/dist/content-summary.schema.js +19 -0
- package/node_modules/@kardalum/api-schemas/dist/content-unpublish.schema.d.ts +23 -0
- package/node_modules/@kardalum/api-schemas/dist/content-unpublish.schema.js +13 -0
- package/node_modules/@kardalum/api-schemas/dist/content.schema.d.ts +3 -0
- package/node_modules/@kardalum/api-schemas/dist/content.schema.js +10 -0
- package/node_modules/@kardalum/api-schemas/dist/contract-cancel.schema.d.ts +41 -0
- package/node_modules/@kardalum/api-schemas/dist/contract-cancel.schema.js +86 -0
- package/node_modules/@kardalum/api-schemas/dist/contribution-issues.d.ts +11 -0
- package/node_modules/@kardalum/api-schemas/dist/contribution-issues.js +14 -0
- package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +55 -13
- package/node_modules/@kardalum/api-schemas/dist/core-actions.js +22 -10
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +25 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +8 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/data-type-issue.d.ts +35 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-issue.js +60 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +257 -15
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +78 -5
- package/node_modules/@kardalum/api-schemas/dist/document-type.schema.d.ts +24 -6
- package/node_modules/@kardalum/api-schemas/dist/document-type.schema.js +90 -5
- package/node_modules/@kardalum/api-schemas/dist/experimental-points.d.ts +19 -0
- package/node_modules/@kardalum/api-schemas/dist/experimental-points.js +250 -0
- package/node_modules/@kardalum/api-schemas/dist/form-protection-callers.d.ts +29 -0
- package/node_modules/@kardalum/api-schemas/dist/form-protection-callers.js +31 -0
- package/node_modules/@kardalum/api-schemas/dist/form-protection.d.ts +23 -0
- package/node_modules/@kardalum/api-schemas/dist/form-protection.js +12 -0
- package/node_modules/@kardalum/api-schemas/dist/graphql-limits.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/graphql-limits.js +14 -0
- package/node_modules/@kardalum/api-schemas/dist/held-embed-words.d.ts +23 -0
- package/node_modules/@kardalum/api-schemas/dist/held-embed-words.js +70 -0
- package/node_modules/@kardalum/api-schemas/dist/html-scan.d.ts +22 -0
- package/node_modules/@kardalum/api-schemas/dist/html-scan.js +122 -0
- package/node_modules/@kardalum/api-schemas/dist/html-start-tags.d.ts +48 -0
- package/node_modules/@kardalum/api-schemas/dist/html-start-tags.js +381 -0
- package/node_modules/@kardalum/api-schemas/dist/index.d.ts +162 -48
- package/node_modules/@kardalum/api-schemas/dist/index.js +137 -30
- package/node_modules/@kardalum/api-schemas/dist/install-sign-in-switched-off.schema.d.ts +9 -0
- package/node_modules/@kardalum/api-schemas/dist/install-sign-in-switched-off.schema.js +9 -0
- package/node_modules/@kardalum/api-schemas/dist/json-depth.d.ts +3 -0
- package/node_modules/@kardalum/api-schemas/dist/json-depth.js +20 -0
- package/node_modules/@kardalum/api-schemas/dist/legal-anchors.d.ts +8 -0
- package/node_modules/@kardalum/api-schemas/dist/legal-anchors.js +9 -0
- package/node_modules/@kardalum/api-schemas/dist/licensing.schema.d.ts +63 -0
- package/node_modules/@kardalum/api-schemas/dist/licensing.schema.js +54 -0
- package/node_modules/@kardalum/api-schemas/dist/mail-rules.d.ts +226 -0
- package/node_modules/@kardalum/api-schemas/dist/mail-rules.js +409 -0
- package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.d.ts +8 -0
- package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.js +4 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-leaks.schema.d.ts +145 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-leaks.schema.js +154 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +490 -10
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +53 -3
- package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.d.ts +15 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.js +14 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-payouts.schema.d.ts +131 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-payouts.schema.js +272 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-profile.schema.d.ts +84 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-profile.schema.js +138 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-revocation.schema.d.ts +20 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-revocation.schema.js +49 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-sites.schema.d.ts +211 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-sites.schema.js +424 -0
- package/node_modules/@kardalum/api-schemas/dist/mcp-plugins.schema.d.ts +78 -0
- package/node_modules/@kardalum/api-schemas/dist/mcp-plugins.schema.js +27 -0
- package/node_modules/@kardalum/api-schemas/dist/mcp-tool-inputs.schema.d.ts +70 -0
- package/node_modules/@kardalum/api-schemas/dist/mcp-tool-inputs.schema.js +43 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +38 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +13 -1
- package/node_modules/@kardalum/api-schemas/dist/media-move.schema.d.ts +75 -0
- package/node_modules/@kardalum/api-schemas/dist/media-move.schema.js +53 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.d.ts +2 -2
- package/node_modules/@kardalum/api-schemas/dist/media-reference.d.ts +2 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference.js +55 -0
- package/node_modules/@kardalum/api-schemas/dist/media.schema.d.ts +5 -0
- package/node_modules/@kardalum/api-schemas/dist/media.schema.js +8 -0
- package/node_modules/@kardalum/api-schemas/dist/nested-fields.schema.d.ts +204 -0
- package/node_modules/@kardalum/api-schemas/dist/nested-fields.schema.js +370 -0
- package/node_modules/@kardalum/api-schemas/dist/nested-validation.d.ts +60 -0
- package/node_modules/@kardalum/api-schemas/dist/nested-validation.js +333 -0
- package/node_modules/@kardalum/api-schemas/dist/news.schema.d.ts +5 -5
- package/node_modules/@kardalum/api-schemas/dist/node-access.schema.d.ts +1 -2
- package/node_modules/@kardalum/api-schemas/dist/node-access.schema.js +1 -2
- package/node_modules/@kardalum/api-schemas/dist/notification-kinds.d.ts +145 -0
- package/node_modules/@kardalum/api-schemas/dist/notification-kinds.js +177 -0
- package/node_modules/@kardalum/api-schemas/dist/notification.schema.d.ts +258 -7
- package/node_modules/@kardalum/api-schemas/dist/notification.schema.js +96 -5
- package/node_modules/@kardalum/api-schemas/dist/page-address.d.ts +10 -0
- package/node_modules/@kardalum/api-schemas/dist/page-address.js +7 -0
- package/node_modules/@kardalum/api-schemas/dist/page-audience.schema.d.ts +87 -0
- package/node_modules/@kardalum/api-schemas/dist/page-audience.schema.js +44 -0
- package/node_modules/@kardalum/api-schemas/dist/password-reset.schema.d.ts +34 -0
- package/node_modules/@kardalum/api-schemas/dist/password-reset.schema.js +60 -0
- package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.d.ts +28 -3
- package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.js +55 -8
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.js +13 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-admin-slots.d.ts +11 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-admin-slots.js +61 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-caller.d.ts +23 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-caller.js +16 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-cli-commands.d.ts +76 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-cli-commands.js +316 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-content-access.d.ts +44 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-content-access.js +84 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-content-slots.d.ts +136 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-content-slots.js +254 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-contract-checks.d.ts +22 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-contract-checks.js +66 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-contract-document.d.ts +130 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-contract-document.js +173 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-contract-fetch.d.ts +16 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-contract-fetch.js +112 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-contract-schema.d.ts +70 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-contract-schema.js +380 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-contract-types.d.ts +3 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-contract-types.js +68 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-data-type-configs.d.ts +31 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-data-type-configs.js +131 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +44 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +44 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +16 -5
- package/node_modules/@kardalum/api-schemas/dist/plugin-document-types.d.ts +228 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-document-types.js +41 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-durable-hooks.d.ts +34 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-durable-hooks.js +102 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-editor-extensions.d.ts +43 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-editor-extensions.js +126 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-events.d.ts +24 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-events.js +53 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-field-info.d.ts +41 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-field-info.js +51 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-graphql-fields.d.ts +32 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-graphql-fields.js +102 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-guards.d.ts +112 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-guards.js +118 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-held-embeds.d.ts +119 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-held-embeds.js +216 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-https-origin.d.ts +5 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-https-origin.js +21 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.js +3 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.d.ts +46 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.js +41 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.d.ts +304 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.js +220 -6
- package/node_modules/@kardalum/api-schemas/dist/plugin-kept-parts.d.ts +138 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-kept-parts.js +110 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-labels.d.ts +26 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-labels.js +29 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.d.ts +32 -8
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.js +120 -14
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +408 -14
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +307 -23
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +23 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +61 -3
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-ai.d.ts +40 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-ai.js +139 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.d.ts +23 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.js +37 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-media-access.d.ts +25 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-media-access.js +43 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-outbound.d.ts +107 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-outbound.js +150 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-package-build.schema.d.ts +5 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-package-build.schema.js +7 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-providers.d.ts +346 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-providers.js +461 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.js +2 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-rich-text.d.ts +638 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-rich-text.js +533 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-sealed-values.d.ts +45 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-sealed-values.js +99 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-secrets.d.ts +68 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-secrets.js +114 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-service-call.d.ts +36 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-service-call.js +32 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-service-connections.d.ts +193 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-service-connections.js +123 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-service-declarations.d.ts +209 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-service-declarations.js +372 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-services.d.ts +90 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-services.js +204 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-settings.d.ts +352 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-settings.js +409 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-site-extensions.d.ts +347 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-site-extensions.js +976 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-site-requests.d.ts +69 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-site-requests.js +149 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.d.ts +7 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.js +47 -4
- package/node_modules/@kardalum/api-schemas/dist/plugin-styles.d.ts +5 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-styles.js +13 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-tasks.d.ts +45 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-tasks.js +197 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-uploads.d.ts +96 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-uploads.js +185 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-user-accounts.d.ts +213 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-user-accounts.js +131 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-view-kit.d.ts +54 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-view-kit.js +154 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-visitor-points.d.ts +37 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-visitor-points.js +124 -0
- package/node_modules/@kardalum/api-schemas/dist/plural-rules.d.ts +9 -0
- package/node_modules/@kardalum/api-schemas/dist/plural-rules.js +41 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +41 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +100 -12
- package/node_modules/@kardalum/api-schemas/dist/refund-request.schema.d.ts +189 -0
- package/node_modules/@kardalum/api-schemas/dist/refund-request.schema.js +164 -0
- package/node_modules/@kardalum/api-schemas/dist/render-cache.d.ts +126 -0
- package/node_modules/@kardalum/api-schemas/dist/render-cache.js +263 -0
- package/node_modules/@kardalum/api-schemas/dist/render-editing.d.ts +307 -4
- package/node_modules/@kardalum/api-schemas/dist/render-editing.js +61 -0
- package/node_modules/@kardalum/api-schemas/dist/revenue-view.schema.js +7 -3
- package/node_modules/@kardalum/api-schemas/dist/rich-text-paste-hosts.d.ts +14 -0
- package/node_modules/@kardalum/api-schemas/dist/rich-text-paste-hosts.js +108 -0
- package/node_modules/@kardalum/api-schemas/dist/rich-text-shape.d.ts +71 -0
- package/node_modules/@kardalum/api-schemas/dist/rich-text-shape.js +540 -0
- package/node_modules/@kardalum/api-schemas/dist/rich-text-text.d.ts +66 -0
- package/node_modules/@kardalum/api-schemas/dist/rich-text-text.js +394 -0
- package/node_modules/@kardalum/api-schemas/dist/sale-conditions.schema.d.ts +82 -0
- package/node_modules/@kardalum/api-schemas/dist/sale-conditions.schema.js +99 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.js +28 -0
- package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.d.ts +201 -1
- package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.js +36 -0
- package/node_modules/@kardalum/api-schemas/dist/security-overview.schema.d.ts +64 -0
- package/node_modules/@kardalum/api-schemas/dist/security-overview.schema.js +38 -0
- package/node_modules/@kardalum/api-schemas/dist/server-settings-api.schema.d.ts +97 -8
- package/node_modules/@kardalum/api-schemas/dist/server-settings-api.schema.js +64 -1
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +136 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +53 -2
- package/node_modules/@kardalum/api-schemas/dist/sign-in-steps.d.ts +724 -0
- package/node_modules/@kardalum/api-schemas/dist/sign-in-steps.js +408 -0
- package/node_modules/@kardalum/api-schemas/dist/sign-in.schema.d.ts +386 -0
- package/node_modules/@kardalum/api-schemas/dist/sign-in.schema.js +618 -0
- package/node_modules/@kardalum/api-schemas/dist/site-consent.d.ts +77 -0
- package/node_modules/@kardalum/api-schemas/dist/site-consent.js +122 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +3 -3
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +1 -1
- package/node_modules/@kardalum/api-schemas/dist/structured-duplicate-key.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/structured-duplicate-key.js +26 -0
- package/node_modules/@kardalum/api-schemas/dist/structured-fields.schema.d.ts +70 -0
- package/node_modules/@kardalum/api-schemas/dist/structured-fields.schema.js +188 -0
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +33 -0
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +26 -1
- package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/template.schema.js +3 -0
- package/node_modules/@kardalum/api-schemas/dist/transaction-rolled-back.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/transaction-rolled-back.js +29 -0
- package/node_modules/@kardalum/api-schemas/dist/trash-purge.schema.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/trash-purge.schema.js +6 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +72 -1
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +36 -3
- package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.d.ts +5 -1
- package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.js +4 -3
- package/node_modules/@kardalum/api-schemas/dist/visitor-accounts.d.ts +482 -0
- package/node_modules/@kardalum/api-schemas/dist/visitor-accounts.js +380 -0
- package/node_modules/@kardalum/api-schemas/dist/visitor-groups.d.ts +109 -0
- package/node_modules/@kardalum/api-schemas/dist/visitor-groups.js +62 -0
- package/node_modules/@kardalum/api-schemas/package.json +2 -0
- package/node_modules/@kardalum/design-tokens/dist/build-css.js +15 -1
- package/node_modules/@kardalum/design-tokens/dist/system-dark.css +1 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.css +7 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +2 -1
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +2 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.css +19 -3
- package/node_modules/@kardalum/design-tokens/dist/tokens.d.ts +1 -1
- package/node_modules/@kardalum/design-tokens/dist/tokens.js +18 -3
- package/node_modules/@kardalum/design-tokens/dist/tokens.json +13 -4
- package/node_modules/@kardalum/design-tokens/dist/types.d.ts +5 -1
- package/node_modules/@kardalum/plugin-package/dist/build-reference.d.ts +38 -2
- package/node_modules/@kardalum/plugin-package/dist/build-reference.js +17 -2
- package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +17 -10
- package/node_modules/@kardalum/plugin-package/dist/capabilities.js +625 -35
- package/node_modules/@kardalum/plugin-package/dist/client-bundle.d.ts +1 -1
- package/node_modules/@kardalum/plugin-package/dist/client-bundle.js +25 -0
- package/node_modules/@kardalum/plugin-package/dist/cms-range.d.ts +17 -0
- package/node_modules/@kardalum/plugin-package/dist/cms-range.js +353 -0
- package/node_modules/@kardalum/plugin-package/dist/contract-fingerprint.d.ts +17 -0
- package/node_modules/@kardalum/plugin-package/dist/contract-fingerprint.js +39 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/admin-styles.d.ts +23 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/admin-styles.js +351 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/ai-declarations.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/ai-declarations.js +26 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/archive-names.d.ts +1 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/archive-names.js +3 -2
- package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.js +1 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/content-access.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/content-access.js +47 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.js +2 -2
- package/node_modules/@kardalum/plugin-package/dist/delivery/editor-extensions.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/editor-extensions.js +40 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/graphql-fields.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/graphql-fields.js +22 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/icons.js +3 -2
- package/node_modules/@kardalum/plugin-package/dist/delivery/index.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/index.js +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/label-languages.js +76 -6
- package/node_modules/@kardalum/plugin-package/dist/delivery/licence-check.d.ts +27 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/licence-check.js +99 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/limits.d.ts +6 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/limits.js +6 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/locales.js +9 -4
- package/node_modules/@kardalum/plugin-package/dist/delivery/plugin-settings.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/plugin-settings.js +68 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/providers.d.ts +5 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/providers.js +316 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/registry.js +40 -4
- package/node_modules/@kardalum/plugin-package/dist/delivery/rich-text.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/rich-text.js +173 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/sample-content.js +91 -2
- package/node_modules/@kardalum/plugin-package/dist/delivery/server-powers.d.ts +6 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/server-powers.js +150 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/services-events.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/services-events.js +35 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/sign-in-steps.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/sign-in-steps.js +71 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/site-extensions.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/site-extensions.js +69 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/templates.d.ts +1 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/templates.js +21 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/types.d.ts +17 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/user-accounts.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/user-accounts.js +36 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/visitor-points.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/visitor-points.js +33 -0
- package/node_modules/@kardalum/plugin-package/dist/index.d.ts +8 -2
- package/node_modules/@kardalum/plugin-package/dist/index.js +7 -1
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.d.ts +75 -0
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.js +123 -0
- package/node_modules/@kardalum/plugin-package/dist/public-suffix.d.ts +7 -0
- package/node_modules/@kardalum/plugin-package/dist/public-suffix.js +23 -0
- package/node_modules/@kardalum/plugin-package/dist/rich-text-summary.d.ts +1 -0
- package/node_modules/@kardalum/plugin-package/dist/rich-text-summary.js +27 -0
- package/node_modules/@kardalum/plugin-package/dist/stylesheet-load-hook.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/stylesheet-load-hook.js +28 -0
- package/node_modules/@kardalum/plugin-package/package.json +4 -0
- package/node_modules/@kardalum/ui/dist/components/select.d.ts +6 -0
- package/node_modules/@kardalum/ui/dist/components/select.js +7 -0
- package/node_modules/@kardalum/ui/dist/components/switch.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/textarea.d.ts +6 -0
- package/node_modules/@kardalum/ui/dist/components/textarea.js +7 -0
- package/node_modules/@kardalum/ui/dist/components/tooltip.js +1 -2
- package/node_modules/@kardalum/ui/dist/components/truncated-text.d.ts +6 -1
- package/node_modules/@kardalum/ui/dist/components/truncated-text.js +5 -4
- package/node_modules/@kardalum/ui/dist/index.d.ts +2 -0
- package/node_modules/@kardalum/ui/dist/index.js +2 -0
- package/package.json +25 -3
|
@@ -0,0 +1,976 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { isReservedRootSlug } from "./reserved-slugs.js";
|
|
3
|
+
import { hasNoControlCharacter } from "./strict-url.js";
|
|
4
|
+
import { PageHeadScriptOriginSchema, SITE_LOCATION_MAX } from "./plugin-https-origin.js";
|
|
5
|
+
import { PluginHeldEmbedsSchema } from "./plugin-held-embeds.js";
|
|
6
|
+
import { CONSENT_CATEGORIES, CORE_DATA_PREFIX } from "./site-consent.js";
|
|
7
|
+
import { SITE_ROUTE_UPLOAD_METHODS, routeUploadsProblem } from "./plugin-uploads.js";
|
|
8
|
+
export { PageHeadScriptOriginSchema, SITE_LOCATION_MAX };
|
|
9
|
+
// M32 F2: the rules and limits for what a plugin adds to the public site.
|
|
10
|
+
// Site routes are file addresses (GET) and form posts (POST) a plugin
|
|
11
|
+
// answers beside the pages; the site fallback answers an address no page
|
|
12
|
+
// holds; template filters and tags extend the page templates under the
|
|
13
|
+
// plugin's own prefix; the page head lets a plugin add meta, link, script
|
|
14
|
+
// and JSON-LD entries to a page's <head>. Every character rule below is a
|
|
15
|
+
// loop over a length-capped string, never a pattern match.
|
|
16
|
+
export const SITE_ROUTE_METHODS = ["GET", "POST"];
|
|
17
|
+
export const SITE_ROUTES_MAX = 20;
|
|
18
|
+
export const SITE_ROUTE_PATH_MAX = 200;
|
|
19
|
+
export const SITE_ROUTE_SEGMENTS_MAX = 8;
|
|
20
|
+
export const SITE_ROUTE_SEGMENT_MAX = 100;
|
|
21
|
+
export const SITE_ROUTE_BODY_LIMIT_BYTES = 65_536;
|
|
22
|
+
export const SITE_ROUTE_FORM_FIELDS_MAX = 200;
|
|
23
|
+
export const SITE_ROUTE_ANSWER_LIMIT_BYTES = 5_242_880;
|
|
24
|
+
/** M35 P3 (W18): the parameters one site route path holds at most. */
|
|
25
|
+
export const SITE_ROUTE_PARAMS_MAX = 4;
|
|
26
|
+
/** M35 P3 (W18): the longest parameter name, in characters. */
|
|
27
|
+
export const SITE_ROUTE_PARAM_NAME_MAX = 32;
|
|
28
|
+
/** M35 P3 (W18): the longest decoded segment a parameter takes; a longer one matches no pattern. */
|
|
29
|
+
export const SITE_ROUTE_PARAM_VALUE_MAX = 200;
|
|
30
|
+
/** M35 P3 (W18): the longest rest a trailing "*" takes, decoded segments joined with "/". */
|
|
31
|
+
export const SITE_ROUTE_REST_MAX = 1_000;
|
|
32
|
+
/** M35 P3 (W18): the most segments a trailing "*" takes. */
|
|
33
|
+
export const SITE_ROUTE_REST_SEGMENTS_MAX = 16;
|
|
34
|
+
/** M35 P3 (W18): the longest raw path the core reads for a pattern; a longer one matches none. */
|
|
35
|
+
export const SITE_ROUTE_MATCH_PATH_MAX = 2_000;
|
|
36
|
+
/** M35 P3 (W18): the key a trailing "*" puts its rest under in request.params. */
|
|
37
|
+
export const SITE_ROUTE_REST_PARAM = "*";
|
|
38
|
+
/** M35 P3 (W18): first segments no route that answers after the pages may take: the visitor account pages (35-U2a). */
|
|
39
|
+
export const SITE_ROUTE_PATTERN_RESERVED_PREFIXES = ["account"];
|
|
40
|
+
export const SITE_FALLBACK_TIME_MS = 250;
|
|
41
|
+
export const SITE_REDIRECT_STATUSES = [301, 302, 307, 308];
|
|
42
|
+
/** M33 K34: the longest a plugin may let a browser keep its fallback redirect, one day, in seconds. */
|
|
43
|
+
export const SITE_REDIRECT_MAX_AGE_MAX = 86_400;
|
|
44
|
+
/** M33 K34: how long a 301 or 308 is kept when the plugin gives no `maxAgeSeconds`, one hour. */
|
|
45
|
+
export const SITE_REDIRECT_MAX_AGE_DEFAULT = 3_600;
|
|
46
|
+
export const TEMPLATE_EXTENSIONS_MAX = 20;
|
|
47
|
+
export const TEMPLATE_NAME_MAX = 40;
|
|
48
|
+
export const TEMPLATE_CALL_TIME_MS = 250;
|
|
49
|
+
/** The time all of one render's plugin template calls may take together; half the render's own time limit. */
|
|
50
|
+
export const TEMPLATE_CALL_TIME_PER_RENDER_MS = 500;
|
|
51
|
+
export const TEMPLATE_CALLS_PER_RENDER_MAX = 2_000;
|
|
52
|
+
export const TEMPLATE_DATA_DEPTH_MAX = 8;
|
|
53
|
+
export const TEMPLATE_DATA_VALUES_MAX = 10_000;
|
|
54
|
+
export const TEMPLATE_DATA_TEXT_MAX_BYTES = 262_144;
|
|
55
|
+
export const TEMPLATE_OUTPUT_LIMIT_BYTES = 65_536;
|
|
56
|
+
/** M35 P3 (W19): the largest rendered body a block tag is handed, in UTF-8 bytes; a larger one is handed as null. */
|
|
57
|
+
export const TEMPLATE_BLOCK_BODY_MAX_BYTES = 262_144;
|
|
58
|
+
/** M35 P3 (W19): the longest class a block tag's wrap names, in characters. */
|
|
59
|
+
export const TEMPLATE_BLOCK_CLASS_MAX = 200;
|
|
60
|
+
/** M35 P3 (W19): the elements a block tag's wrap may put the body in. */
|
|
61
|
+
export const TEMPLATE_BLOCK_WRAP_ELEMENTS = ["div", "section", "span", "figure", "blockquote"];
|
|
62
|
+
/** M35 P3 (W19): what a block tag writes when it cannot answer: the author's body (the default) or nothing. */
|
|
63
|
+
export const TEMPLATE_BLOCK_ON_FAILURE = ["body", "nothing"];
|
|
64
|
+
/** M35 P3 (evidence 116): what a filter prints when it cannot answer: its value (the default) or nothing. */
|
|
65
|
+
export const TEMPLATE_FILTER_ON_FAILURE = ["value", "nothing"];
|
|
66
|
+
/** M35 P3 (W19): the published reads all plugin template calls of one render make together, on the render's list read budget. */
|
|
67
|
+
export const TEMPLATE_PLUGIN_READS_PER_RENDER_MAX = 20;
|
|
68
|
+
/** M35 P3 (W19): of those, the searches. */
|
|
69
|
+
export const TEMPLATE_PLUGIN_SEARCHES_PER_RENDER_MAX = 2;
|
|
70
|
+
/** M35 P3 (W19): why a template call's read was refused: a budget is spent, the call has ended, or no reader is wired. */
|
|
71
|
+
export const TEMPLATE_READ_REFUSALS = ["spent", "ended", "unavailable"];
|
|
72
|
+
export const PAGE_HEAD_ENTRIES_MAX = 20;
|
|
73
|
+
export const PAGE_HEAD_LIMIT_BYTES = 65_536;
|
|
74
|
+
export const PAGE_HEAD_SCRIPT_ORIGINS_MAX = 10;
|
|
75
|
+
export const PAGE_HEAD_TIME_MS = 250;
|
|
76
|
+
export const PAGE_HEAD_CONTENT_MAX = 2_000;
|
|
77
|
+
export const PAGE_HEAD_JSON_LD_MAX_BYTES = 32_768;
|
|
78
|
+
export const PAGE_HEAD_ASSET_PATH_MAX = 500;
|
|
79
|
+
/** M33 K26 (SEO 2.16 C4): the `publicMediaUrl` reads one plugin's page head may make in one render; a fifth answers null. */
|
|
80
|
+
export const PAGE_HEAD_MEDIA_READS_MAX = 4;
|
|
81
|
+
/** M33 K27 (SEO 2.16 C5): the longest page title a plugin's title entry may give, in characters. */
|
|
82
|
+
export const PAGE_HEAD_TITLE_MAX = 300;
|
|
83
|
+
/** M33 K27: how much of a rendered page the core reads to find its <title> or </head>, in bytes. */
|
|
84
|
+
export const PAGE_TITLE_SCAN_BYTES = 65_536;
|
|
85
|
+
export const PAGE_HEAD_LINK_RELS = ["canonical", "alternate", "icon", "manifest", "preconnect", "dns-prefetch", "stylesheet"];
|
|
86
|
+
/** M35 P1 (W40): the longest inline snippet a head entry carries, in UTF-8 bytes. */
|
|
87
|
+
export const PAGE_HEAD_INLINE_TEXT_MAX_BYTES = 16_384;
|
|
88
|
+
/** M35 P1 (W40): the inline snippets one plugin's head writes in a render; a fifth is dropped. Counted among PAGE_HEAD_ENTRIES_MAX and PAGE_HEAD_LIMIT_BYTES. */
|
|
89
|
+
export const PAGE_HEAD_INLINE_SNIPPETS_MAX = 4;
|
|
90
|
+
/** M35 P1 (W3): the page output transforms one render runs, in plugin id order; later ones are skipped. */
|
|
91
|
+
export const PAGE_OUTPUT_TRANSFORMS_MAX = 8;
|
|
92
|
+
/** M35 P1 (W3): how long the core waits for one transform, in milliseconds. */
|
|
93
|
+
export const PAGE_OUTPUT_TIME_MS = 100;
|
|
94
|
+
/** M35 P1 (W3): how long the core waits for all transforms of one render together; its own budget, apart from the template calls'. */
|
|
95
|
+
export const PAGE_OUTPUT_TIME_PER_RENDER_MS = 250;
|
|
96
|
+
/** M35 P1 (W3): the largest page handed to transforms, in UTF-8 bytes; a larger page is served as rendered. */
|
|
97
|
+
export const PAGE_OUTPUT_INPUT_MAX_BYTES = 2_097_152;
|
|
98
|
+
/** M35 P1 (W3): how many UTF-8 bytes one transform's answer may add to the page it was handed. */
|
|
99
|
+
export const PAGE_OUTPUT_GROWTH_MAX_BYTES = 262_144;
|
|
100
|
+
// M32 F4c (D2): `context.listPublishedPages`. A call answers at most LIMIT_MAX pages (LIMIT_DEFAULT
|
|
101
|
+
// when none is asked) and reads at most BATCHES_MAX batches of `limit` rows to fill them, so a
|
|
102
|
+
// tree full of drafts never makes one call unbounded.
|
|
103
|
+
export const PUBLISHED_PAGES_LIMIT_DEFAULT = 100;
|
|
104
|
+
export const PUBLISHED_PAGES_LIMIT_MAX = 500;
|
|
105
|
+
export const PUBLISHED_PAGES_BATCHES_MAX = 5;
|
|
106
|
+
// M33 K31 (Redirects 2.16 C2): `context.pageAddresses` takes 1 to PAGE_ADDRESSES_TARGETS_MAX targets a call.
|
|
107
|
+
export const PAGE_ADDRESSES_TARGETS_MAX = 100;
|
|
108
|
+
// M32 F2 (D14): the first word of every core filter and tag name (liquidjs's and Kardalum's). The server's plugin-template-binding test pins it against the engine; after release 1.0 a new core name is kardalum_<name>, so this list does not grow.
|
|
109
|
+
export const RESERVED_TEMPLATE_WORDS = [
|
|
110
|
+
"abs", "append", "array", "assign", "at", "base64", "block", "break", "capitalize", "capture",
|
|
111
|
+
"case", "ceil", "cgi", "comment", "compact", "concat", "continue", "cycle", "date", "decrement",
|
|
112
|
+
"default", "divided", "downcase", "echo", "editable", "escape", "find", "first", "floor", "for",
|
|
113
|
+
"form", "format", "group", "has", "hmac", "if", "include", "increment", "inspect", "join", "json",
|
|
114
|
+
"jsonify", "kardalum", "last", "layout", "liquid", "list", "lstrip", "map", "minus", "modulo",
|
|
115
|
+
"newline", "normalize", "number", "plugin", "plus", "pop", "prepend", "push", "raw", "reject",
|
|
116
|
+
"remove", "render", "replace", "reverse", "round", "rstrip", "sample", "search", "sha256", "shift", "size", "slice",
|
|
117
|
+
"slugify", "sort", "split", "squish", "strip", "sum", "tablerow", "times", "to", "truncate", "truncatewords",
|
|
118
|
+
"uniq", "unless", "unshift", "upcase", "uri", "url", "where", "xml",
|
|
119
|
+
];
|
|
120
|
+
/** M33 K71: the facts a template reads off `page` (and a listed page) ahead of a field of the same
|
|
121
|
+
* id, so a field with one of these ids is reached there only as `page.fields.<id>`. The renderer
|
|
122
|
+
* answers them by these names, and the document type editor warns on a field id among them.
|
|
123
|
+
* M35 P4: `name` (`_name`) is answered on `page` only until 35-C5 adds `child._name`; on a listed
|
|
124
|
+
* page it reads a field of that id, which none can be. */
|
|
125
|
+
export const TEMPLATE_PAGE_FACTS = {
|
|
126
|
+
children: "children",
|
|
127
|
+
culture: "culture",
|
|
128
|
+
parent: "parent",
|
|
129
|
+
id: "id",
|
|
130
|
+
url: "url",
|
|
131
|
+
path: "path",
|
|
132
|
+
type: "type",
|
|
133
|
+
locale: "locale",
|
|
134
|
+
publishedAt: "publishedAt",
|
|
135
|
+
fields: "fields",
|
|
136
|
+
/** M35 P4 (evidence 33): the page's own published name. A field id starts with a letter, so none can be `_name`. */
|
|
137
|
+
name: "_name",
|
|
138
|
+
};
|
|
139
|
+
/** The tags Kardalum's engine adds to Liquid's own, each written with no block body. A parse-only
|
|
140
|
+
* engine (the CLI's templates check) knows them by name; the server's plugin-template-binding test
|
|
141
|
+
* pins the list against the engine. */
|
|
142
|
+
export const KARDALUM_TEMPLATE_TAGS = ["list", "form_protection", "plugin_head", "search", "plugin_tag"];
|
|
143
|
+
const isLower = (c) => c >= "a" && c <= "z";
|
|
144
|
+
const isDigit = (c) => c >= "0" && c <= "9";
|
|
145
|
+
const isUpper = (c) => c >= "A" && c <= "Z";
|
|
146
|
+
const SEGMENT_EXTRA = new Set([".", "_", "~", "-"]);
|
|
147
|
+
function everyChar(test) {
|
|
148
|
+
return (value) => {
|
|
149
|
+
for (const c of value)
|
|
150
|
+
if (!test(c))
|
|
151
|
+
return false;
|
|
152
|
+
return true;
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
/** A parameter name: a letter, then letters, digits and "_", 1 to SITE_ROUTE_PARAM_NAME_MAX. */
|
|
156
|
+
function isParamName(name) {
|
|
157
|
+
if (name.length === 0 || name.length > SITE_ROUTE_PARAM_NAME_MAX)
|
|
158
|
+
return false;
|
|
159
|
+
if (!(isLower(name[0]) || isUpper(name[0])))
|
|
160
|
+
return false;
|
|
161
|
+
for (const c of name)
|
|
162
|
+
if (!(isLower(c) || isUpper(c) || isDigit(c) || c === "_"))
|
|
163
|
+
return false;
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* M32 F2 (D2, D3), M35 P3 (W18): a declared site route path read left to right, once, into its
|
|
168
|
+
* segments, or the first reason it is refused. The length is checked before any segment is read.
|
|
169
|
+
*/
|
|
170
|
+
export function readSiteRoutePath(method, path) {
|
|
171
|
+
const no = (problem) => ({ ok: false, problem });
|
|
172
|
+
if (!SITE_ROUTE_METHODS.includes(method))
|
|
173
|
+
return no(`method must be one of ${SITE_ROUTE_METHODS.join(", ")}`);
|
|
174
|
+
if (typeof path !== "string" || path.length === 0 || path.length > SITE_ROUTE_PATH_MAX)
|
|
175
|
+
return no(`path must be 1 to ${SITE_ROUTE_PATH_MAX} characters`);
|
|
176
|
+
if (path[0] !== "/")
|
|
177
|
+
return no('path must start with "/"');
|
|
178
|
+
const raw = path.slice(1).split("/");
|
|
179
|
+
if (raw.length > SITE_ROUTE_SEGMENTS_MAX)
|
|
180
|
+
return no(`path has at most ${SITE_ROUTE_SEGMENTS_MAX} segments`);
|
|
181
|
+
const segments = [];
|
|
182
|
+
const params = [];
|
|
183
|
+
let dotted = false;
|
|
184
|
+
for (let index = 0; index < raw.length; index += 1) {
|
|
185
|
+
const segment = raw[index];
|
|
186
|
+
const last = index === raw.length - 1;
|
|
187
|
+
if (segment === "")
|
|
188
|
+
return no("path has no empty segment and no trailing slash");
|
|
189
|
+
if (segment === "*") {
|
|
190
|
+
if (!last)
|
|
191
|
+
return no('a "*" is only the last segment');
|
|
192
|
+
if (index === 0)
|
|
193
|
+
return no('the first segment is a fixed name, never a parameter or "*"');
|
|
194
|
+
segments.push({ kind: "rest" });
|
|
195
|
+
params.push(SITE_ROUTE_REST_PARAM);
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
if (segment[0] === ":") {
|
|
199
|
+
if (index === 0)
|
|
200
|
+
return no('the first segment is a fixed name, never a parameter or "*"');
|
|
201
|
+
const name = segment.slice(1);
|
|
202
|
+
if (!isParamName(name))
|
|
203
|
+
return no(`a parameter is ":" and a name of 1 to ${SITE_ROUTE_PARAM_NAME_MAX} letters, digits and "_", starting with a letter`);
|
|
204
|
+
if (params.includes(name))
|
|
205
|
+
return no("path names each parameter name once");
|
|
206
|
+
segments.push({ kind: "param", name });
|
|
207
|
+
params.push(name);
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
if (segment === "." || segment === "..")
|
|
211
|
+
return no('path has no "." or ".." segment');
|
|
212
|
+
if (segment.length > SITE_ROUTE_SEGMENT_MAX)
|
|
213
|
+
return no(`each segment is at most ${SITE_ROUTE_SEGMENT_MAX} characters`);
|
|
214
|
+
for (const c of segment) {
|
|
215
|
+
if (!(isLower(c) || isUpper(c) || isDigit(c) || SEGMENT_EXTRA.has(c)))
|
|
216
|
+
return no('segments hold letters, digits, ".", "_", "~" and "-", or are ":<name>" or a last "*"');
|
|
217
|
+
}
|
|
218
|
+
if (segment.includes("."))
|
|
219
|
+
dotted = true;
|
|
220
|
+
segments.push({ kind: "literal", value: segment });
|
|
221
|
+
}
|
|
222
|
+
if (params.filter((name) => name !== SITE_ROUTE_REST_PARAM).length > SITE_ROUTE_PARAMS_MAX)
|
|
223
|
+
return no(`path has at most ${SITE_ROUTE_PARAMS_MAX} parameters`);
|
|
224
|
+
const prefix = segments[0].value;
|
|
225
|
+
if (isReservedRootSlug(prefix))
|
|
226
|
+
return no(`"/${prefix}" is the server's own address`);
|
|
227
|
+
// An HTML document at a site address is a page, which the CMS or the
|
|
228
|
+
// owner's public/ folder answers: a route there would answer before the
|
|
229
|
+
// owner's own public/ HTML file, which the order promises wins.
|
|
230
|
+
const tail = segments[segments.length - 1];
|
|
231
|
+
if (method === "GET" && tail.kind === "literal") {
|
|
232
|
+
const lower = tail.value.toLowerCase();
|
|
233
|
+
if (lower.endsWith(".html") || lower.endsWith(".htm"))
|
|
234
|
+
return no("a GET site route is not an HTML file address (.html or .htm): a page or a public/ file answers there");
|
|
235
|
+
}
|
|
236
|
+
const patterned = segments.some((segment) => segment.kind !== "literal");
|
|
237
|
+
const phase = patterned || (method === "GET" && !dotted) ? "afterPages" : "fixed";
|
|
238
|
+
if (phase === "afterPages" && SITE_ROUTE_PATTERN_RESERVED_PREFIXES.includes(prefix.toLowerCase()))
|
|
239
|
+
return no(`"/${prefix}" is the visitor account pages' address`);
|
|
240
|
+
const shape = `${method} /${segments.map((segment) => (segment.kind === "literal" ? segment.value : segment.kind === "param" ? ":" : "*")).join("/")}`;
|
|
241
|
+
return { ok: true, pattern: { method: method, segments, phase, prefix, shape, params } };
|
|
242
|
+
}
|
|
243
|
+
/** M32 F2 (D2, D3): why a declared site route path is refused, or null. M35 P3: over readSiteRoutePath. */
|
|
244
|
+
export function siteRoutePathProblem(method, path) {
|
|
245
|
+
const read = readSiteRoutePath(method, path);
|
|
246
|
+
return read.ok ? null : read.problem;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* M35 P3 (W18): a visitor's raw path (before "?") as decoded segments, or null when it matches no
|
|
250
|
+
* pattern: over SITE_ROUTE_MATCH_PATH_MAX characters, not starting with "/", an empty, "." or ".."
|
|
251
|
+
* segment (raw or decoded), a segment that does not decode, a decoded "/" or control character, or
|
|
252
|
+
* more than SITE_ROUTE_SEGMENTS_MAX + SITE_ROUTE_REST_SEGMENTS_MAX segments. Split first, then each
|
|
253
|
+
* segment decoded once, so an encoded "/" never makes a second segment.
|
|
254
|
+
*/
|
|
255
|
+
export function readAddressSegments(rawPath) {
|
|
256
|
+
if (typeof rawPath !== "string" || rawPath.length < 2 || rawPath.length > SITE_ROUTE_MATCH_PATH_MAX || rawPath[0] !== "/")
|
|
257
|
+
return null;
|
|
258
|
+
const raw = rawPath.slice(1).split("/");
|
|
259
|
+
if (raw.length > SITE_ROUTE_SEGMENTS_MAX + SITE_ROUTE_REST_SEGMENTS_MAX)
|
|
260
|
+
return null;
|
|
261
|
+
const out = [];
|
|
262
|
+
for (const segment of raw) {
|
|
263
|
+
if (segment === "" || segment === "." || segment === "..")
|
|
264
|
+
return null;
|
|
265
|
+
let decoded;
|
|
266
|
+
try {
|
|
267
|
+
decoded = decodeURIComponent(segment);
|
|
268
|
+
}
|
|
269
|
+
catch {
|
|
270
|
+
return null;
|
|
271
|
+
}
|
|
272
|
+
if (decoded === "" || decoded === "." || decoded === ".." || decoded.includes("/") || !hasNoControlCharacter(decoded))
|
|
273
|
+
return null;
|
|
274
|
+
out.push(decoded);
|
|
275
|
+
}
|
|
276
|
+
return out;
|
|
277
|
+
}
|
|
278
|
+
/** M35 P3 (W18): the parameters of `segments` under `pattern`, frozen with no prototype, or null. */
|
|
279
|
+
export function matchSiteRoutePattern(pattern, segments) {
|
|
280
|
+
const params = Object.create(null);
|
|
281
|
+
for (let index = 0; index < pattern.segments.length; index += 1) {
|
|
282
|
+
const segment = pattern.segments[index];
|
|
283
|
+
if (segment.kind === "rest") {
|
|
284
|
+
const rest = segments.slice(index);
|
|
285
|
+
if (rest.length === 0 || rest.length > SITE_ROUTE_REST_SEGMENTS_MAX)
|
|
286
|
+
return null;
|
|
287
|
+
const joined = rest.join("/");
|
|
288
|
+
if (joined.length > SITE_ROUTE_REST_MAX)
|
|
289
|
+
return null;
|
|
290
|
+
params[SITE_ROUTE_REST_PARAM] = joined;
|
|
291
|
+
return Object.freeze(params);
|
|
292
|
+
}
|
|
293
|
+
const value = segments[index];
|
|
294
|
+
if (value === undefined)
|
|
295
|
+
return null;
|
|
296
|
+
if (segment.kind === "literal") {
|
|
297
|
+
if (value !== segment.value)
|
|
298
|
+
return null;
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
if (value.length > SITE_ROUTE_PARAM_VALUE_MAX)
|
|
302
|
+
return null;
|
|
303
|
+
params[segment.name] = value;
|
|
304
|
+
}
|
|
305
|
+
return segments.length === pattern.segments.length ? Object.freeze(params) : null;
|
|
306
|
+
}
|
|
307
|
+
const SPECIFICITY = { literal: 0, param: 1, rest: 2 };
|
|
308
|
+
/** M35 P3 (W18): negative when `a` is more specific, segment by segment from the left: a literal, then a parameter, then the rest. */
|
|
309
|
+
export function compareSiteRouteSpecificity(a, b) {
|
|
310
|
+
const length = Math.max(a.segments.length, b.segments.length);
|
|
311
|
+
for (let index = 0; index < length; index += 1) {
|
|
312
|
+
const left = a.segments[index];
|
|
313
|
+
const right = b.segments[index];
|
|
314
|
+
if (left === undefined || right === undefined)
|
|
315
|
+
return left === undefined ? 1 : -1;
|
|
316
|
+
const difference = SPECIFICITY[left.kind] - SPECIFICITY[right.kind];
|
|
317
|
+
if (difference !== 0)
|
|
318
|
+
return difference;
|
|
319
|
+
}
|
|
320
|
+
return 0;
|
|
321
|
+
}
|
|
322
|
+
/** M35 P2 (W21): why a site route's `rawBody` cannot stand, or null when it can (absent, or `true` on a
|
|
323
|
+
* POST route): the exact bytes of a body sent to be signed. GET has no body. */
|
|
324
|
+
export function siteRouteRawBodyProblem(route) {
|
|
325
|
+
if (route.rawBody === undefined)
|
|
326
|
+
return null;
|
|
327
|
+
if (route.rawBody !== true)
|
|
328
|
+
return "rawBody must be true when it is given";
|
|
329
|
+
if (route.method !== "POST")
|
|
330
|
+
return `rawBody is only for a POST site route, and this route is ${typeof route.method === "string" ? route.method : "not a method"}`;
|
|
331
|
+
return null;
|
|
332
|
+
}
|
|
333
|
+
/** Every character is printable ASCII (no space): one linear scan. */
|
|
334
|
+
function printableAscii(value) {
|
|
335
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
336
|
+
const code = value.charCodeAt(index);
|
|
337
|
+
if (code <= 0x20 || code >= 0x7f)
|
|
338
|
+
return false;
|
|
339
|
+
}
|
|
340
|
+
return true;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* M33 K33: the path a site fallback receives for an address: the address's path, percent-decoded, exactly as
|
|
344
|
+
* sent (a trailing slash stays). Null for an escape that does not decode and for a control character.
|
|
345
|
+
*/
|
|
346
|
+
export function fallbackPathOf(address) {
|
|
347
|
+
let pathname;
|
|
348
|
+
try {
|
|
349
|
+
pathname = decodeURIComponent(new URL(address, "http://placeholder").pathname);
|
|
350
|
+
}
|
|
351
|
+
catch {
|
|
352
|
+
return null;
|
|
353
|
+
}
|
|
354
|
+
return hasNoControlCharacter(pathname) ? pathname : null;
|
|
355
|
+
}
|
|
356
|
+
/** Where a stored location's path ends: before its first "?" or "#"; for a URL, after "scheme://host". */
|
|
357
|
+
function pathBounds(stored) {
|
|
358
|
+
let end = stored.length;
|
|
359
|
+
for (let index = 0; index < stored.length; index += 1) {
|
|
360
|
+
const char = stored[index];
|
|
361
|
+
if (char === "?" || char === "#") {
|
|
362
|
+
end = index;
|
|
363
|
+
break;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
if (stored[0] === "/")
|
|
367
|
+
return { start: 0, end };
|
|
368
|
+
const schemeEnd = stored.indexOf("://");
|
|
369
|
+
if (schemeEnd === -1 || schemeEnd >= end)
|
|
370
|
+
return { start: end, end };
|
|
371
|
+
let start = schemeEnd + 3;
|
|
372
|
+
while (start < end && stored[start] !== "/")
|
|
373
|
+
start += 1;
|
|
374
|
+
return { start, end };
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* M33 K33: a location made of a stored target, the rest of a visitor's decoded path below a stored address and
|
|
378
|
+
* the visitor's query, or null. `rest` is split at "/" and every segment is percent-encoded; an empty, "." or ".."
|
|
379
|
+
* segment answers null. It goes before the stored target's own query and fragment, after one trailing "/" of the
|
|
380
|
+
* stored path is dropped. `query` is printable ASCII without "#" and is joined with "?" or "&". The result must
|
|
381
|
+
* pass `siteLocationProblem`. The scheme and host are never changed. Linear scans only.
|
|
382
|
+
*/
|
|
383
|
+
export function joinSiteLocation(stored, extra) {
|
|
384
|
+
if (typeof stored !== "string" || siteLocationProblem(stored) !== null)
|
|
385
|
+
return null;
|
|
386
|
+
const rest = extra?.rest;
|
|
387
|
+
const query = extra?.query;
|
|
388
|
+
if ((rest !== undefined && typeof rest !== "string") || (query !== undefined && typeof query !== "string"))
|
|
389
|
+
return null;
|
|
390
|
+
const { start, end } = pathBounds(stored);
|
|
391
|
+
let result = stored.slice(0, end);
|
|
392
|
+
if (rest !== undefined && rest !== "") {
|
|
393
|
+
if (result.length > start && result[result.length - 1] === "/")
|
|
394
|
+
result = result.slice(0, -1);
|
|
395
|
+
let segmentStart = 0;
|
|
396
|
+
for (let index = 0; index <= rest.length; index += 1) {
|
|
397
|
+
if (index !== rest.length && rest[index] !== "/")
|
|
398
|
+
continue;
|
|
399
|
+
const segment = rest.slice(segmentStart, index);
|
|
400
|
+
if (segment === "" || segment === "." || segment === "..")
|
|
401
|
+
return null;
|
|
402
|
+
try {
|
|
403
|
+
result += "/" + encodeURIComponent(segment);
|
|
404
|
+
}
|
|
405
|
+
catch {
|
|
406
|
+
return null;
|
|
407
|
+
}
|
|
408
|
+
segmentStart = index + 1;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
let tail = stored.slice(end);
|
|
412
|
+
if (query !== undefined && query !== "") {
|
|
413
|
+
if (!printableAscii(query) || query.includes("#"))
|
|
414
|
+
return null;
|
|
415
|
+
const fragmentAt = tail.indexOf("#");
|
|
416
|
+
const head = fragmentAt === -1 ? tail : tail.slice(0, fragmentAt);
|
|
417
|
+
const fragment = fragmentAt === -1 ? "" : tail.slice(fragmentAt);
|
|
418
|
+
tail = head + (head.includes("?") ? "&" : "?") + query + fragment;
|
|
419
|
+
}
|
|
420
|
+
result += tail;
|
|
421
|
+
return siteLocationProblem(result) === null ? result : null;
|
|
422
|
+
}
|
|
423
|
+
/** M32 F2: why a redirect location (or a page head link) is refused, or null. A site path or an http(s) URL. */
|
|
424
|
+
export function siteLocationProblem(location) {
|
|
425
|
+
if (location.length === 0)
|
|
426
|
+
return "location is empty";
|
|
427
|
+
if (location.length > SITE_LOCATION_MAX)
|
|
428
|
+
return `location is at most ${SITE_LOCATION_MAX} characters`;
|
|
429
|
+
if (!hasNoControlCharacter(location))
|
|
430
|
+
return "location holds a control character";
|
|
431
|
+
if (location[0] === "/") {
|
|
432
|
+
if (location[1] === "/")
|
|
433
|
+
return 'a site path does not start with "//"';
|
|
434
|
+
if (location.includes("\\"))
|
|
435
|
+
return 'a site path holds no "\\"';
|
|
436
|
+
return printableAscii(location) ? null : "a site path holds printable ASCII only (encode spaces and other characters)";
|
|
437
|
+
}
|
|
438
|
+
// A Location header holds bytes, not text: Node refuses a character outside Latin-1 (a 500) and
|
|
439
|
+
// writes Latin-1 as raw bytes a browser may read differently, so an absolute URL is encoded too.
|
|
440
|
+
if (!printableAscii(location))
|
|
441
|
+
return "a URL holds printable ASCII only (encode spaces and other characters)";
|
|
442
|
+
let url;
|
|
443
|
+
try {
|
|
444
|
+
url = new URL(location);
|
|
445
|
+
}
|
|
446
|
+
catch {
|
|
447
|
+
return 'location is a site path starting with "/" or an http or https URL';
|
|
448
|
+
}
|
|
449
|
+
if (url.protocol !== "http:" && url.protocol !== "https:")
|
|
450
|
+
return "location is an http or https URL";
|
|
451
|
+
if (url.host === "")
|
|
452
|
+
return "location names a host";
|
|
453
|
+
if (url.username !== "" || url.password !== "")
|
|
454
|
+
return "location carries no user name or password";
|
|
455
|
+
return null;
|
|
456
|
+
}
|
|
457
|
+
/** M32 F2: a template filter or tag name as a plugin declares it (before its prefix). */
|
|
458
|
+
export function isTemplateExtensionName(value) {
|
|
459
|
+
if (value.length === 0 || value.length > TEMPLATE_NAME_MAX)
|
|
460
|
+
return false;
|
|
461
|
+
if (!isLower(value[0]))
|
|
462
|
+
return false;
|
|
463
|
+
return everyChar((c) => isLower(c) || isDigit(c) || c === "_")(value);
|
|
464
|
+
}
|
|
465
|
+
/** The plugin's template prefix: its id's last segment, "-" written "_". */
|
|
466
|
+
export function templatePrefixOf(pluginId) {
|
|
467
|
+
return pluginId.slice(pluginId.lastIndexOf(".") + 1).split("-").join("_");
|
|
468
|
+
}
|
|
469
|
+
/** The name a template uses for a plugin's filter or tag. */
|
|
470
|
+
export function templateNameOf(pluginId, name) {
|
|
471
|
+
return `${templatePrefixOf(pluginId)}_${name}`;
|
|
472
|
+
}
|
|
473
|
+
/** M32 F2 (D14): why a plugin id cannot carry template filters or tags, or null. */
|
|
474
|
+
export function templatePrefixProblem(pluginId) {
|
|
475
|
+
const segment = pluginId.slice(pluginId.lastIndexOf(".") + 1);
|
|
476
|
+
const word = templatePrefixOf(pluginId).split("_")[0];
|
|
477
|
+
if (RESERVED_TEMPLATE_WORDS.includes(word)) {
|
|
478
|
+
return `the plugin id's last segment "${segment}" opens with "${word}", which core template names use, so this plugin declares no template filters or tags`;
|
|
479
|
+
}
|
|
480
|
+
return null;
|
|
481
|
+
}
|
|
482
|
+
/** M35 P3 (W19): the tag that closes a plugin's block tag. */
|
|
483
|
+
export function templateBlockEndNameOf(fullName) {
|
|
484
|
+
return `end${fullName}`;
|
|
485
|
+
}
|
|
486
|
+
/** M35 P3 (W19): why a block tag's wrap class is refused, or null. One scan after the length check; the reason never quotes the value. */
|
|
487
|
+
export function templateBlockClassProblem(value) {
|
|
488
|
+
if (typeof value !== "string")
|
|
489
|
+
return "is not text";
|
|
490
|
+
if (value.length === 0)
|
|
491
|
+
return "is empty";
|
|
492
|
+
if (value.length > TEMPLATE_BLOCK_CLASS_MAX)
|
|
493
|
+
return `is more than ${TEMPLATE_BLOCK_CLASS_MAX} characters`;
|
|
494
|
+
for (const c of value) {
|
|
495
|
+
if (!(isLower(c) || isUpper(c) || isDigit(c) || c === "-" || c === "_" || c === " "))
|
|
496
|
+
return 'holds a character other than letters, digits, "-", "_" and spaces';
|
|
497
|
+
}
|
|
498
|
+
return null;
|
|
499
|
+
}
|
|
500
|
+
const KEEP_KEYS = new Set(["keepBody", "before", "after", "wrap"]);
|
|
501
|
+
const WRAP_KEYS = new Set(["element", "class"]);
|
|
502
|
+
/**
|
|
503
|
+
* M35 P3 (W19): a block tag's `{ keepBody: true, before?, after?, wrap? }` answer read without trusting it,
|
|
504
|
+
* or null when it is out of shape. `before` and `after` are text the binding cleans; the binding also measures
|
|
505
|
+
* them against TEMPLATE_OUTPUT_LIMIT_BYTES, before and after cleaning, so a long answer is reported as too large,
|
|
506
|
+
* not as out of shape. `wrap` names one of TEMPLATE_BLOCK_WRAP_ELEMENTS and an optional class. No other key. A
|
|
507
|
+
* null `before`, `after`, `wrap` or wrap `class` is read as absent, all four alike.
|
|
508
|
+
*/
|
|
509
|
+
export function readTemplateBlockKeep(answer) {
|
|
510
|
+
if (answer === null || typeof answer !== "object" || Array.isArray(answer) || answer.keepBody !== true)
|
|
511
|
+
return null;
|
|
512
|
+
for (const key of Object.keys(answer))
|
|
513
|
+
if (!KEEP_KEYS.has(key))
|
|
514
|
+
return null;
|
|
515
|
+
const before = answer.before ?? "";
|
|
516
|
+
const after = answer.after ?? "";
|
|
517
|
+
if (typeof before !== "string" || typeof after !== "string")
|
|
518
|
+
return null;
|
|
519
|
+
const rawWrap = answer.wrap ?? null;
|
|
520
|
+
if (rawWrap === null)
|
|
521
|
+
return { before, after, wrap: null };
|
|
522
|
+
if (typeof rawWrap !== "object" || Array.isArray(rawWrap))
|
|
523
|
+
return null;
|
|
524
|
+
for (const key of Object.keys(rawWrap))
|
|
525
|
+
if (!WRAP_KEYS.has(key))
|
|
526
|
+
return null;
|
|
527
|
+
const element = rawWrap.element;
|
|
528
|
+
if (typeof element !== "string" || !TEMPLATE_BLOCK_WRAP_ELEMENTS.includes(element))
|
|
529
|
+
return null;
|
|
530
|
+
const wrapClass = rawWrap.class ?? null;
|
|
531
|
+
if (wrapClass !== null && templateBlockClassProblem(wrapClass) !== null)
|
|
532
|
+
return null;
|
|
533
|
+
return { before, after, wrap: { element: element, class: wrapClass } };
|
|
534
|
+
}
|
|
535
|
+
const noControl = { message: "holds no control character" };
|
|
536
|
+
const headName = z
|
|
537
|
+
.string()
|
|
538
|
+
.min(1)
|
|
539
|
+
.max(100)
|
|
540
|
+
.refine(everyChar((c) => isLower(c) || isUpper(c) || isDigit(c) || c === ":" || c === "." || c === "_" || c === "-"), {
|
|
541
|
+
message: 'letters, digits, ":", ".", "_" and "-" only',
|
|
542
|
+
});
|
|
543
|
+
const headContent = z.string().max(PAGE_HEAD_CONTENT_MAX).refine(hasNoControlCharacter, noControl);
|
|
544
|
+
const headAddress = z
|
|
545
|
+
.string()
|
|
546
|
+
.min(1)
|
|
547
|
+
.max(SITE_LOCATION_MAX)
|
|
548
|
+
.refine(hasNoControlCharacter, noControl)
|
|
549
|
+
.refine((value) => !value.includes("\\"), { message: 'holds no "\\"' });
|
|
550
|
+
const controlFree = (min, max) => z.string().min(min).max(max).refine(hasNoControlCharacter, noControl);
|
|
551
|
+
const crossorigin = z.literal("anonymous");
|
|
552
|
+
const metaEntry = z
|
|
553
|
+
.strictObject({ tag: z.literal("meta"), name: headName.optional(), property: headName.optional(), content: headContent })
|
|
554
|
+
.superRefine((entry, ctx) => {
|
|
555
|
+
if ((entry.name === undefined) === (entry.property === undefined))
|
|
556
|
+
ctx.addIssue({ code: "custom", message: "a meta entry has exactly one of name and property" });
|
|
557
|
+
});
|
|
558
|
+
const linkEntry = z.strictObject({
|
|
559
|
+
tag: z.literal("link"),
|
|
560
|
+
rel: z.enum(PAGE_HEAD_LINK_RELS),
|
|
561
|
+
href: headAddress,
|
|
562
|
+
hreflang: z
|
|
563
|
+
.string()
|
|
564
|
+
.min(1)
|
|
565
|
+
.max(35)
|
|
566
|
+
.refine(everyChar((c) => isLower(c) || isUpper(c) || isDigit(c) || c === "-"), { message: 'letters, digits and "-" only' })
|
|
567
|
+
.optional(),
|
|
568
|
+
type: controlFree(1, 100).optional(),
|
|
569
|
+
media: controlFree(1, 200).optional(),
|
|
570
|
+
crossorigin: crossorigin.optional(),
|
|
571
|
+
});
|
|
572
|
+
const dataKey = z
|
|
573
|
+
.string()
|
|
574
|
+
.min(1)
|
|
575
|
+
.max(40)
|
|
576
|
+
.refine(everyChar((c) => isLower(c) || isDigit(c) || c === "-"), { message: 'lower-case letters, digits and "-" only' })
|
|
577
|
+
// M35 P5 (P5-D6): the core's own data- prefix carries an inert script's source and flags.
|
|
578
|
+
.refine((key) => !key.startsWith(CORE_DATA_PREFIX), { message: 'never starts with "kardalum-"' });
|
|
579
|
+
const scriptEntry = z.strictObject({
|
|
580
|
+
tag: z.literal("script"),
|
|
581
|
+
src: headAddress,
|
|
582
|
+
async: z.boolean().optional(),
|
|
583
|
+
defer: z.boolean().optional(),
|
|
584
|
+
module: z.boolean().optional(),
|
|
585
|
+
integrity: z
|
|
586
|
+
.string()
|
|
587
|
+
.min(1)
|
|
588
|
+
.max(200)
|
|
589
|
+
.refine(everyChar((c) => isLower(c) || isUpper(c) || isDigit(c) || c === "+" || c === "/" || c === "=" || c === "-"), { message: 'letters, digits, "+", "/", "=" and "-" only' })
|
|
590
|
+
.optional(),
|
|
591
|
+
crossorigin: crossorigin.optional(),
|
|
592
|
+
data: z
|
|
593
|
+
.record(dataKey, controlFree(0, 500))
|
|
594
|
+
.refine((data) => Object.keys(data).length <= 10, { message: "at most 10 data attributes" })
|
|
595
|
+
.optional(),
|
|
596
|
+
/** M35 P5 (P5-D6): written inert until the visitor grants this category. */
|
|
597
|
+
consent: z.enum(CONSENT_CATEGORIES).optional(),
|
|
598
|
+
});
|
|
599
|
+
function jsonLdFits(data) {
|
|
600
|
+
let text;
|
|
601
|
+
try {
|
|
602
|
+
text = JSON.stringify(data);
|
|
603
|
+
}
|
|
604
|
+
catch {
|
|
605
|
+
return false;
|
|
606
|
+
}
|
|
607
|
+
return typeof text === "string" && new TextEncoder().encode(text).length <= PAGE_HEAD_JSON_LD_MAX_BYTES;
|
|
608
|
+
}
|
|
609
|
+
const jsonLdEntry = z.strictObject({
|
|
610
|
+
tag: z.literal("jsonLd"),
|
|
611
|
+
data: z.unknown().refine(jsonLdFits, { message: `JSON of at most ${PAGE_HEAD_JSON_LD_MAX_BYTES} bytes` }),
|
|
612
|
+
});
|
|
613
|
+
/** M33 K27 (SEO 2.16 C5): the page's title, from a plugin that declares `pageHead.setsTitle`. The core
|
|
614
|
+
* writes it, escaped, in place of the layout's own; it is not one of the head's written entries. A
|
|
615
|
+
* title of whitespace alone is refused (dropped and logged like any refused entry), so it never
|
|
616
|
+
* blanks the layout's own title. */
|
|
617
|
+
const titleEntry = z.strictObject({
|
|
618
|
+
tag: z.literal("title"),
|
|
619
|
+
text: controlFree(1, PAGE_HEAD_TITLE_MAX).refine((text) => text.trim() !== "", { message: "a title with more than whitespace" }),
|
|
620
|
+
});
|
|
621
|
+
/** M35 P1 (W40): code written into the page itself, from a plugin that declares `pageHead.inlineSnippets`.
|
|
622
|
+
* The text is checked by inlineSnippetProblem in checkPageHeadEntry, never by this shape alone. */
|
|
623
|
+
const inlineText = z.string().min(1).max(PAGE_HEAD_INLINE_TEXT_MAX_BYTES);
|
|
624
|
+
const inlineScriptEntry = z.strictObject({ tag: z.literal("inlineScript"), text: inlineText, module: z.boolean().optional(), consent: z.enum(CONSENT_CATEGORIES).optional() });
|
|
625
|
+
const inlineStyleEntry = z.strictObject({ tag: z.literal("inlineStyle"), text: inlineText, media: controlFree(1, 200).optional() });
|
|
626
|
+
/** M32 F2: one entry a plugin adds to a page's <head>. */
|
|
627
|
+
export const PageHeadEntrySchema = z.discriminatedUnion("tag", [metaEntry, linkEntry, scriptEntry, jsonLdEntry, titleEntry, inlineScriptEntry, inlineStyleEntry]);
|
|
628
|
+
const HEAD_ENTRY_FIELDS = new Set(["name", "property", "content", "rel", "href", "hreflang", "type", "media", "crossorigin", "src", "async", "defer", "module", "integrity", "data", "text", "consent"]);
|
|
629
|
+
/** M33 K48: the longest file path the rule accepts, in characters. */
|
|
630
|
+
export const PLUGIN_PUBLIC_FILE_PATH_MAX = 200;
|
|
631
|
+
/**
|
|
632
|
+
* M33 K48: the one rule for every manifest field that names a file in the plugin's `public/` folder
|
|
633
|
+
* (a head script, a provider's widget script, a sign-in mark). A path of 1 to 200 characters whose
|
|
634
|
+
* segments hold letters, digits, "-", "_" and "." only, with no empty, "." or ".." segment and no
|
|
635
|
+
* leading "/". "%", "?", "#" and "\" are outside the set, so no encoded dot segment and no query can
|
|
636
|
+
* change what the address names. One linear scan; the length is checked first.
|
|
637
|
+
*/
|
|
638
|
+
export function isPluginPublicFilePath(path) {
|
|
639
|
+
if (typeof path !== "string" || path.length === 0 || path.length > PLUGIN_PUBLIC_FILE_PATH_MAX)
|
|
640
|
+
return false;
|
|
641
|
+
let segmentStart = 0;
|
|
642
|
+
let dots = 0;
|
|
643
|
+
for (let i = 0; i <= path.length; i += 1) {
|
|
644
|
+
const c = i < path.length ? path[i] : "/";
|
|
645
|
+
if (c === "/") {
|
|
646
|
+
const length = i - segmentStart;
|
|
647
|
+
if (length === 0)
|
|
648
|
+
return false;
|
|
649
|
+
if (dots === length && length > 0 && length <= 2)
|
|
650
|
+
return false; // "." or ".." (the empty case is refused above)
|
|
651
|
+
segmentStart = i + 1;
|
|
652
|
+
dots = 0;
|
|
653
|
+
continue;
|
|
654
|
+
}
|
|
655
|
+
if (c === ".")
|
|
656
|
+
dots += 1;
|
|
657
|
+
if (!(isLower(c) || isUpper(c) || isDigit(c) || c === "-" || c === "_" || c === "."))
|
|
658
|
+
return false;
|
|
659
|
+
}
|
|
660
|
+
return true;
|
|
661
|
+
}
|
|
662
|
+
/** Whether text[at, at + name.length) is `name` (lower-case ASCII) in any ASCII case. */
|
|
663
|
+
function asciiNameAt(text, at, name) {
|
|
664
|
+
if (at + name.length > text.length)
|
|
665
|
+
return false;
|
|
666
|
+
for (let index = 0; index < name.length; index += 1) {
|
|
667
|
+
const code = text.charCodeAt(at + index);
|
|
668
|
+
const lower = code >= 0x41 && code <= 0x5a ? code + 0x20 : code;
|
|
669
|
+
if (lower !== name.charCodeAt(index))
|
|
670
|
+
return false;
|
|
671
|
+
}
|
|
672
|
+
return true;
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* M35 P1 (W40): why an inline snippet's text is refused, or null. The core writes the text between
|
|
676
|
+
* `<script>` and `</script>` (or `<style>` and `</style>`) exactly as given, so it never holds what
|
|
677
|
+
* could end its element or change how the browser reads it: for a script `<!--`, `<script` and
|
|
678
|
+
* `</script` in any ASCII case, for a style `</style`. No control character (C0, DEL or C1, U+0080
|
|
679
|
+
* to U+009F) but tab, line feed and carriage return, and no lone surrogate (the bytes served must be
|
|
680
|
+
* the bytes hashed; plugin-head.ts serves a carriage return as a line feed, as a browser reads it). At most
|
|
681
|
+
* PAGE_HEAD_INLINE_TEXT_MAX_BYTES of UTF-8. The length is checked before the scan, which reads each
|
|
682
|
+
* code unit once. The reason never quotes the text.
|
|
683
|
+
*/
|
|
684
|
+
export function inlineSnippetProblem(tag, text) {
|
|
685
|
+
if (typeof text !== "string" || text.length === 0)
|
|
686
|
+
return "holds no text";
|
|
687
|
+
const tooLong = `is more than ${PAGE_HEAD_INLINE_TEXT_MAX_BYTES} bytes`;
|
|
688
|
+
if (text.length > PAGE_HEAD_INLINE_TEXT_MAX_BYTES)
|
|
689
|
+
return tooLong;
|
|
690
|
+
let bytes = 0;
|
|
691
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
692
|
+
const code = text.charCodeAt(index);
|
|
693
|
+
if (code >= 0xd800 && code <= 0xdbff) {
|
|
694
|
+
const next = index + 1 < text.length ? text.charCodeAt(index + 1) : 0;
|
|
695
|
+
if (next < 0xdc00 || next > 0xdfff)
|
|
696
|
+
return "holds a lone surrogate";
|
|
697
|
+
bytes += 4;
|
|
698
|
+
index += 1;
|
|
699
|
+
continue;
|
|
700
|
+
}
|
|
701
|
+
if (code >= 0xdc00 && code <= 0xdfff)
|
|
702
|
+
return "holds a lone surrogate";
|
|
703
|
+
if ((code < 0x20 && code !== 0x09 && code !== 0x0a && code !== 0x0d) || (code >= 0x7f && code <= 0x9f))
|
|
704
|
+
return "holds a control character";
|
|
705
|
+
bytes += code < 0x80 ? 1 : code < 0x800 ? 2 : 3;
|
|
706
|
+
if (code !== 0x3c)
|
|
707
|
+
continue;
|
|
708
|
+
if (tag === "inlineScript") {
|
|
709
|
+
if (text.startsWith("!--", index + 1))
|
|
710
|
+
return 'holds "<!--"';
|
|
711
|
+
if (asciiNameAt(text, index + 1, "script"))
|
|
712
|
+
return 'holds "<script"';
|
|
713
|
+
if (text.charCodeAt(index + 1) === 0x2f && asciiNameAt(text, index + 2, "script"))
|
|
714
|
+
return 'holds "</script"';
|
|
715
|
+
}
|
|
716
|
+
else if (text.charCodeAt(index + 1) === 0x2f && asciiNameAt(text, index + 2, "style")) {
|
|
717
|
+
return 'holds "</style"';
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
return bytes > PAGE_HEAD_INLINE_TEXT_MAX_BYTES ? tooLong : null;
|
|
721
|
+
}
|
|
722
|
+
/** The plugin's own browser file: `/plugin-assets/<id>/<version>/public/<file>`, the address the asset mount serves a file of the package's public/ folder at. */
|
|
723
|
+
function ownAssetPath(value, pluginId) {
|
|
724
|
+
const prefix = `/plugin-assets/${pluginId}/`;
|
|
725
|
+
if (!value.startsWith(prefix) || value.length > PAGE_HEAD_ASSET_PATH_MAX)
|
|
726
|
+
return false;
|
|
727
|
+
const rest = value.slice(prefix.length);
|
|
728
|
+
const versionEnd = rest.indexOf("/");
|
|
729
|
+
if (versionEnd <= 0)
|
|
730
|
+
return false;
|
|
731
|
+
// The version is one segment of the plugin's own release (semver, "~" allowed), never a dot segment.
|
|
732
|
+
const version = rest.slice(0, versionEnd);
|
|
733
|
+
if (version === "." || version === "..")
|
|
734
|
+
return false;
|
|
735
|
+
for (const c of version) {
|
|
736
|
+
if (!(isLower(c) || isUpper(c) || isDigit(c) || SEGMENT_EXTRA.has(c)))
|
|
737
|
+
return false;
|
|
738
|
+
}
|
|
739
|
+
const folder = "public/";
|
|
740
|
+
if (!rest.startsWith(folder, versionEnd + 1))
|
|
741
|
+
return false;
|
|
742
|
+
return isPluginPublicFilePath(rest.slice(versionEnd + 1 + folder.length));
|
|
743
|
+
}
|
|
744
|
+
/** Link rels a browser fetches (icon, manifest) or connects to (preconnect, dns-prefetch): a site path, the plugin's own file, or a declared origin. */
|
|
745
|
+
const FETCHING_LINK_RELS = new Set(["icon", "manifest", "preconnect", "dns-prefetch"]);
|
|
746
|
+
/** A meta name that sets a page-wide policy, which a plugin never does. */
|
|
747
|
+
const POLICY_META_NAMES = new Set(["referrer"]);
|
|
748
|
+
function fromDeclaredOrigin(value, scriptOrigins) {
|
|
749
|
+
let url;
|
|
750
|
+
try {
|
|
751
|
+
url = new URL(value);
|
|
752
|
+
}
|
|
753
|
+
catch {
|
|
754
|
+
return false;
|
|
755
|
+
}
|
|
756
|
+
return url.protocol === "https:" && url.username === "" && url.password === "" && scriptOrigins.includes(url.origin);
|
|
757
|
+
}
|
|
758
|
+
/** M32 F2: a page head entry checked against the plugin that gave it. The reason never quotes the value.
|
|
759
|
+
* M33 K27: a title entry only from a plugin whose attached declaration says `setsTitle: true`.
|
|
760
|
+
* M35 P1 (W40): an inline entry only from one whose declaration says `inlineSnippets: true`. */
|
|
761
|
+
export function checkPageHeadEntry(entry, scope) {
|
|
762
|
+
if (entry === null || typeof entry !== "object" || Array.isArray(entry))
|
|
763
|
+
return { ok: false, reason: "not an object" };
|
|
764
|
+
const tag = entry.tag;
|
|
765
|
+
if (tag !== "meta" && tag !== "link" && tag !== "script" && tag !== "jsonLd" && tag !== "title" && tag !== "inlineScript" && tag !== "inlineStyle") {
|
|
766
|
+
return { ok: false, reason: "unknown tag" };
|
|
767
|
+
}
|
|
768
|
+
if (tag === "title" && scope.setsTitle !== true)
|
|
769
|
+
return { ok: false, reason: "title entry from a plugin that does not declare setsTitle" };
|
|
770
|
+
if ((tag === "inlineScript" || tag === "inlineStyle") && scope.inlineSnippets !== true) {
|
|
771
|
+
return { ok: false, reason: `${tag} entry from a plugin that does not declare inlineSnippets` };
|
|
772
|
+
}
|
|
773
|
+
const parsed = PageHeadEntrySchema.safeParse(entry);
|
|
774
|
+
if (!parsed.success) {
|
|
775
|
+
const issue = parsed.error.issues[0];
|
|
776
|
+
const field = issue && typeof issue.path[0] === "string" ? issue.path[0] : undefined;
|
|
777
|
+
if (issue?.code === "unrecognized_keys")
|
|
778
|
+
return { ok: false, reason: `${tag} entry with an unknown key` };
|
|
779
|
+
return { ok: false, reason: field !== undefined && HEAD_ENTRY_FIELDS.has(field) ? `${tag} entry with a bad ${field}` : `malformed ${tag} entry` };
|
|
780
|
+
}
|
|
781
|
+
const value = parsed.data;
|
|
782
|
+
if (value.tag === "inlineScript" || value.tag === "inlineStyle") {
|
|
783
|
+
const problem = inlineSnippetProblem(value.tag, value.text);
|
|
784
|
+
return problem === null ? { ok: true, entry: value } : { ok: false, reason: `${value.tag} entry whose text ${problem}` };
|
|
785
|
+
}
|
|
786
|
+
if (value.tag === "meta" && value.name !== undefined && POLICY_META_NAMES.has(value.name.toLowerCase())) {
|
|
787
|
+
return { ok: false, reason: "meta entry that sets a page policy" };
|
|
788
|
+
}
|
|
789
|
+
if (value.tag === "script" || (value.tag === "link" && value.rel === "stylesheet")) {
|
|
790
|
+
const address = value.tag === "script" ? value.src : value.href;
|
|
791
|
+
if (!ownAssetPath(address, scope.pluginId) && !fromDeclaredOrigin(address, scope.scriptOrigins)) {
|
|
792
|
+
return { ok: false, reason: value.tag === "script" ? "script from an undeclared origin" : "stylesheet from an undeclared origin" };
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
else if (value.tag === "link" && FETCHING_LINK_RELS.has(value.rel)) {
|
|
796
|
+
const sitePath = value.href[0] === "/" && siteLocationProblem(value.href) === null;
|
|
797
|
+
if (!sitePath && !fromDeclaredOrigin(value.href, scope.scriptOrigins)) {
|
|
798
|
+
return { ok: false, reason: `${value.rel} link to an undeclared origin` };
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
else if (value.tag === "link" && siteLocationProblem(value.href) !== null) {
|
|
802
|
+
return { ok: false, reason: "link to an address that is not a site path or an http or https URL" };
|
|
803
|
+
}
|
|
804
|
+
return { ok: true, entry: value };
|
|
805
|
+
}
|
|
806
|
+
/** M35 P2 (W2): a redirect a plugin answers instead of the page: the site fallback's, and a request guard's.
|
|
807
|
+
* A site path or an http or https URL (siteLocationProblem), one of SITE_REDIRECT_STATUSES. */
|
|
808
|
+
export const SiteRedirectAnswerSchema = z.strictObject({
|
|
809
|
+
redirect: z.strictObject({
|
|
810
|
+
location: z.string().refine((value) => siteLocationProblem(value) === null, { message: 'a site path starting with "/" or an http or https URL' }),
|
|
811
|
+
status: z.literal(SITE_REDIRECT_STATUSES),
|
|
812
|
+
maxAgeSeconds: z.number().int().min(0).max(SITE_REDIRECT_MAX_AGE_MAX).optional(),
|
|
813
|
+
}),
|
|
814
|
+
});
|
|
815
|
+
/** M32 F2: what a plugin's site fallback answers for an address no page holds. */
|
|
816
|
+
export const SiteFallbackAnswerSchema = z.union([SiteRedirectAnswerSchema, z.strictObject({ gone: z.literal(true) })]);
|
|
817
|
+
const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
818
|
+
function checkTemplateList(key, value, issues) {
|
|
819
|
+
const at = ["contributions", key];
|
|
820
|
+
if (!Array.isArray(value)) {
|
|
821
|
+
issues.push({ path: at, message: "is a list of { name } entries" });
|
|
822
|
+
return false;
|
|
823
|
+
}
|
|
824
|
+
if (value.length > TEMPLATE_EXTENSIONS_MAX) {
|
|
825
|
+
issues.push({ path: at, message: `declares at most ${TEMPLATE_EXTENSIONS_MAX} entries` });
|
|
826
|
+
return true;
|
|
827
|
+
}
|
|
828
|
+
const seen = new Set();
|
|
829
|
+
value.forEach((entry, index) => {
|
|
830
|
+
const name = isRecord(entry) ? entry.name : undefined;
|
|
831
|
+
if (typeof name !== "string" || !isTemplateExtensionName(name)) {
|
|
832
|
+
issues.push({ path: [...at, index, "name"], message: `a name of 1 to ${TEMPLATE_NAME_MAX} lower-case letters, digits and "_", starting with a letter` });
|
|
833
|
+
return;
|
|
834
|
+
}
|
|
835
|
+
if (seen.has(name))
|
|
836
|
+
issues.push({ path: [...at, index, "name"], message: "declares each name once" });
|
|
837
|
+
seen.add(name);
|
|
838
|
+
// M35 P3 (W19, evidence 116): a tag's block and failure choice, a filter's failure choice.
|
|
839
|
+
const record = entry;
|
|
840
|
+
if (record.block !== undefined && (key !== "templateTags" || record.block !== true)) {
|
|
841
|
+
issues.push({ path: [...at, index, "block"], message: key === "templateTags" ? "is true when declared" : "is for a template tag only" });
|
|
842
|
+
}
|
|
843
|
+
if (record.onFailure !== undefined) {
|
|
844
|
+
const allowed = key === "templateFilters" ? TEMPLATE_FILTER_ON_FAILURE : record.block === true ? TEMPLATE_BLOCK_ON_FAILURE : [];
|
|
845
|
+
if (typeof record.onFailure !== "string" || !allowed.includes(record.onFailure)) {
|
|
846
|
+
issues.push({
|
|
847
|
+
path: [...at, index, "onFailure"],
|
|
848
|
+
message: key === "templateFilters" ? `is one of ${TEMPLATE_FILTER_ON_FAILURE.join(", ")}` : record.block === true ? `is one of ${TEMPLATE_BLOCK_ON_FAILURE.join(", ")}` : "is for a block tag only (block: true)",
|
|
849
|
+
});
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
});
|
|
853
|
+
return value.length > 0;
|
|
854
|
+
}
|
|
855
|
+
/** M32 F2: the site extension rules over a manifest (live or manifest.json), as `path: message` issues. */
|
|
856
|
+
export function checkSiteExtensionDeclarations(manifest) {
|
|
857
|
+
const contributions = manifest.contributions;
|
|
858
|
+
if (!isRecord(contributions))
|
|
859
|
+
return [];
|
|
860
|
+
const issues = [];
|
|
861
|
+
const routes = contributions.siteRoutes;
|
|
862
|
+
if (routes !== undefined) {
|
|
863
|
+
if (!Array.isArray(routes)) {
|
|
864
|
+
issues.push({ path: ["contributions", "siteRoutes"], message: "is a list of { method, path } entries" });
|
|
865
|
+
}
|
|
866
|
+
else if (routes.length > SITE_ROUTES_MAX) {
|
|
867
|
+
issues.push({ path: ["contributions", "siteRoutes"], message: `declares at most ${SITE_ROUTES_MAX} routes` });
|
|
868
|
+
}
|
|
869
|
+
else {
|
|
870
|
+
const seen = new Set();
|
|
871
|
+
routes.forEach((route, index) => {
|
|
872
|
+
const at = ["contributions", "siteRoutes", index];
|
|
873
|
+
if (!isRecord(route) || typeof route.method !== "string" || typeof route.path !== "string") {
|
|
874
|
+
issues.push({ path: at, message: "a route has a string method and path" });
|
|
875
|
+
return;
|
|
876
|
+
}
|
|
877
|
+
const methodOk = SITE_ROUTE_METHODS.includes(route.method);
|
|
878
|
+
const read = readSiteRoutePath(route.method, route.path);
|
|
879
|
+
if (!read.ok) {
|
|
880
|
+
issues.push({ path: [...at, methodOk ? "path" : "method"], message: read.problem });
|
|
881
|
+
return;
|
|
882
|
+
}
|
|
883
|
+
// M35 P3 (W18): one route per method and shape, so `/shop/:id` and `/shop/:slug` cannot both stand.
|
|
884
|
+
const key = read.pattern.shape;
|
|
885
|
+
if (seen.has(key))
|
|
886
|
+
issues.push({ path: at, message: "declares each method and path once" });
|
|
887
|
+
seen.add(key);
|
|
888
|
+
// M35 P2 (W21): the exact bytes, only on a POST route.
|
|
889
|
+
const rawBody = siteRouteRawBodyProblem(route);
|
|
890
|
+
if (rawBody !== null)
|
|
891
|
+
issues.push({ path: [...at, "rawBody"], message: rawBody });
|
|
892
|
+
// M35 B3 (W17): files, on a POST site route without rawBody, within the upload limits.
|
|
893
|
+
const uploads = routeUploadsProblem(route, SITE_ROUTE_UPLOAD_METHODS, "site route");
|
|
894
|
+
if (uploads !== null)
|
|
895
|
+
issues.push({ path: [...at, "uploads"], message: uploads });
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
const fallback = contributions.siteFallback;
|
|
900
|
+
if (fallback !== undefined && fallback !== true && !isRecord(fallback)) {
|
|
901
|
+
issues.push({ path: ["contributions", "siteFallback"], message: "is true or an object" });
|
|
902
|
+
}
|
|
903
|
+
for (const key of ["templateFilters", "templateTags"]) {
|
|
904
|
+
const value = contributions[key];
|
|
905
|
+
if (value === undefined)
|
|
906
|
+
continue;
|
|
907
|
+
const nonEmpty = checkTemplateList(key, value, issues);
|
|
908
|
+
if (nonEmpty && typeof manifest.id === "string") {
|
|
909
|
+
const problem = templatePrefixProblem(manifest.id);
|
|
910
|
+
if (problem !== null)
|
|
911
|
+
issues.push({ path: ["contributions", key], message: problem });
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
const head = contributions.pageHead;
|
|
915
|
+
if (head !== undefined) {
|
|
916
|
+
if (!isRecord(head)) {
|
|
917
|
+
issues.push({ path: ["contributions", "pageHead"], message: "is an object" });
|
|
918
|
+
}
|
|
919
|
+
else if (head.scriptOrigins !== undefined) {
|
|
920
|
+
const origins = head.scriptOrigins;
|
|
921
|
+
const at = ["contributions", "pageHead", "scriptOrigins"];
|
|
922
|
+
if (!Array.isArray(origins)) {
|
|
923
|
+
issues.push({ path: at, message: "is a list of https origins" });
|
|
924
|
+
}
|
|
925
|
+
else if (origins.length > PAGE_HEAD_SCRIPT_ORIGINS_MAX) {
|
|
926
|
+
issues.push({ path: at, message: `declares at most ${PAGE_HEAD_SCRIPT_ORIGINS_MAX} origins` });
|
|
927
|
+
}
|
|
928
|
+
else {
|
|
929
|
+
const seen = new Set();
|
|
930
|
+
origins.forEach((origin, index) => {
|
|
931
|
+
if (typeof origin !== "string" || !PageHeadScriptOriginSchema.safeParse(origin).success) {
|
|
932
|
+
issues.push({ path: [...at, index], message: "an https origin with no path, user name or trailing slash" });
|
|
933
|
+
return;
|
|
934
|
+
}
|
|
935
|
+
if (seen.has(origin))
|
|
936
|
+
issues.push({ path: [...at, index], message: "declares each origin once" });
|
|
937
|
+
seen.add(origin);
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
// M33 K27: the one declaration that lets a plugin's title entry set the page title.
|
|
942
|
+
if (isRecord(head) && head.setsTitle !== undefined && head.setsTitle !== true) {
|
|
943
|
+
issues.push({ path: ["contributions", "pageHead", "setsTitle"], message: "is true when declared" });
|
|
944
|
+
}
|
|
945
|
+
// M35 P1 (W40): the one declaration that lets a plugin's head write inline code.
|
|
946
|
+
if (isRecord(head) && head.inlineSnippets !== undefined && head.inlineSnippets !== true) {
|
|
947
|
+
issues.push({ path: ["contributions", "pageHead", "inlineSnippets"], message: "is true when declared" });
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
// M33 K42: held content from other sites, by the rules of plugin-held-embeds.ts, each issue under
|
|
951
|
+
// its entry's own path.
|
|
952
|
+
const held = contributions.heldEmbeds;
|
|
953
|
+
if (held !== undefined) {
|
|
954
|
+
const parsed = PluginHeldEmbedsSchema.safeParse(held);
|
|
955
|
+
if (!parsed.success) {
|
|
956
|
+
for (const issue of parsed.error.issues) {
|
|
957
|
+
issues.push({ path: ["contributions", "heldEmbeds", ...issue.path.filter((part) => typeof part !== "symbol")], message: issue.message });
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
// M35 P1 (W3): the page output transform. manifest.json carries `true` (the transform is code, which the
|
|
962
|
+
// writer cannot keep), the live manifest an object, whose shape the SDK's manifest schema checks.
|
|
963
|
+
const output = contributions.pageOutput;
|
|
964
|
+
if (output !== undefined && output !== true && !isRecord(output)) {
|
|
965
|
+
issues.push({ path: ["contributions", "pageOutput"], message: "is true or an object" });
|
|
966
|
+
}
|
|
967
|
+
// M35 P2 (W2): the request guard and the response headers. manifest.json carries `true` (each is code,
|
|
968
|
+
// which the writer cannot keep), the live manifest an object, whose shape the SDK's manifest schema checks.
|
|
969
|
+
// M35 P4 (W32, W46): and the page cache and the page gate.
|
|
970
|
+
for (const key of ["requestGuard", "responseHeaders", "pageCache", "pageGate"]) {
|
|
971
|
+
const declared = contributions[key];
|
|
972
|
+
if (declared !== undefined && declared !== true && !isRecord(declared))
|
|
973
|
+
issues.push({ path: ["contributions", key], message: "is true or an object" });
|
|
974
|
+
}
|
|
975
|
+
return issues;
|
|
976
|
+
}
|