Repository navigation
Conversation
…ants Problem: the stringly-typed fields in a signed manifest — `mode`, `pathRules[].type`, `contentRules[].action.type`, `signatureType`, `logsMinLevel` were authored as ad-hoc string literals in build configs and dropped silently if misspelled: the loader's permissive normalizer would warn+fallback at runtime, but the signer happily produced the broken manifest and operators had no way to catch the typo before deploy. This change: 1. Extracts the stringly-typed values into frozen enums in `@dappfence/core/constants` (`MODE`, `PATH_RULE_TYPE`, `CONTENT_ACTION_TYPE`, `SIGNATURE_TYPE`, `LOG_LEVEL`), each with a matching JSDoc `@typedef`. These are the single source of truth for both the signer and the SW loader. 2. Adds `@dappfence/manifest-tools/validate` — a strict `assertValidManifestPayload` that throws on any unknown enum value, malformed sha256 hash, malformed URL, or type mismatch. Exposed via `./validate` subpath export so build tools can call it directly. 3. Wires `signManifest` to call the validator by default (with a `skipValidation: true` escape for tests that exercise malformed payloads on purpose).
Wire the shared constants into the SW's manifest handling so string literals can't drift, and extend signManifest to honor the declared signatureType.
✅ Deploy Preview for dappfence-templates canceled.
|
Collaborator
|
When validation catches a config typo (e.g. mode: 'PROTECTED' instead of 'protected'), |
The try/catch in generateManifest swallowed signing errors, logged them at `logger.error`, and wrote an unsigned manifest. Builds still exited 0, so a config typo like `mode: 'PROTECTED'` would silently deploy an unsigned manifest — defeating the strict validator added alongside signManifest in this PR. Remove the catch: signing failures (validation, bad key, crypto) now abort the build. The existing `else` branch still handles the unsigned dev path when no secretKey is provided.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem: the stringly-typed fields in a signed manifest
mode,pathRules[].type,contentRules[].action.type,signatureType,logsMinLevelwere authored as ad-hoc string literals in buildconfigs and dropped silently if misspelled: the loader's permissive
normalizer would warn+fallback at runtime, but the signer happily
produced the broken manifest and operators had no way to catch the
typo before deploy.
This change:
@dappfence/core/constants(MODE,PATH_RULE_TYPE,CONTENT_ACTION_TYPE,SIGNATURE_TYPE,LOG_LEVEL), each with amatching JSDoc
@typedef. These are the single source of truthfor both the signer and the SW loader.
@dappfence/manifest-tools/validate— a strictassertValidManifestPayloadthat throws on any unknown enum value,malformed sha256 hash, malformed URL, or type mismatch. Exposed via
./validatesubpath export so build tools can call it directly.signManifestto call the validator by default (with askipValidation: trueescape for tests that exercise malformedpayloads on purpose).