Initial commit
This commit is contained in:
26
packages/core-consent/src/handlers/grant.handler.ts
Normal file
26
packages/core-consent/src/handlers/grant.handler.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { z } from "zod";
|
||||
import type { IConsent } from "../consent.interface";
|
||||
|
||||
export const grantHandlerInputSchema = z
|
||||
.object({
|
||||
category: z.string().min(1),
|
||||
meta: z
|
||||
.object({
|
||||
bannerVersion: z.string().optional(),
|
||||
policyVersion: z.string().optional(),
|
||||
method: z.string().optional(),
|
||||
})
|
||||
.strict()
|
||||
.optional(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
export type GrantHandlerInput = z.infer<typeof grantHandlerInputSchema>;
|
||||
|
||||
export async function grantHandler(
|
||||
consent: IConsent,
|
||||
input: GrantHandlerInput,
|
||||
): Promise<{ success: true }> {
|
||||
await consent.grant(input.category, input.meta);
|
||||
return { success: true };
|
||||
}
|
||||
Reference in New Issue
Block a user