@mouryaamit/nx-polystack 1.23.0 → 1.24.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/README.md +120 -1
- package/USER-MANUAL.md +21 -4
- package/dist/bin/cli.js +6 -0
- package/dist/bin/cli.js.map +1 -1
- package/dist/src/cli/versions.d.ts +8 -0
- package/dist/src/cli/versions.js +23 -5
- package/dist/src/cli/versions.js.map +1 -1
- package/dist/src/lib/utils/devkit-deps.js +14 -1
- package/dist/src/lib/utils/devkit-deps.js.map +1 -1
- package/package.json +8 -1
- package/runtime/csp-nonce.js +22 -2
- package/runtime/csp-style-attr.js +51 -0
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ pipeline into every app, so they are all built the same way.
|
|
|
10
10
|
## Install
|
|
11
11
|
|
|
12
12
|
```bash
|
|
13
|
-
npm i -g @mouryaamit/nx-polystack
|
|
13
|
+
npm i -g @mouryaamit/nx-polystack nx@22 @nx/devkit@22
|
|
14
14
|
pstack new my-workspace --npmScope=acme --ci=github-actions
|
|
15
15
|
cd my-workspace
|
|
16
16
|
pstack app --type=angular --name=portal
|
|
@@ -23,6 +23,10 @@ pstack app --from=portal --name=partner-portal # a copy of portal, env values
|
|
|
23
23
|
pinned copy, so output always matches the workspace's version. Move a workspace to a new release
|
|
24
24
|
with `pstack update`, which installs it and runs its migrations.
|
|
25
25
|
|
|
26
|
+
`nx` and `@nx/devkit` are optional peer dependencies (since 1.24.0, so apps that only import a
|
|
27
|
+
runtime file do not get Nx), which is why the global install names them; without them, commands
|
|
28
|
+
that need them stop with this install hint.
|
|
29
|
+
|
|
26
30
|
Requires Node 20 and npm 10+. `pstack new` creates Nx 17 workspaces on Angular 15 or, with
|
|
27
31
|
`--angular=16`, Angular 16, and Nx 18 workspaces with `--angular=17`; the plugin itself loads in workspaces on Nx 17 to 22.
|
|
28
32
|
|
|
@@ -134,6 +138,121 @@ npx nx list @mouryaamit/nx-polystack
|
|
|
134
138
|
npx nx g @mouryaamit/nx-polystack:app --type=angular --name=portal
|
|
135
139
|
```
|
|
136
140
|
|
|
141
|
+
## Phase 1 – runtime only
|
|
142
|
+
|
|
143
|
+
An Angular 15 app that is not in a pstack workspace yet (a plain Angular CLI repo) can use the CSP
|
|
144
|
+
nonce runtime on its own. It needs no `nx.json` and no workspace config, and the install brings in
|
|
145
|
+
no Nx and runs no install scripts (only `tslib` comes with it):
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
npm i -E @mouryaamit/nx-polystack@1.24.0 # or the team's git copy, e.g. "<package>@git+https://…#dist-v1.24.0"
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
First line of `src/main.ts` (a renamed copy uses its own package name):
|
|
152
|
+
|
|
153
|
+
```ts
|
|
154
|
+
import '@mouryaamit/nx-polystack/runtime/csp-nonce';
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
It gives the page nonce to the `<style>`, `<script>` and `<link rel="stylesheet">` elements that
|
|
158
|
+
Angular 15 and webpack add at runtime (inserted via `appendChild`, `insertBefore`, `append`, … on
|
|
159
|
+
the document, elements and shadow roots). Runtime 1.24.0 behaves the same as the 1.2.2 runtime
|
|
160
|
+
(the file is unchanged apart from the warning below).
|
|
161
|
+
|
|
162
|
+
**Server side.** The nonce must be new on every response, and the same value must appear in the CSP
|
|
163
|
+
header and in `index.html`:
|
|
164
|
+
|
|
165
|
+
- `<meta property="csp-nonce" content="…">` in `<head>` (preferred: the runtime reads it even
|
|
166
|
+
when an inline script is not allowed), or an inline
|
|
167
|
+
`<script nonce="…">window.__cspNonce = '…';</script>` before the app's scripts. The runtime
|
|
168
|
+
reads `window.__cspNonce` first, then the meta tag (`property="csp-nonce"` or `name="csp-nonce"`).
|
|
169
|
+
- `nonce="…"` on every `<script>`, `<link rel="stylesheet">` and `<style>` in the built
|
|
170
|
+
`index.html`. Angular 15 does not add these; pstack's release build does, and outside a workspace
|
|
171
|
+
the app's own post-build step must (for example one that writes the SSI directive below).
|
|
172
|
+
|
|
173
|
+
With Apache, mod_include (SSI) fills the value. In `index.html` (single quotes inside the
|
|
174
|
+
directive, so an unprocessed directive cannot end the double-quoted attribute):
|
|
175
|
+
|
|
176
|
+
```html
|
|
177
|
+
<meta property="csp-nonce" content="<!--#echo var='CSP_NONCE' -->" />
|
|
178
|
+
<script src="main.js" type="module" nonce="<!--#echo var='CSP_NONCE' -->"></script>
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
`.htaccess` next to `index.html` (needs `mod_rewrite`, `mod_headers`, `mod_include`,
|
|
182
|
+
`mod_unique_id` and `mod_setenvif`, and `AllowOverride FileInfo Options=IncludesNOEXEC` for the
|
|
183
|
+
folder). This is what `pstack csp` writes, reduced to the CSP parts:
|
|
184
|
+
|
|
185
|
+
```apache
|
|
186
|
+
RewriteEngine On
|
|
187
|
+
RewriteCond %{REQUEST_FILENAME} !-f
|
|
188
|
+
RewriteCond %{REQUEST_FILENAME} !-d
|
|
189
|
+
RewriteRule ^ index.html [L]
|
|
190
|
+
|
|
191
|
+
# Per-request nonce: UNIQUE_ID without "@" (not allowed in a nonce). reqenv() reads the
|
|
192
|
+
# environment only, so request headers cannot set it. Repeat the second line 8 times in all.
|
|
193
|
+
SetEnvIfExpr "reqenv('UNIQUE_ID') =~ /^(.+)$/" CSP_NONCE=$1
|
|
194
|
+
SetEnvIfExpr "reqenv('CSP_NONCE') =~ /^([^@]*)@(.*)$/" CSP_NONCE=$1_$2
|
|
195
|
+
|
|
196
|
+
Options +IncludesNOEXEC
|
|
197
|
+
<Files "index.html">
|
|
198
|
+
SetOutputFilter INCLUDES
|
|
199
|
+
Header always set Cache-Control "no-store"
|
|
200
|
+
</Files>
|
|
201
|
+
|
|
202
|
+
Header always set Content-Security-Policy "script-src 'self' 'nonce-%{CSP_NONCE}e' 'strict-dynamic'; style-src 'self' 'nonce-%{CSP_NONCE}e'; object-src 'none'; base-uri 'self'"
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
**When the value is not filled in.** A value that is not a real nonce (the SSI directive left as
|
|
206
|
+
is, Apache's `(none)` for an unset variable, or a placeholder such as `random-csp-nonce`) counts as
|
|
207
|
+
no nonce: nothing is patched, so runtime styles and scripts are blocked. Since 1.24.0 the runtime
|
|
208
|
+
then logs one console warning, `[pstack csp-nonce] The CSP nonce was not filled in …`. No value at
|
|
209
|
+
all (e.g. `ng serve` without a CSP) stays silent. If the server fills nothing, the browser usually
|
|
210
|
+
blocks the app's own scripts first (their `nonce` attributes are unfilled too, and Angular 16+
|
|
211
|
+
copies `ngCspNonce` onto its script tags), so the runtime never runs: the browser's CSP errors
|
|
212
|
+
are then the signal.
|
|
213
|
+
|
|
214
|
+
## Style attributes under a strict CSP: runtime/csp-style-attr (opt-in, 1.24.0)
|
|
215
|
+
|
|
216
|
+
Under `style-src` without `'unsafe-inline'`, `element.setAttribute('style', …)` is blocked
|
|
217
|
+
(`style-src-attr`), but the same declarations written through the CSSOM (`element.style.cssText`)
|
|
218
|
+
are allowed. Angular writes static `style="…"` in templates, host styles and `[attr.style]` with
|
|
219
|
+
`setAttribute('style')`, and so do libraries (NgbModal backdrop, NgbTooltip, NgbPopover,
|
|
220
|
+
ngx-extended-pdf-viewer). This opt-in runtime routes those writes to the CSSOM. Angular 15–21 need
|
|
221
|
+
it (Angular 21 for the NgbModal backdrop and NgbPopover). Import it right after the nonce runtime:
|
|
222
|
+
|
|
223
|
+
```ts
|
|
224
|
+
import '@mouryaamit/nx-polystack/runtime/csp-nonce';
|
|
225
|
+
import '@mouryaamit/nx-polystack/runtime/csp-style-attr';
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
It replaces `Element.prototype.setAttribute` and `setAttributeNS` so that only
|
|
229
|
+
`setAttribute('style', v)` (any case) and `setAttributeNS(null, 'style', v)` become
|
|
230
|
+
`el.style.cssText = v`; every other attribute and namespace goes to the original method. It does
|
|
231
|
+
not depend on the nonce. Angular 21's builder warns that the two runtime files are not ESM; that is
|
|
232
|
+
harmless (they are side-effect-only scripts), and `allowedCommonJsDependencies` silences it.
|
|
233
|
+
|
|
234
|
+
Conditions of use (any change to the patch needs a new security review):
|
|
235
|
+
|
|
236
|
+
- **F1 – no user-controlled data** in `[attr.style]`, `[style]`, `[ngStyle]` or
|
|
237
|
+
`setAttribute('style', …)`. The patch lifts the CSP block on these writes, so CSS from user input
|
|
238
|
+
would be applied (CSS injection: overlays, data exfiltration through `url()`).
|
|
239
|
+
- **F2 – no CSP reports for these writes.** They no longer raise `securitypolicyviolation` events
|
|
240
|
+
or reports. Keep CSP reporting on for everything else.
|
|
241
|
+
- **F3 – only `setAttribute` / `setAttributeNS` are patched.** `setAttributeNode`,
|
|
242
|
+
`attributes.setNamedItem` and `Attr.value` still set the attribute and stay blocked.
|
|
243
|
+
- **F4 – `getAttribute('style')` returns normalised text.** The browser's serialisation is
|
|
244
|
+
returned, not the string written, and declarations the browser does not support are dropped
|
|
245
|
+
(`'color: rgb(0, 0, 255); -x-unknown: 1'` reads back as `'color: rgb(0, 0, 255);'`).
|
|
246
|
+
- **F5 – import order and rollback.** Import it right after `runtime/csp-nonce`. To roll back,
|
|
247
|
+
remove the line.
|
|
248
|
+
|
|
249
|
+
Not covered (still blocked by `style-src-attr`): `style="…"` in markup parsed by the HTML parser,
|
|
250
|
+
i.e. `innerHTML`, `insertAdjacentHTML`, `[innerHTML]` content and static `index.html` markup
|
|
251
|
+
(for example ngx-extended-pdf-viewer's thumbnails, one report per page, which it builds with `innerHTML`).
|
|
252
|
+
Static `style="…"` written in Angular templates is not parser markup: Angular sets it with
|
|
253
|
+
`setAttribute`, so it is covered. Trusted Types and inline event handlers
|
|
254
|
+
(`setAttribute('onclick', …)`) are unaffected.
|
|
255
|
+
|
|
137
256
|
## Contributing and security
|
|
138
257
|
|
|
139
258
|
See [CONTRIBUTING.md](CONTRIBUTING.md) and [SECURITY.md](SECURITY.md). Changes are listed in
|
package/USER-MANUAL.md
CHANGED
|
@@ -67,12 +67,15 @@ that target Angular, Ionic, Flutter, Android, and iOS from a single workspace. I
|
|
|
67
67
|
### Option A — global install (recommended)
|
|
68
68
|
|
|
69
69
|
```bash
|
|
70
|
-
npm i -g @mouryaamit/nx-polystack
|
|
70
|
+
npm i -g @mouryaamit/nx-polystack nx@22 @nx/devkit@22
|
|
71
71
|
pstack --version
|
|
72
72
|
pstack --help
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
-
Requires npm 7
|
|
75
|
+
Requires npm 7+. Since v1.24.0 `nx` and `@nx/devkit` are optional peer dependencies (so an app that
|
|
76
|
+
only imports a runtime file, such as `runtime/csp-nonce`, does not get Nx), so the global install
|
|
77
|
+
names them. `pstack new`, `preset`, `upgrade` and `migrate` need them; without them those commands
|
|
78
|
+
stop with the install command. `pstack --help` and `pstack update` print it too.
|
|
76
79
|
|
|
77
80
|
Note: `npm install` inside a new workspace (run by `pstack new`) downloads sharp's prebuilt binaries, so it needs network access.
|
|
78
81
|
|
|
@@ -946,9 +949,23 @@ blocks them (Angular 15 has no built-in nonce support).
|
|
|
946
949
|
- `append`/`prepend`/`before`/`after`/`replaceWith`/`insertAdjacentElement`.
|
|
947
950
|
- **Where the nonce comes from:** `window.__cspNonce`, or the `csp-nonce` meta tag that
|
|
948
951
|
`release --secure` writes. An SSI directive the server did not process, or a placeholder such as
|
|
949
|
-
`random-csp-nonce`, counts as no nonce, and nothing is patched.
|
|
952
|
+
`random-csp-nonce`, counts as no nonce, and nothing is patched. Since v1.24.0 that case logs one
|
|
953
|
+
console warning (`[pstack csp-nonce] The CSP nonce was not filled in …`); no value at all
|
|
954
|
+
(e.g. `ng serve` without a CSP) stays silent.
|
|
950
955
|
- **Existing apps:** `pstack update` (migration `add-csp-nonce-import`) adds the import to apps
|
|
951
956
|
with the polystack release target. It never removes a local nonce patch import.
|
|
957
|
+
- **Outside a workspace:** an Angular CLI app can install the package and import only this file;
|
|
958
|
+
see "Phase 1 – runtime only" in the README for the server side.
|
|
959
|
+
|
|
960
|
+
#### Style attributes at runtime (v1.24.0, opt-in)
|
|
961
|
+
|
|
962
|
+
`@mouryaamit/nx-polystack/runtime/csp-style-attr`, imported right after `runtime/csp-nonce`, routes
|
|
963
|
+
`setAttribute('style', v)` and `setAttributeNS(null, 'style', v)` to `el.style.cssText = v`, which
|
|
964
|
+
`style-src` without `'unsafe-inline'` allows. That covers static template and host styles,
|
|
965
|
+
`[attr.style]` and libraries such as NgbModal, NgbTooltip, NgbPopover and ngx-extended-pdf-viewer,
|
|
966
|
+
on Angular 15–21. Its conditions of use (no user-controlled data, no CSP reports for these writes,
|
|
967
|
+
what stays blocked, normalised `getAttribute('style')`, import order and rollback) are in the
|
|
968
|
+
README section "Style attributes under a strict CSP". pstack does not add the import; apps opt in.
|
|
952
969
|
|
|
953
970
|
#### Env encryption settings (v0.25.0)
|
|
954
971
|
|
|
@@ -2053,7 +2070,7 @@ if it was stripped by the TypeScript compiler.
|
|
|
2053
2070
|
version shown differs from what was installed, you may have a stale global install:
|
|
2054
2071
|
|
|
2055
2072
|
```bash
|
|
2056
|
-
npm i -g @mouryaamit/nx-polystack@latest
|
|
2073
|
+
npm i -g @mouryaamit/nx-polystack@latest nx@22 @nx/devkit@22
|
|
2057
2074
|
```
|
|
2058
2075
|
|
|
2059
2076
|
Inside a workspace whose local plugin version differs from the global CLI, `pstack -v` prints the global
|
package/dist/bin/cli.js
CHANGED
|
@@ -10,6 +10,7 @@ const context_1 = require("../src/cli/context");
|
|
|
10
10
|
const help_1 = require("../src/cli/help");
|
|
11
11
|
const launcher_1 = require("../src/cli/launcher");
|
|
12
12
|
const types_1 = require("../src/cli/types");
|
|
13
|
+
const versions_1 = require("../src/cli/versions");
|
|
13
14
|
async function main(argv) {
|
|
14
15
|
const { command, positionals, flags } = (0, args_1.parseArgs)(argv);
|
|
15
16
|
const selfRoot = (0, context_1.selfPackageRoot)(__dirname);
|
|
@@ -85,6 +86,11 @@ async function main(argv) {
|
|
|
85
86
|
return await handler(ctx);
|
|
86
87
|
}
|
|
87
88
|
catch (err) {
|
|
89
|
+
const hint = (0, versions_1.missingNxPeerHint)(err);
|
|
90
|
+
if (hint) {
|
|
91
|
+
console.error(`\nError: ${hint}`);
|
|
92
|
+
return 1;
|
|
93
|
+
}
|
|
88
94
|
const message = err instanceof Error ? err.message : String(err);
|
|
89
95
|
console.error(`\nError: ${message}`);
|
|
90
96
|
if (verbose && !(err instanceof types_1.CliError) && err instanceof Error && err.stack) {
|
package/dist/bin/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../bin/cli.ts"],"names":[],"mappings":";AAAA,wEAAwE;;;AAExE,mDAA6B;AAE7B,0CAAyD;AACzD,kDAA+C;AAC/C,gDAK4B;AAC5B,0CAA2C;AAC3C,kDAQ6B;AAC7B,4CAA4D;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../bin/cli.ts"],"names":[],"mappings":";AAAA,wEAAwE;;;AAExE,mDAA6B;AAE7B,0CAAyD;AACzD,kDAA+C;AAC/C,gDAK4B;AAC5B,0CAA2C;AAC3C,kDAQ6B;AAC7B,4CAA4D;AAC5D,kDAAwD;AAExD,KAAK,UAAU,IAAI,CAAC,IAAc;IAChC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,IAAA,gBAAS,EAAC,IAAI,CAAC,CAAC;IACxD,MAAM,QAAQ,GAAG,IAAA,yBAAe,EAAC,SAAS,CAAC,CAAC;IAC5C,MAAM,WAAW,GAAG,IAAA,4BAAkB,EAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC;IAC5E,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC1B,MAAM,MAAM,GAAG,IAAA,2BAAiB,EAAC,GAAG,CAAC,CAAC;IACtC,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,IAAA,4BAAkB,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC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CAAC,CACF,CAAC"}
|
|
@@ -43,3 +43,11 @@ export declare function parsePluginSpec(spec: string, source?: InstallSource): s
|
|
|
43
43
|
* to GitHub; `gh` downloads with the user's GitHub login.
|
|
44
44
|
*/
|
|
45
45
|
export declare function globalInstallCommand(version: string, source?: InstallSource, name?: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* nx and @nx/devkit are optional peers since 1.24.0 (so apps that only import a runtime file do
|
|
48
|
+
* not get Nx), so the global CLI is installed with them: `pstack new` writes the new workspace
|
|
49
|
+
* through @nx/devkit before that workspace has its own.
|
|
50
|
+
*/
|
|
51
|
+
export declare const GLOBAL_NX_PEERS = "nx@22 @nx/devkit@22";
|
|
52
|
+
/** The fix for a command that failed to load because nx / @nx/devkit is missing, else undefined. */
|
|
53
|
+
export declare function missingNxPeerHint(err: unknown): string | undefined;
|
package/dist/src/cli/versions.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.globalInstallCommand = exports.parsePluginSpec = exports.pinInstallFlags = exports.pluginSpecOverride = exports.formatPluginSpec = exports.templateFromPin = exports.compareVersions = exports.normalizeVersion = exports.LEGACY_GITHUB_REPOS = exports.PLUGIN_GITHUB_REPO = exports.PLUGIN_NAME = void 0;
|
|
3
|
+
exports.missingNxPeerHint = exports.GLOBAL_NX_PEERS = exports.globalInstallCommand = exports.parsePluginSpec = exports.pinInstallFlags = exports.pluginSpecOverride = exports.formatPluginSpec = exports.templateFromPin = exports.compareVersions = exports.normalizeVersion = exports.LEGACY_GITHUB_REPOS = exports.PLUGIN_GITHUB_REPO = exports.PLUGIN_NAME = void 0;
|
|
4
4
|
const install_source_1 = require("./install-source");
|
|
5
5
|
const types_1 = require("./types");
|
|
6
6
|
exports.PLUGIN_NAME = '@mouryaamit/nx-polystack';
|
|
@@ -109,12 +109,30 @@ exports.parsePluginSpec = parsePluginSpec;
|
|
|
109
109
|
function globalInstallCommand(version, source = (0, install_source_1.installSource)(), name = exports.PLUGIN_NAME) {
|
|
110
110
|
const v = normalizeVersion(version);
|
|
111
111
|
if (source.kind === 'npm')
|
|
112
|
-
return `npm i -g ${name}@${v}`;
|
|
113
|
-
if (source.kind === 'git')
|
|
114
|
-
return `npm i -g "${name}@${formatPluginSpec(v, source)}"`;
|
|
112
|
+
return `npm i -g ${name}@${v} ${exports.GLOBAL_NX_PEERS}`;
|
|
113
|
+
if (source.kind === 'git') {
|
|
114
|
+
return `npm i -g "${name}@${formatPluginSpec(v, source)}" ${exports.GLOBAL_NX_PEERS}`;
|
|
115
|
+
}
|
|
115
116
|
const asset = `mouryaamit-nx-polystack-v${v}.tgz`;
|
|
116
117
|
return (`gh release download v${v} -R ${source.repo} -p ${asset} -D /tmp --clobber` +
|
|
117
|
-
` && npm i -g /tmp/${asset}`);
|
|
118
|
+
` && npm i -g /tmp/${asset} ${exports.GLOBAL_NX_PEERS}`);
|
|
118
119
|
}
|
|
119
120
|
exports.globalInstallCommand = globalInstallCommand;
|
|
121
|
+
/**
|
|
122
|
+
* nx and @nx/devkit are optional peers since 1.24.0 (so apps that only import a runtime file do
|
|
123
|
+
* not get Nx), so the global CLI is installed with them: `pstack new` writes the new workspace
|
|
124
|
+
* through @nx/devkit before that workspace has its own.
|
|
125
|
+
*/
|
|
126
|
+
exports.GLOBAL_NX_PEERS = 'nx@22 @nx/devkit@22';
|
|
127
|
+
/** The fix for a command that failed to load because nx / @nx/devkit is missing, else undefined. */
|
|
128
|
+
function missingNxPeerHint(err) {
|
|
129
|
+
if (!(err instanceof Error) || err.code !== 'MODULE_NOT_FOUND') {
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
if (!/Cannot find module '(@nx\/devkit|nx)(\/[^']*)?'/.test(err.message))
|
|
133
|
+
return undefined;
|
|
134
|
+
return ('This command needs nx and @nx/devkit next to the global pstack CLI (optional peers since ' +
|
|
135
|
+
`1.24.0). Install them: npm i -g ${exports.GLOBAL_NX_PEERS}`);
|
|
136
|
+
}
|
|
137
|
+
exports.missingNxPeerHint = missingNxPeerHint;
|
|
120
138
|
//# sourceMappingURL=versions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versions.js","sourceRoot":"","sources":["../../../src/cli/versions.ts"],"names":[],"mappings":";;;AAAA,qDAK0B;AAC1B,mCAAmC;AAEtB,QAAA,WAAW,GAAG,0BAA0B,CAAC;AACtD,4DAA4D;AAC/C,QAAA,kBAAkB,GAAG,gCAAe,CAAC;AAClD,2FAA2F;AAC9E,QAAA,mBAAmB,GAAG,CAAC,yBAAyB,CAAC,CAAC;AAE/D,MAAM,MAAM,GAAG,yBAAyB,CAAC;AACzC,MAAM,YAAY,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAC;AACtF,4FAA4F;AAC5F,MAAM,QAAQ,GAAG,4BAA4B,CAAC;AAE9C,2EAA2E;AAC3E,SAAS,OAAO,CAAC,MAAqB;IACpC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,0BAAkB,EAAE,GAAG,2BAAmB,CAAC,CAAC,CAAC;IACpE,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ;QAAE,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACrD,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAC7D,OAAO,IAAI,MAAM,CACf,0EAA0E,IAAI,oCAAoC,CACnH,CAAC;AACJ,CAAC;AAED,SAAgB,gBAAgB,CAAC,CAAS;IACxC,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAChC,IAAI,CAAC,CAAC,EAAE;QACN,MAAM,IAAI,gBAAQ,CAA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AC,CAAC;IACpC,IAAI,MAAM,CAAC,IAAI,KAAK,KAAK;QAAE,OAAO,YAAY,IAAI,IAAI,CAAC,IAAI,uBAAe,EAAE,CAAC;IAC7E,IAAI,MAAM,CAAC,IAAI,KAAK,KAAK,EAAE;QACzB,OAAO,aAAa,IAAI,IAAI,gBAAgB,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,uBAAe,EAAE,CAAC;KAC/E;IACD,MAAM,KAAK,GAAG,4BAA4B,CAAC,MAAM,CAAC;IAClD,OAAO,CACL,wBAAwB,CAAC,OAAO,MAAM,CAAC,IAAI,OAAO,KAAK,oBAAoB;QAC3E,qBAAqB,KAAK,IAAI,uBAAe,EAAE,CAChD,CAAC;AACJ,CAAC;AAfD,oDAeC;AAED;;;;GAIG;AACU,QAAA,eAAe,GAAG,qBAAqB,CAAC;AAErD,oGAAoG;AACpG,SAAgB,iBAAiB,CAAC,GAAY;IAC5C,IAAI,CAAC,CAAC,GAAG,YAAY,KAAK,CAAC,IAAK,GAA6B,CAAC,IAAI,KAAK,kBAAkB,EAAE;QACzF,OAAO,SAAS,CAAC;KAClB;IACD,IAAI,CAAC,iDAAiD,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE,OAAO,SAAS,CAAC;IAC3F,OAAO,CACL,2FAA2F;QAC3F,mCAAmC,uBAAe,EAAE,CACrD,CAAC;AACJ,CAAC;AATD,8CASC"}
|
|
@@ -8,8 +8,21 @@ const module_1 = require("module");
|
|
|
8
8
|
* plugin declaring its own copies.
|
|
9
9
|
*/
|
|
10
10
|
const fromDevkit = (0, module_1.createRequire)(require.resolve('@nx/devkit/package.json'));
|
|
11
|
+
/**
|
|
12
|
+
* `ignore` is a dependency of nx, not of @nx/devkit 22: it resolved through @nx/devkit only when
|
|
13
|
+
* both were installed in one tree. Since 1.24.0 they can be separate global installs, so fall
|
|
14
|
+
* back to nx.
|
|
15
|
+
*/
|
|
16
|
+
function fromDevkitOrNx(id) {
|
|
17
|
+
try {
|
|
18
|
+
return fromDevkit(id);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return (0, module_1.createRequire)(require.resolve('nx/package.json'))(id);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
11
24
|
exports.semver = fromDevkit('semver');
|
|
12
|
-
const ignoreModule =
|
|
25
|
+
const ignoreModule = fromDevkitOrNx('ignore');
|
|
13
26
|
exports.createIgnore = ignoreModule.default ?? ignoreModule;
|
|
14
27
|
/**
|
|
15
28
|
* True when two version specs can be satisfied together. Ranges that semver understands are
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devkit-deps.js","sourceRoot":"","sources":["../../../../src/lib/utils/devkit-deps.ts"],"names":[],"mappings":";;;AAAA,mCAAuC;AAEvC;;;;GAIG;AACH,MAAM,UAAU,GAAG,IAAA,sBAAa,EAAC,OAAO,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"devkit-deps.js","sourceRoot":"","sources":["../../../../src/lib/utils/devkit-deps.ts"],"names":[],"mappings":";;;AAAA,mCAAuC;AAEvC;;;;GAIG;AACH,MAAM,UAAU,GAAG,IAAA,sBAAa,EAAC,OAAO,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC,CAAC;AAc7E;;;;GAIG;AACH,SAAS,cAAc,CAAC,EAAU;IAChC,IAAI;QACF,OAAO,UAAU,CAAC,EAAE,CAAC,CAAC;KACvB;IAAC,MAAM;QACN,OAAO,IAAA,sBAAa,EAAC,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;KAC9D;AACH,CAAC;AAEY,QAAA,MAAM,GAAW,UAAU,CAAC,QAAQ,CAAC,CAAC;AACnD,MAAM,YAAY,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;AACjC,QAAA,YAAY,GAAiB,YAAY,CAAC,OAAO,IAAI,YAAY,CAAC;AAE/E;;;;GAIG;AACH,SAAgB,aAAa,CAAC,CAAS,EAAE,CAAS;IAChD,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACzB,MAAM,EAAE,GAAG,cAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,EAAE,GAAG,cAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAChC,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE;QAAE,OAAO,KAAK,CAAC;IAC7B,IAAI;QACF,OAAO,cAAM,CAAC,UAAU,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;KAClC;IAAC,MAAM;QACN,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AAVD,sCAUC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mouryaamit/nx-polystack",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.24.0",
|
|
4
4
|
"description": "Nx plugin and pstack CLI that scaffold and build multi-tech monorepos (Angular, Ionic, Flutter) with a hardened release pipeline.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"default": "./dist/src/migrate-sdk.js"
|
|
17
17
|
},
|
|
18
18
|
"./runtime/csp-nonce": "./runtime/csp-nonce.js",
|
|
19
|
+
"./runtime/csp-style-attr": "./runtime/csp-style-attr.js",
|
|
19
20
|
"./runtime/env-secret": {
|
|
20
21
|
"types": "./runtime/env-secret.d.ts",
|
|
21
22
|
"import": "./runtime/env-secret.mjs",
|
|
@@ -70,6 +71,12 @@
|
|
|
70
71
|
"sharp": "^0.33.0 || ^0.34.0 || ^0.35.0"
|
|
71
72
|
},
|
|
72
73
|
"peerDependenciesMeta": {
|
|
74
|
+
"@nx/devkit": {
|
|
75
|
+
"optional": true
|
|
76
|
+
},
|
|
77
|
+
"nx": {
|
|
78
|
+
"optional": true
|
|
79
|
+
},
|
|
73
80
|
"crypto-js": {
|
|
74
81
|
"optional": true
|
|
75
82
|
},
|
package/runtime/csp-nonce.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* The nonce is read from `window.__cspNonce`, else from <meta property="csp-nonce" content="…">
|
|
15
15
|
* (written by the pstack release build) or <meta name="csp-nonce">. A value the server did not
|
|
16
16
|
* fill in (an SSI directive left as is, or a placeholder such as "random-csp-nonce") counts as no
|
|
17
|
-
* nonce: nothing is patched.
|
|
17
|
+
* nonce: nothing is patched, and one console warning says the nonce was not filled in.
|
|
18
18
|
*
|
|
19
19
|
* Plain browser JavaScript with no imports, safe to load more than once.
|
|
20
20
|
*/
|
|
@@ -47,11 +47,31 @@
|
|
|
47
47
|
|
|
48
48
|
var raw = window.__cspNonce;
|
|
49
49
|
var nonce = valid(raw) ? raw : undefined;
|
|
50
|
+
var meta;
|
|
50
51
|
if (!nonce) {
|
|
51
|
-
|
|
52
|
+
meta = fromMeta();
|
|
52
53
|
nonce = valid(meta) ? meta : undefined;
|
|
53
54
|
}
|
|
54
55
|
if (!nonce) {
|
|
56
|
+
// A value is there but was not filled in (the server did not replace it): say so once.
|
|
57
|
+
// No value at all (e.g. ng serve without a CSP) stays silent; '' is what this runtime writes.
|
|
58
|
+
var unfilled =
|
|
59
|
+
typeof raw === 'string' && raw !== '' ? raw : typeof meta === 'string' ? meta : undefined;
|
|
60
|
+
if (
|
|
61
|
+
unfilled !== undefined &&
|
|
62
|
+
!window.__pstackCspNonceWarned &&
|
|
63
|
+
typeof console !== 'undefined'
|
|
64
|
+
) {
|
|
65
|
+
window.__pstackCspNonceWarned = true;
|
|
66
|
+
console.warn(
|
|
67
|
+
'[pstack csp-nonce] The CSP nonce was not filled in (found "' +
|
|
68
|
+
unfilled.slice(0, 40) +
|
|
69
|
+
'"), so no nonce is added: under a nonce-based CSP, runtime <style>, <script> and ' +
|
|
70
|
+
'<link rel="stylesheet"> elements will be blocked. The server must replace the ' +
|
|
71
|
+
'placeholder in index.html on every response (e.g. Apache SSI: Options +IncludesNOEXEC ' +
|
|
72
|
+
'and the INCLUDES output filter for index.html).',
|
|
73
|
+
);
|
|
74
|
+
}
|
|
55
75
|
window.__cspNonce = '';
|
|
56
76
|
return;
|
|
57
77
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/* eslint-env browser */
|
|
2
|
+
/**
|
|
3
|
+
* @mouryaamit/nx-polystack/runtime/csp-style-attr (opt-in)
|
|
4
|
+
*
|
|
5
|
+
* Import right after runtime/csp-nonce in main.ts:
|
|
6
|
+
* import '@mouryaamit/nx-polystack/runtime/csp-nonce';
|
|
7
|
+
* import '@mouryaamit/nx-polystack/runtime/csp-style-attr';
|
|
8
|
+
*
|
|
9
|
+
* Under style-src without 'unsafe-inline', element.setAttribute('style', v) is blocked
|
|
10
|
+
* (style-src-attr), but the same declarations written through the CSSOM (style.cssText = v) are
|
|
11
|
+
* allowed. Angular writes static template / host style attributes with setAttribute('style'), so
|
|
12
|
+
* this routes setAttribute('style', v) and setAttributeNS(null, 'style', v) to style.cssText.
|
|
13
|
+
* Nothing else changes: other attributes, setAttributeNode, attributes.setNamedItem, Attr.value
|
|
14
|
+
* and style attributes parsed by the HTML parser (innerHTML, insertAdjacentHTML, static
|
|
15
|
+
* index.html markup) stay blocked. Static style="" in Angular templates is covered: Angular
|
|
16
|
+
* writes it with setAttribute.
|
|
17
|
+
* getAttribute('style') then returns the browser's normalised text, without declarations it does
|
|
18
|
+
* not support. Never pass user-controlled data to these writes. Rollback: remove the import.
|
|
19
|
+
*
|
|
20
|
+
* Plain browser JavaScript with no imports, safe to load more than once.
|
|
21
|
+
*/
|
|
22
|
+
(function pstackCspStyleAttr() {
|
|
23
|
+
if (typeof window === 'undefined' || typeof Element === 'undefined') return;
|
|
24
|
+
if (window.__pstackCspStyleAttrPatched) return;
|
|
25
|
+
window.__pstackCspStyleAttrPatched = true;
|
|
26
|
+
|
|
27
|
+
var proto = Element.prototype;
|
|
28
|
+
var setAttribute = proto.setAttribute;
|
|
29
|
+
var setAttributeNS = proto.setAttributeNS;
|
|
30
|
+
|
|
31
|
+
/** The element's CSSOM declaration when name is the style attribute, else undefined. */
|
|
32
|
+
function styleOf(el, name) {
|
|
33
|
+
if (typeof name !== 'string' || name.toLowerCase() !== 'style') return undefined;
|
|
34
|
+
var style = el.style;
|
|
35
|
+
return style && typeof style === 'object' && 'cssText' in style ? style : undefined;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
proto.setAttribute = function (name, value) {
|
|
39
|
+
var style = arguments.length >= 2 ? styleOf(this, name) : undefined;
|
|
40
|
+
if (!style) return setAttribute.apply(this, arguments);
|
|
41
|
+
style.cssText = String(value);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
if (typeof setAttributeNS === 'function') {
|
|
45
|
+
proto.setAttributeNS = function (ns, name, value) {
|
|
46
|
+
var style = arguments.length >= 3 && !ns ? styleOf(this, name) : undefined;
|
|
47
|
+
if (!style) return setAttributeNS.apply(this, arguments);
|
|
48
|
+
style.cssText = String(value);
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
})();
|