@extantape/payload-plugin-hats 0.0.0-stage → 0.2.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.
@@ -0,0 +1,162 @@
1
+ import { asPlugin, attachState, hatsOptions, idOf } from './state.js';
2
+ import { LINKS, MEMBERS, SESSIONS } from './types.js';
3
+ export async function sessionBySid(payload, sid, req) {
4
+ const { docs } = await payload.find({ collection: SESSIONS, where: { sid: { equals: sid } }, limit: 1, depth: 0, overrideAccess: true, pagination: false, req });
5
+ return docs[0] ?? null;
6
+ }
7
+ /** Removes one Payload session from an account, so its token stops working everywhere at once. */
8
+ export async function revokeSid(payload, userId, sid, req) {
9
+ const { users } = hatsOptions(payload);
10
+ const user = (await payload.findByID({ collection: users, id: userId, depth: 0, overrideAccess: true, showHiddenFields: true, disableErrors: true, req }));
11
+ if (!user?.sessions?.some((s) => s.id === sid))
12
+ return;
13
+ // The same write Payload's own logout makes: only the sessions change.
14
+ await payload.db.updateOne({ collection: users, id: user.id, data: { sessions: user.sessions.filter((s) => s.id !== sid) }, req, returning: false });
15
+ }
16
+ /**
17
+ * Marks a session's record revoked instead of deleting it. Payload writes a user's whole `sessions` list at once, so a
18
+ * sign-in at the same moment can put a revoked session back; the tombstone makes sure that session stays signed out,
19
+ * rather than looking like a plain sign-in with every role. Tombstones go once they can't matter (`cleanupSessions`).
20
+ */
21
+ export async function tombstone(payload, id, req) {
22
+ await payload.update({ collection: SESSIONS, id, data: { revokedAt: new Date().toISOString() }, overrideAccess: true, req });
23
+ }
24
+ /** Ends every switched session matching `where` (and its Payload session), e.g. after an unlink. */
25
+ export async function revokeSessions(payload, where, reason, req) {
26
+ const live = { and: [where, { revokedAt: { exists: false } }] };
27
+ const { docs } = await payload.find({ collection: SESSIONS, where: live, limit: 0, depth: 0, overrideAccess: true, pagination: false, req });
28
+ for (const s of docs) {
29
+ await revokeSid(payload, s.user, s.sid, req);
30
+ await tombstone(payload, s.id, req);
31
+ }
32
+ if (docs.length)
33
+ await hatsOptions(payload).onEvent?.({ type: 'sessions-revoked', payload, sessions: docs.length, reason });
34
+ return docs.length;
35
+ }
36
+ /** A set with one account left isn't a link any more: remove it. */
37
+ export async function dissolveIfAlone(payload, link, req) {
38
+ const { docs } = await payload.find({ collection: MEMBERS, where: { link: { equals: link } }, limit: 0, depth: 0, overrideAccess: true, pagination: false, req });
39
+ if (docs.length > 1)
40
+ return;
41
+ const before = req.context?.hatsDissolving;
42
+ req.context = { ...(req.context ?? {}), hatsDissolving: true };
43
+ try {
44
+ await asPlugin(req, async () => {
45
+ for (const d of docs)
46
+ await payload.delete({ collection: MEMBERS, id: d.id, overrideAccess: true, req });
47
+ await payload.delete({ collection: LINKS, where: { id: { equals: link } }, overrideAccess: true, req });
48
+ });
49
+ }
50
+ finally {
51
+ req.context.hatsDissolving = before;
52
+ }
53
+ await revokeSessions(payload, { link: { equals: link } }, 'set dissolved', req);
54
+ }
55
+ /** The approved set two accounts are both in, or null. Read fresh every time. */
56
+ export async function sharedLink(payload, a, b, req) {
57
+ const { docs } = await payload.find({
58
+ collection: MEMBERS,
59
+ where: { and: [{ user: { in: [a, b] } }, { status: { equals: 'approved' } }] },
60
+ limit: 2,
61
+ depth: 0,
62
+ overrideAccess: true,
63
+ pagination: false,
64
+ req,
65
+ });
66
+ const [x, y] = docs;
67
+ if (a === b)
68
+ return x ? idOf(x.link) : null;
69
+ return x && y && idOf(x.link) === idOf(y.link) ? idOf(x.link) : null;
70
+ }
71
+ /** The hat a session wears, from the account's current hats. A worn hat the account no longer has falls to the narrowest. */
72
+ export function wornHat(hats, s) {
73
+ if (!hats.length)
74
+ return null;
75
+ if (!s?.hat)
76
+ return s?.via ? hats[0] : null;
77
+ return hats.find((h) => h.id === s.hat) ?? hats[0];
78
+ }
79
+ /**
80
+ * The user as the rest of the site sees them: narrowed to the hat this session wears. A switched session whose set
81
+ * is gone is revoked and signed out. Anything unexpected throws, which signs the request out: never full roles.
82
+ */
83
+ export async function applyHat(payload, opts, user) {
84
+ const sid = user._sid;
85
+ if (!sid)
86
+ return user; // API keys and other non-session sign-ins: the site's own business.
87
+ const s = await sessionBySid(payload, sid);
88
+ if (s && String(s.user) !== String(user.id))
89
+ throw new Error('Hats: this session belongs to another account.');
90
+ if (s?.revokedAt) {
91
+ // A revoked session that came back (see `tombstone`): end it again, and sign this request out.
92
+ await revokeSid(payload, String(user.id), sid);
93
+ return null;
94
+ }
95
+ if (s?.via) {
96
+ const link = await sharedLink(payload, String(user.id), String(s.via));
97
+ if (!link || link !== String(s.link)) {
98
+ await revokeSessions(payload, { sid: { equals: sid } }, 'no longer linked');
99
+ return null;
100
+ }
101
+ }
102
+ const hats = opts.hatsOf(user);
103
+ // A session the plugin keeps a record for (switched into, or wearing a hat) whose account now has no hats at all,
104
+ // e.g. one a site disabled: sign it out. Without a hat to narrow to it would otherwise get every role.
105
+ if (!hats.length && s && (s.via || s.hat)) {
106
+ await revokeSessions(payload, { sid: { equals: sid } }, 'no hats left');
107
+ return null;
108
+ }
109
+ const hat = wornHat(hats, s);
110
+ const state = { sid, hat: hat?.id ?? null, via: s?.via ? String(s.via) : null, link: s?.link ? String(s.link) : null };
111
+ if (!hat || hat.id === hats.at(-1).id)
112
+ return attachState(user, state);
113
+ const narrowed = opts.wear(user, hat.id);
114
+ const held = new Map(hats.map((h) => [h.id, h]));
115
+ const after = opts.hatsOf(narrowed);
116
+ // Wearing a hat never adds one, and an ordinary hat never carries a sensitive one with it.
117
+ for (const h of after)
118
+ if (!held.has(h.id))
119
+ throw new Error(`Hats: wearing "${hat.id}" added "${h.id}", which the account doesn't hold.`);
120
+ for (const h of after)
121
+ if (h.sensitive && !hat.sensitive)
122
+ throw new Error(`Hats: wearing "${hat.id}" kept the sensitive hat "${h.id}".`);
123
+ // A wear() that hands back the same object didn't narrow anything: refuse rather than act in every role.
124
+ if (narrowed === user)
125
+ throw new Error(`Hats: wear("${hat.id}") returned the user unchanged; it must return a narrowed copy.`);
126
+ return attachState(narrowed, state);
127
+ }
128
+ /** Every auth strategy, wrapped so a signed-in user of our collection is narrowed before `req.user` exists. */
129
+ export function wrapStrategies(payload, opts) {
130
+ payload.authStrategies = payload.authStrategies.map((strategy) => ({
131
+ ...strategy,
132
+ authenticate: async (args) => {
133
+ const result = await strategy.authenticate(args);
134
+ const user = result.user;
135
+ if (!user || user.collection !== opts.users)
136
+ return result;
137
+ const worn = await applyHat(payload, opts, user);
138
+ return { ...result, user: worn ?? null };
139
+ },
140
+ }));
141
+ }
142
+ const DAY = 86_400_000;
143
+ /**
144
+ * Deletes session records that can't matter any more: expired over a day ago, and with no unexpired Payload session
145
+ * of that id left on the account. A record whose Payload session was kept alive (a refresh moves its expiry) stays,
146
+ * because deleting it would turn a narrowed or switched session into a plain one. At most `max` per call.
147
+ */
148
+ export async function cleanupSessions(payload, req, max = 50) {
149
+ const { users } = hatsOptions(payload);
150
+ const before = new Date(Date.now() - DAY).toISOString();
151
+ const { docs } = await payload.find({ collection: SESSIONS, where: { expiresAt: { less_than: before } }, limit: max, depth: 0, overrideAccess: true, pagination: false, req });
152
+ let removed = 0;
153
+ for (const s of docs) {
154
+ const user = (await payload.findByID({ collection: users, id: s.user, depth: 0, overrideAccess: true, showHiddenFields: true, disableErrors: true, req }));
155
+ const alive = user?.sessions?.some((x) => x.id === s.sid && (!x.expiresAt || new Date(x.expiresAt).getTime() > Date.now()));
156
+ if (alive)
157
+ continue;
158
+ await payload.delete({ collection: SESSIONS, id: s.id, overrideAccess: true, req });
159
+ removed++;
160
+ }
161
+ return removed;
162
+ }
@@ -0,0 +1,13 @@
1
+ import type { Payload, PayloadRequest } from 'payload';
2
+ import type { HatsState, HatsUser, ResolvedHatsOptions } from './types.js';
3
+ /** Attaches the session's hat state to a user without it ever being serialised into a response. */
4
+ export declare function attachState<T extends object>(user: T, state: HatsState): T;
5
+ /** The hat state of a signed-in user (or request), for audit logs and the site's own checks. */
6
+ export declare function hatsStateOf(userOrReq: unknown): HatsState | null;
7
+ export declare const hatsOptions: (payload: Payload) => ResolvedHatsOptions;
8
+ export declare const newToken: () => string;
9
+ export declare const hashToken: (token: string) => string;
10
+ /** Runs `fn` with the request marked as the plugin's own, then puts the mark back as it was. */
11
+ export declare function asPlugin<T>(req: PayloadRequest, fn: () => Promise<T>): Promise<T>;
12
+ export declare const idOf: (v: unknown) => string;
13
+ export type { HatsUser };
package/dist/state.js ADDED
@@ -0,0 +1,29 @@
1
+ import { createHash, randomBytes } from 'node:crypto';
2
+ const KEY = '_hats';
3
+ /** Attaches the session's hat state to a user without it ever being serialised into a response. */
4
+ export function attachState(user, state) {
5
+ Object.defineProperty(user, KEY, { value: state, enumerable: false, configurable: true, writable: false });
6
+ return user;
7
+ }
8
+ /** The hat state of a signed-in user (or request), for audit logs and the site's own checks. */
9
+ export function hatsStateOf(userOrReq) {
10
+ if (!userOrReq || typeof userOrReq !== 'object')
11
+ return null;
12
+ const user = 'payload' in userOrReq && 'user' in userOrReq ? userOrReq.user : userOrReq;
13
+ return user?.[KEY] ?? null;
14
+ }
15
+ export const hatsOptions = (payload) => payload.config.custom?.hats;
16
+ export const newToken = () => randomBytes(32).toString('base64url');
17
+ export const hashToken = (token) => createHash('sha256').update(`hats:${token}`).digest('hex');
18
+ /** Runs `fn` with the request marked as the plugin's own, then puts the mark back as it was. */
19
+ export async function asPlugin(req, fn) {
20
+ const before = req.context?.hatsInternal;
21
+ req.context = { ...(req.context ?? {}), hatsInternal: true };
22
+ try {
23
+ return await fn();
24
+ }
25
+ finally {
26
+ req.context.hatsInternal = before;
27
+ }
28
+ }
29
+ export const idOf = (v) => String(v && typeof v === 'object' && 'id' in v ? v.id : v);
@@ -0,0 +1,21 @@
1
+ import type { PayloadRequest } from 'payload';
2
+ import type { Hat, HatsUser, ResolvedHatsOptions } from './types.js';
3
+ /** The key a good code is remembered under: the linked set with `rememberPer: 'set'` (when the account is in one), else the account. */
4
+ export declare const memoryKey: (opts: ResolvedHatsOptions, account: string, set: string | null) => string;
5
+ /** Whether a good code was given recently enough to count. */
6
+ export declare const remembered: (opts: ResolvedHatsOptions, steppedUp: Record<string, string> | null | undefined, account: string, set: string | null) => boolean;
7
+ /**
8
+ * Does moving to `hat` on `target` need a code (before any memory is taken into account)? Without `stepUpWhen` that is
9
+ * the hat's `sensitive` flag. With it, the site's answer decides, and only an exact `false` skips the code: `true`, a
10
+ * throw, a rejection or any other answer (`'no'`, `0`, `undefined`) asks.
11
+ */
12
+ export declare function needsStepUp(opts: ResolvedHatsOptions, args: {
13
+ req: PayloadRequest;
14
+ from: {
15
+ user: HatsUser;
16
+ hat: string | null;
17
+ };
18
+ target: HatsUser;
19
+ hats: Hat[];
20
+ hat: Hat;
21
+ }): Promise<boolean>;
package/dist/stepup.js ADDED
@@ -0,0 +1,26 @@
1
+ /** The key a good code is remembered under: the linked set with `rememberPer: 'set'` (when the account is in one), else the account. */
2
+ export const memoryKey = (opts, account, set) => (opts.stepUp?.rememberPer === 'set' && set ? `set:${set}` : account);
3
+ /** Whether a good code was given recently enough to count. */
4
+ export const remembered = (opts, steppedUp, account, set) => {
5
+ const at = steppedUp?.[memoryKey(opts, account, set)];
6
+ return Boolean(at && Date.now() - new Date(at).getTime() < (opts.stepUp?.rememberMinutes ?? 180) * 60_000);
7
+ };
8
+ /**
9
+ * Does moving to `hat` on `target` need a code (before any memory is taken into account)? Without `stepUpWhen` that is
10
+ * the hat's `sensitive` flag. With it, the site's answer decides, and only an exact `false` skips the code: `true`, a
11
+ * throw, a rejection or any other answer (`'no'`, `0`, `undefined`) asks.
12
+ */
13
+ export async function needsStepUp(opts, args) {
14
+ const when = opts.stepUpWhen;
15
+ if (!when)
16
+ return Boolean(args.hat.sensitive);
17
+ try {
18
+ // The target as it would be worn: the account's last hat is all of its roles, so nothing is narrowed.
19
+ const user = args.hat.id === args.hats.at(-1)?.id ? args.target : opts.wear(args.target, args.hat.id);
20
+ const answer = await when({ req: args.req, from: args.from, to: { user, hat: args.hat.id } });
21
+ return answer !== false;
22
+ }
23
+ catch {
24
+ return true;
25
+ }
26
+ }
@@ -0,0 +1,175 @@
1
+ import type { Payload, PayloadRequest, TypedUser } from 'payload';
2
+ /** One role an account can act in. `sensitive` hats need the second factor before switching into them. */
3
+ export type Hat = {
4
+ id: string;
5
+ label: string;
6
+ sensitive?: boolean;
7
+ };
8
+ /** Who is asking, passed to the site's two-step checks along with the target account. */
9
+ export type StepUpContext = {
10
+ /** The account that actually signed in: the person (`via` when this session was switched in, else the account). */
11
+ signedIn: HatsUser;
12
+ /** The linked set's id, or null when the target account is in none. */
13
+ set: string | null;
14
+ };
15
+ /** A user record as the plugin sees it. */
16
+ export type HatsUser = TypedUser & {
17
+ id: string | number;
18
+ email?: string | null;
19
+ _sid?: string;
20
+ };
21
+ /** What the plugin knows about the request's session (also on `user._hats`, not enumerable). */
22
+ export type HatsState = {
23
+ /** This session's Payload session id. */
24
+ sid: string;
25
+ /** The hat worn, or null when the account wears all its roles (a plain sign-in). */
26
+ hat: string | null;
27
+ /** The account that actually signed in, when this session was switched to from it. */
28
+ via: string | null;
29
+ /** The linked set, when this session was switched into. */
30
+ link: string | null;
31
+ };
32
+ export type HatsOptions = {
33
+ /** The auth collection. Default `users`. */
34
+ users?: string;
35
+ /**
36
+ * The hats an account can wear, narrowest first, from its own roles. An account with one hat (or none) has
37
+ * nothing to switch between. The last hat is the account's full set of roles.
38
+ */
39
+ hatsOf: (user: HatsUser) => Hat[];
40
+ /**
41
+ * The user as seen while wearing `hat`: return a copy with roles narrowed, so every access rule that reads roles
42
+ * from `req.user` follows the hat. Never add a role the user doesn't have: the plugin refuses a result that
43
+ * offers a hat the account doesn't hold.
44
+ */
45
+ wear: (user: HatsUser, hat: string) => HatsUser;
46
+ /** Who approves link requests. Default: nobody, so linking stays off until the site says who. */
47
+ canApproveLinks?: (args: {
48
+ req: PayloadRequest;
49
+ user: HatsUser;
50
+ }) => boolean | Promise<boolean>;
51
+ /** The site's second factor, asked before switching into a sensitive hat. */
52
+ stepUp?: {
53
+ /** Whether the account has a second factor set up at all. May look it up (async), since it's often a hidden field. */
54
+ available: (user: HatsUser, ctx: StepUpContext) => boolean | Promise<boolean>;
55
+ /** Check a code for `user`. Resolve true only for a good code. */
56
+ verify: (args: {
57
+ req: PayloadRequest;
58
+ user: HatsUser;
59
+ code: string;
60
+ } & StepUpContext) => boolean | Promise<boolean>;
61
+ /** How long a good code is remembered, in minutes. Default 180 (three hours). */
62
+ rememberMinutes?: number;
63
+ /**
64
+ * What a good code is remembered for. `'account'` (default): the account it was given for. `'set'`: every account
65
+ * in the same linked set, so one two-step per person; an account in no set is still remembered on its own.
66
+ */
67
+ rememberPer?: 'account' | 'set';
68
+ };
69
+ /**
70
+ * Decides whether a switch needs a code, in place of the hat's `sensitive` flag. Called with the account and hat
71
+ * worn now (`from`, as narrowed) and the account and hat it would become (`to`, as it would be worn). Answer `true`
72
+ * to ask for a code (unless one is remembered). Only an exact `false` skips the code: a throw or any other answer
73
+ * asks. Default: the target hat's `sensitive` flag.
74
+ */
75
+ stepUpWhen?: (args: {
76
+ req: PayloadRequest;
77
+ from: {
78
+ user: HatsUser;
79
+ hat: string | null;
80
+ };
81
+ to: {
82
+ user: HatsUser;
83
+ hat: string;
84
+ };
85
+ }) => boolean | Promise<boolean>;
86
+ /**
87
+ * Who sees the switch. Default: anyone whose own account, or another account in their linked set, has more than
88
+ * one hat. Switching is refused where the switch isn't shown.
89
+ */
90
+ showSwitch?: (args: {
91
+ user: HatsUser;
92
+ hats: Hat[];
93
+ linked: {
94
+ user: HatsUser;
95
+ hats: Hat[];
96
+ }[];
97
+ }) => boolean;
98
+ /**
99
+ * A reason switching, linking and unlinking are refused right now (e.g. "Stop masquerading first."), or null to go ahead.
100
+ * Only null (or undefined) goes ahead: any other answer, and a throw, refuses with 409 `blocked`.
101
+ */
102
+ blocked?: (req: PayloadRequest) => string | null | Promise<string | null>;
103
+ /**
104
+ * Rate limit for link requests: answer exactly true to allow this one. Anything else, a throw included, refuses it
105
+ * ("Too many link requests. Try again later.").
106
+ * Called with the acting account and the email it asked for, so a site can limit per person and per address.
107
+ * Default: no limit beyond `maxLinked` and the one-set-per-account rule.
108
+ */
109
+ limit?: (args: {
110
+ req: PayloadRequest;
111
+ user: HatsUser;
112
+ email: string;
113
+ }) => boolean | Promise<boolean>;
114
+ /** Most accounts in one linked set. Default 4. */
115
+ maxLinked?: number;
116
+ /** Sends the link-confirmation email. Default: `payload.sendEmail`. */
117
+ sendEmail?: (args: {
118
+ payload: Payload;
119
+ to: string;
120
+ subject: string;
121
+ text: string;
122
+ }) => Promise<unknown>;
123
+ /** The confirmation link for a token. Default: this site's `/api/hats/confirm?token=…`. */
124
+ confirmURL?: (args: {
125
+ req: PayloadRequest;
126
+ token: string;
127
+ }) => string;
128
+ /** Called after anything the audit log should know: linking, approving, unlinking, switching, revoking. */
129
+ onEvent?: (event: HatsEvent) => void | Promise<void>;
130
+ /** Put the switch in the admin header. Default true. */
131
+ adminSwitch?: boolean;
132
+ /** Hours a confirmation link works. Default 24. */
133
+ confirmHours?: number;
134
+ };
135
+ export type HatsEvent = {
136
+ type: 'link-requested';
137
+ req: PayloadRequest;
138
+ link: string;
139
+ by: string;
140
+ account: string;
141
+ } | {
142
+ type: 'link-confirmed';
143
+ payload: Payload;
144
+ link: string;
145
+ account: string;
146
+ } | {
147
+ type: 'link-approved';
148
+ req: PayloadRequest;
149
+ link: string;
150
+ account: string;
151
+ by: string;
152
+ } | {
153
+ type: 'unlinked';
154
+ payload: Payload;
155
+ link: string;
156
+ account: string;
157
+ by: string | null;
158
+ } | {
159
+ type: 'switched';
160
+ req: PayloadRequest;
161
+ from: string;
162
+ to: string;
163
+ hat: string;
164
+ via: string;
165
+ steppedUp: boolean;
166
+ } | {
167
+ type: 'sessions-revoked';
168
+ payload: Payload;
169
+ sessions: number;
170
+ reason: string;
171
+ };
172
+ export type ResolvedHatsOptions = Required<Omit<HatsOptions, 'stepUp' | 'stepUpWhen' | 'canApproveLinks' | 'blocked' | 'limit' | 'onEvent' | 'confirmURL'>> & Pick<HatsOptions, 'stepUp' | 'stepUpWhen' | 'canApproveLinks' | 'blocked' | 'limit' | 'onEvent' | 'confirmURL'>;
173
+ export declare const LINKS = "hat-links";
174
+ export declare const MEMBERS = "hat-members";
175
+ export declare const SESSIONS = "hat-sessions";
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ export const LINKS = 'hat-links';
2
+ export const MEMBERS = 'hat-members';
3
+ export const SESSIONS = 'hat-sessions';
package/package.json CHANGED
@@ -1,6 +1,74 @@
1
1
  {
2
2
  "name": "@extantape/payload-plugin-hats",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "Linked accounts and role hats for Payload: one person switches between their approved accounts, and acts in one role at a time, with a second factor before switching up.",
5
+ "keywords": [
6
+ "payload",
7
+ "payload-plugin",
8
+ "payloadcms",
9
+ "account-switcher",
10
+ "linked-accounts",
11
+ "roles",
12
+ "least-privilege",
13
+ "step-up-authentication"
14
+ ],
15
+ "license": "MIT",
16
+ "homepage": "https://github.com/ExtantApe/payload-plugin-hats#readme",
17
+ "bugs": {
18
+ "url": "https://github.com/ExtantApe/payload-plugin-hats/issues"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/ExtantApe/payload-plugin-hats.git"
23
+ },
24
+ "type": "module",
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/index.d.ts",
28
+ "import": "./dist/index.js"
29
+ },
30
+ "./client": {
31
+ "types": "./dist/client/index.d.ts",
32
+ "import": "./dist/client/index.js"
33
+ }
34
+ },
35
+ "main": "./dist/index.js",
36
+ "types": "./dist/index.d.ts",
37
+ "files": [
38
+ "dist",
39
+ "README.md",
40
+ "LICENSE"
41
+ ],
42
+ "engines": {
43
+ "node": ">=22"
44
+ },
45
+ "scripts": {
46
+ "build": "rm -rf dist && tsc -p tsconfig.build.json",
47
+ "typecheck": "tsc --noEmit",
48
+ "test": "vitest run",
49
+ "prepack": "npm run build",
50
+ "prepublishOnly": "npm run typecheck && npm test"
51
+ },
52
+ "peerDependencies": {
53
+ "payload": "^3.80.0",
54
+ "react": "^19.0.0"
55
+ },
56
+ "devDependencies": {
57
+ "@payloadcms/db-mongodb": "3.92.1",
58
+ "@types/node": "^24.0.0",
59
+ "@types/react": "^19.3.0",
60
+ "@types/react-dom": "^19.3.0",
61
+ "graphql": "^16.14.2",
62
+ "mongodb-memory-server": "^11.3.0",
63
+ "payload": "3.92.1",
64
+ "react": "^19.3.1",
65
+ "react-dom": "^19.3.1",
66
+ "typescript": "^5.9.0",
67
+ "vitest": "^5.1.0"
68
+ },
69
+ "peerDependenciesMeta": {
70
+ "react": {
71
+ "optional": true
72
+ }
73
+ }
74
+ }