fg-dynamic-component 4.0.0 → 5.0.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 CHANGED
@@ -7,6 +7,7 @@ Create an Angular standalone signals based dynamic components tree through a JSO
7
7
 
8
8
  | Angular | fg-dynamic-component | NPM package |
9
9
  | ------- | -------------------- | ----------------------------- |
10
+ | 22.2.3 | 5.0.0 | `fg-dynamic-component@^5.0.0` |
10
11
  | 22.2.3 | 4.0.0 | `fg-dynamic-component@^4.0.0` |
11
12
  | 22.2.3 | 3.0.0 | `fg-dynamic-component@^3.0.0` |
12
13
  | 22.1.6 | 2.0.0 | `fg-dynamic-component@^2.0.0` |
@@ -50,7 +51,7 @@ FGDynamicService.registerComponent("MyDynamicComponent5", async () => (await imp
50
51
 
51
52
  @Component({
52
53
  selector: "my-component",
53
- template: `<fg-dynamic [configuration]="configuration()" />`
54
+ template: `<fg-dynamic [configuration]="configuration()" [typePolicy]="{ allowFunctionTypes: true }" />`
54
55
  })
55
56
  class MyComponent {
56
57
  configuration = signal({
@@ -79,6 +80,10 @@ class MyComponent {
79
80
  }
80
81
  ```
81
82
 
83
+ > Promise and function loaders execute host code. The examples above opt in with
84
+ > `[typePolicy]="{ allowFunctionTypes: true }"`; omit it when you only use direct
85
+ > component classes or registry names.
86
+
82
87
  #### Standalone API
83
88
 
84
89
  You may use `<fg-dynamic>` as a standalone component:
@@ -91,7 +96,7 @@ FGDynamicService.registerComponent("MyDynamicComponent5", async () => (await imp
91
96
 
92
97
  @Component({
93
98
  selector: "my-component",
94
- template: `<fg-dynamic [configuration]="configuration()" />`,
99
+ template: `<fg-dynamic [configuration]="configuration()" [typePolicy]="{ allowFunctionTypes: true }" />`,
95
100
  imports: [FGDynamicComponent],
96
101
  standalone: true
97
102
  })
@@ -121,6 +126,9 @@ class MyComponent {
121
126
  }
122
127
  ```
123
128
 
129
+ > Promise and function loaders execute host code. The standalone example above
130
+ > opts in with `[typePolicy]="{ allowFunctionTypes: true }"`.
131
+
124
132
  _NOTE:_ You can declare components to dynamically load in static and/or dynamic way using or not the FGDynamicService.
125
133
 
126
134
  #### Scoped registry
@@ -267,9 +275,13 @@ class MyComponent {
267
275
  > `data-*` or `aria-*` attribute.
268
276
  >
269
277
  > Event handlers (`on*`), `style`, `srcdoc`, `formaction`, namespaced attributes
270
- > and non-primitive values are ignored. `href` and `src` only accept `http`,
271
- > `https`, `mailto`, `tel` and relative URLs, so `javascript:` URLs are blocked
272
- > even when they come from an expression.
278
+ > and non-primitive values are ignored. `href` and `src` accept relative and
279
+ > same-origin URLs plus `mailto:` and `tel:`; cross-origin and protocol-relative
280
+ > URLs are rejected by default, so an untrusted configuration cannot exfiltrate
281
+ > view-model data by pointing an image or link at an attacker-controlled host.
282
+ > Opt into external URLs for trusted configurations with
283
+ > `[attributePolicy]="{ allowExternalUrls: true }"`. `javascript:` and `data:`
284
+ > URLs stay blocked even when they come from an expression.
273
285
  >
274
286
  > Boolean attributes (`hidden`, `disabled`, `readonly`, `required`, `checked`,
275
287
  > `selected`, `multiple`) follow HTML presence semantics: a truthy value adds
@@ -377,11 +389,23 @@ template: `<fg-dynamic [configuration]="configuration()" [expressionPolicy]="{ a
377
389
  are not exposed by default; enable view-model mutation explicitly with
378
390
  `[expressionPolicy]="{ allowViewModelMutation: true }"`.
379
391
 
392
+ `allowedMethods` entries are **receiver-scoped to the root view model**: the
393
+ string form allows `$vm().save()` but not `$vm().nested.save()`, so granting one
394
+ method name does not unlock every reachable object with the same name. When a
395
+ nested capability is intentional, use the descriptor form
396
+ `{ name: 'save', on: someObject }` (or `{ name: 'save', receiver: 'any' }` for a
397
+ fully trusted view model).
398
+
399
+ Arrow parameters cannot rebind the host identifiers `$vm`, `$event` or `$ev`, and
400
+ the method policy also covers coercion hooks (`toString`, `valueOf`,
401
+ `Symbol.toPrimitive`, `Symbol.isConcatSpreadable`) on both receivers and
402
+ arguments, so native string/array methods cannot be used to invoke host code.
403
+
380
404
  > Treat configurations as untrusted data unless they come from your own code.
381
405
  > For multi-tenant/plugin scenarios prefer a scoped registry,
382
406
  > `expressionPolicy.allowedMethods`, `formControlPolicy.allowedControlNames`,
383
407
  > `[typePolicy]="{ requireScopedRegistry: true }"` and
384
- > `[attributePolicy]="{ strict: true }"`.
408
+ > `[attributePolicy]="{ strict: true }"` (leave `allowExternalUrls` disabled).
385
409
 
386
410
  #### Component type policy
387
411