@dpgradio/creative 7.1.0 → 7.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -61,11 +61,11 @@ await configuration.retrieveConfigForDetectedStation(appId) // Default, by hostn
61
61
  // Or, if you want to retrieve the config by hostnames only.
62
62
  await configuration.retrieveConfigByHostname(appId)
63
63
  // Or, if you want to retrieve the config for a specific station:
64
- await configuration.retrieveConfigByStation(stationId, appId)
64
+ await configuration.retrieveConfigForStation(stationId, appId)
65
65
 
66
66
  // By default the first station ID (stationIdA) is used as the current station of the configuration.
67
67
  // If you want to use a different station, you can do so by calling setStation:
68
- await configuration.retrieveConfigByStations([stationIdA, stationIdB, stationIdC], appId)
68
+ await configuration.retrieveConfigForStations([stationIdA, stationIdB, stationIdC], appId)
69
69
  configuration.setStation(stationIdC)
70
70
  ```
71
71
  You can change the station later on at any time without having to retrieve the config again.
@@ -366,6 +366,25 @@ const image = new ImageGeneratorProperties('https://static.qmusic.be/acties/joe-
366
366
  (await shareable.generateUsingImage(image)).openWhatsappUrl()
367
367
  ```
368
368
 
369
+ ## CSP
370
+
371
+ Sometimes it's necessary to set strict Content Security Policy (CSP) headers. When that's the case a nicety of some of the methods in this package is that they support a random nonce to be passed in so extra sources (GTM, Privacy gate) don't need to be explicitly whitelisted (since they might be unknown at the time of development). Our datalayer and privacy gate initializers have an optional `nonce` parameter that can be passed in.
372
+
373
+ ```js
374
+ import { privacy, dataLayer } from '@dpgradio/creative'
375
+
376
+ privacy.initialize(privacyManagerId, websiteUrl, cmpCname, { nonce: "abc1234" })
377
+ dataLayer.initialize({ nonce: "abc1234" })
378
+ ```
379
+
380
+ Which then allows you to whitelist that nonce in your CSP header
381
+
382
+ ```
383
+ Content-Security-Policy: script-src 'nonce-abc1234'
384
+ ```
385
+
386
+ **!! Take note that this nonce need to be random on every request, as else this security is useless !!**
387
+
369
388
  ## Utilities
370
389
 
371
390
  This package provides a number of utility functions.