@simmalugnt-se/payload-consent 0.7.1 → 0.8.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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.8.0
4
+
5
+ - The consent log's Allowed categories and a scan's Status show English and Swedish names instead
6
+ of their stored values (`necessary`, `queued`), and a scan's start and finish times have labels.
7
+ Stored values are unchanged, so no migration.
8
+ - `access.manage` defaults to users signed in to Admin (the config's `admin.user`). Any signed-in
9
+ user could manage cookies and read the consent log, a site member or customer from another auth
10
+ collection too. A site that passes `access.manage` is unaffected.
11
+
3
12
  ## 0.7.1
4
13
 
5
14
  - A scan after one that found nothing marks everything it finds as new, and so sends its email.
package/README.md CHANGED
@@ -304,7 +304,8 @@ banner's own consent storage first: `c15t` (the choice), `c15t-sid` (the visitor
304
304
  The global and the services are public to read by default (`access.read`), since the site shows
305
305
  them to everyone. `access.manage` says who works with cookies in Admin: changing the texts and
306
306
  services, reading the consent log, the policies, the scans and their evidence, starting a scan and
307
- adding its findings, and seeing the dashboard widget. It defaults to signed-in users; with roles,
307
+ adding its findings, and seeing the dashboard widget. It defaults to users signed in to Admin
308
+ (the config's `admin.user`), not users of another auth collection such as site members; with roles,
308
309
  pass the project's:
309
310
 
310
311
  ```ts
package/dist/access.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { Access, PayloadRequest } from "payload";
2
2
  import type { ConsentPluginOptions } from "./types.ts";
3
- /** Who works with cookies in Admin (`access.manage`); signed-in users unless the host says. */
3
+ /** Who works with cookies in Admin (`access.manage`); Admin's users unless the host says. */
4
4
  export declare function manageAccess(options: ConsentPluginOptions): Access;
5
5
  /** Whether `manage` lets this request through; a query result counts as yes. */
6
6
  export declare function canManage(options: ConsentPluginOptions, req: PayloadRequest): Promise<boolean>;
package/dist/access.js CHANGED
@@ -1,7 +1,8 @@
1
- const signedIn = ({ req }) => Boolean(req.user);
2
- /** Who works with cookies in Admin (`access.manage`); signed-in users unless the host says. */
1
+ /** Signed in to Admin: a user of the config's `admin.user`, not of another auth collection. */
2
+ const adminUser = ({ req }) => Boolean(req.user && req.user.collection === req.payload.config.admin.user);
3
+ /** Who works with cookies in Admin (`access.manage`); Admin's users unless the host says. */
3
4
  export function manageAccess(options) {
4
- return options.access?.manage ?? signedIn;
5
+ return options.access?.manage ?? adminUser;
5
6
  }
6
7
  /** Whether `manage` lets this request through; a query result counts as yes. */
7
8
  export async function canManage(options, req) {
package/dist/records.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { manageAccess } from "./access.js";
2
2
  import { CATEGORIES } from "./defaults.js";
3
+ import { categoryLabels } from "./global.js";
3
4
  import { allowedOrigin, clientKey, createRateLimit, MAX_RECORD_BYTES } from "./record-guard.js";
4
5
  import { readConsent, toConsentConfig } from "./site-config.js";
5
6
  import { CONSENT_POLICIES, CONSENT_RECORDS, DEFAULT_RETENTION_DAYS, } from "./types.js";
@@ -204,7 +205,7 @@ export function recordsCollection(options) {
204
205
  type: "select",
205
206
  hasMany: true,
206
207
  label: { en: "Allowed", sv: "Tillåtna" },
207
- options: CATEGORIES.map((value) => ({ value, label: value })),
208
+ options: CATEGORIES.map((value) => ({ value, label: categoryLabels[value] })),
208
209
  },
209
210
  { name: "choices", type: "json", label: { en: "Choices", sv: "Val" } },
210
211
  {
package/dist/scans.js CHANGED
@@ -568,7 +568,12 @@ export function scansCollection(options) {
568
568
  name: "status",
569
569
  type: "select",
570
570
  label: { en: "Status", sv: "Status" },
571
- options: ["queued", "running", "done", "failed"].map((value) => ({ value, label: value })),
571
+ options: [
572
+ { value: "queued", label: { en: "Queued", sv: "I kö" } },
573
+ { value: "running", label: { en: "Running", sv: "Pågår" } },
574
+ { value: "done", label: { en: "Done", sv: "Klar" } },
575
+ { value: "failed", label: { en: "Failed", sv: "Misslyckades" } },
576
+ ],
572
577
  },
573
578
  {
574
579
  name: "trigger",
@@ -581,8 +586,18 @@ export function scansCollection(options) {
581
586
  },
582
587
  { name: "scanId", type: "text", index: true, admin: { hidden: true } },
583
588
  { name: "error", type: "text", label: { en: "Error", sv: "Fel" } },
584
- { name: "startedAt", type: "date", admin: { date: { pickerAppearance: "dayAndTime" } } },
585
- { name: "finishedAt", type: "date", admin: { date: { pickerAppearance: "dayAndTime" } } },
589
+ {
590
+ name: "startedAt",
591
+ type: "date",
592
+ label: { en: "Start time", sv: "Starttid" },
593
+ admin: { date: { pickerAppearance: "dayAndTime" } },
594
+ },
595
+ {
596
+ name: "finishedAt",
597
+ type: "date",
598
+ label: { en: "Finish time", sv: "Sluttid" },
599
+ admin: { date: { pickerAppearance: "dayAndTime" } },
600
+ },
586
601
  { name: "summary", type: "json", label: { en: "Summary", sv: "Sammanfattning" } },
587
602
  { name: "findings", type: "json", label: { en: "Findings", sv: "Fynd" } },
588
603
  { name: "states", type: "json", label: { en: "States", sv: "Lägen" } },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simmalugnt-se/payload-consent",
3
- "version": "0.7.1",
3
+ "version": "0.8.0",
4
4
  "description": "Cookie consent for Payload sites: banner texts, services and scans in Admin",
5
5
  "keywords": [
6
6
  "payload",