@phygitallabs/phygital-consent 1.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.
@@ -0,0 +1,430 @@
1
+ /*! tailwindcss v4.1.18 | MIT License | https://tailwindcss.com */
2
+ @layer properties;
3
+ @layer theme, base, components, utilities;
4
+ @layer theme {
5
+ :root, :host {
6
+ --consent-font-sans: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji",
7
+ "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
8
+ --consent-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
9
+ "Courier New", monospace;
10
+ --consent-color-red-600: oklch(57.7% 0.245 27.325);
11
+ --consent-color-gray-200: oklch(92.8% 0.006 264.531);
12
+ --consent-color-gray-300: oklch(87.2% 0.01 258.338);
13
+ --consent-color-gray-600: oklch(44.6% 0.03 256.802);
14
+ --consent-color-gray-700: oklch(37.3% 0.034 259.733);
15
+ --consent-color-gray-900: oklch(21% 0.034 264.665);
16
+ --consent-color-white: #fff;
17
+ --consent-spacing: 0.25rem;
18
+ --consent-container-md: 28rem;
19
+ --consent-text-sm: 0.875rem;
20
+ --consent-text-sm--line-height: calc(1.25 / 0.875);
21
+ --consent-text-lg: 1.125rem;
22
+ --consent-text-lg--line-height: calc(1.75 / 1.125);
23
+ --consent-font-weight-medium: 500;
24
+ --consent-font-weight-semibold: 600;
25
+ --consent-radius-lg: 0.5rem;
26
+ --consent-radius-xl: 0.75rem;
27
+ --consent-default-font-family: var(--consent-font-sans);
28
+ --consent-default-mono-font-family: var(--consent-font-mono);
29
+ }
30
+ }
31
+ @layer base {
32
+ *, ::after, ::before, ::backdrop, ::file-selector-button {
33
+ box-sizing: border-box;
34
+ margin: 0;
35
+ padding: 0;
36
+ border: 0 solid;
37
+ }
38
+ html, :host {
39
+ line-height: 1.5;
40
+ -webkit-text-size-adjust: 100%;
41
+ tab-size: 4;
42
+ font-family: var(--consent-default-font-family, ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");
43
+ font-feature-settings: var(--consent-default-font-feature-settings, normal);
44
+ font-variation-settings: var(--consent-default-font-variation-settings, normal);
45
+ -webkit-tap-highlight-color: transparent;
46
+ }
47
+ hr {
48
+ height: 0;
49
+ color: inherit;
50
+ border-top-width: 1px;
51
+ }
52
+ abbr:where([title]) {
53
+ -webkit-text-decoration: underline dotted;
54
+ text-decoration: underline dotted;
55
+ }
56
+ h1, h2, h3, h4, h5, h6 {
57
+ font-size: inherit;
58
+ font-weight: inherit;
59
+ }
60
+ a {
61
+ color: inherit;
62
+ -webkit-text-decoration: inherit;
63
+ text-decoration: inherit;
64
+ }
65
+ b, strong {
66
+ font-weight: bolder;
67
+ }
68
+ code, kbd, samp, pre {
69
+ font-family: var(--consent-default-mono-font-family, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);
70
+ font-feature-settings: var(--consent-default-mono-font-feature-settings, normal);
71
+ font-variation-settings: var(--consent-default-mono-font-variation-settings, normal);
72
+ font-size: 1em;
73
+ }
74
+ small {
75
+ font-size: 80%;
76
+ }
77
+ sub, sup {
78
+ font-size: 75%;
79
+ line-height: 0;
80
+ position: relative;
81
+ vertical-align: baseline;
82
+ }
83
+ sub {
84
+ bottom: -0.25em;
85
+ }
86
+ sup {
87
+ top: -0.5em;
88
+ }
89
+ table {
90
+ text-indent: 0;
91
+ border-color: inherit;
92
+ border-collapse: collapse;
93
+ }
94
+ :-moz-focusring {
95
+ outline: auto;
96
+ }
97
+ progress {
98
+ vertical-align: baseline;
99
+ }
100
+ summary {
101
+ display: list-item;
102
+ }
103
+ ol, ul, menu {
104
+ list-style: none;
105
+ }
106
+ img, svg, video, canvas, audio, iframe, embed, object {
107
+ display: block;
108
+ vertical-align: middle;
109
+ }
110
+ img, video {
111
+ max-width: 100%;
112
+ height: auto;
113
+ }
114
+ button, input, select, optgroup, textarea, ::file-selector-button {
115
+ font: inherit;
116
+ font-feature-settings: inherit;
117
+ font-variation-settings: inherit;
118
+ letter-spacing: inherit;
119
+ color: inherit;
120
+ border-radius: 0;
121
+ background-color: transparent;
122
+ opacity: 1;
123
+ }
124
+ :where(select:is([multiple], [size])) optgroup {
125
+ font-weight: bolder;
126
+ }
127
+ :where(select:is([multiple], [size])) optgroup option {
128
+ padding-inline-start: 20px;
129
+ }
130
+ ::file-selector-button {
131
+ margin-inline-end: 4px;
132
+ }
133
+ ::placeholder {
134
+ opacity: 1;
135
+ }
136
+ @supports (not (-webkit-appearance: -apple-pay-button)) or (contain-intrinsic-size: 1px) {
137
+ ::placeholder {
138
+ color: currentcolor;
139
+ @supports (color: color-mix(in lab, red, red)) {
140
+ color: color-mix(in oklab, currentcolor 50%, transparent);
141
+ }
142
+ }
143
+ }
144
+ textarea {
145
+ resize: vertical;
146
+ }
147
+ ::-webkit-search-decoration {
148
+ -webkit-appearance: none;
149
+ }
150
+ ::-webkit-date-and-time-value {
151
+ min-height: 1lh;
152
+ text-align: inherit;
153
+ }
154
+ ::-webkit-datetime-edit {
155
+ display: inline-flex;
156
+ }
157
+ ::-webkit-datetime-edit-fields-wrapper {
158
+ padding: 0;
159
+ }
160
+ ::-webkit-datetime-edit, ::-webkit-datetime-edit-year-field, ::-webkit-datetime-edit-month-field, ::-webkit-datetime-edit-day-field, ::-webkit-datetime-edit-hour-field, ::-webkit-datetime-edit-minute-field, ::-webkit-datetime-edit-second-field, ::-webkit-datetime-edit-millisecond-field, ::-webkit-datetime-edit-meridiem-field {
161
+ padding-block: 0;
162
+ }
163
+ ::-webkit-calendar-picker-indicator {
164
+ line-height: 1;
165
+ }
166
+ :-moz-ui-invalid {
167
+ box-shadow: none;
168
+ }
169
+ button, input:where([type="button"], [type="reset"], [type="submit"]), ::file-selector-button {
170
+ appearance: button;
171
+ }
172
+ ::-webkit-inner-spin-button, ::-webkit-outer-spin-button {
173
+ height: auto;
174
+ }
175
+ [hidden]:where(:not([hidden="until-found"])) {
176
+ display: none !important;
177
+ }
178
+ }
179
+ @layer utilities {
180
+ .consent\:fixed {
181
+ position: fixed;
182
+ }
183
+ .consent\:right-0 {
184
+ right: calc(var(--consent-spacing) * 0);
185
+ }
186
+ .consent\:bottom-0 {
187
+ bottom: calc(var(--consent-spacing) * 0);
188
+ }
189
+ .consent\:left-0 {
190
+ left: calc(var(--consent-spacing) * 0);
191
+ }
192
+ .consent\:z-50 {
193
+ z-index: 50;
194
+ }
195
+ .consent\:flex {
196
+ display: flex;
197
+ }
198
+ .consent\:flex-col {
199
+ flex-direction: column;
200
+ }
201
+ .consent\:flex-wrap {
202
+ flex-wrap: wrap;
203
+ }
204
+ .consent\:gap-2 {
205
+ gap: calc(var(--consent-spacing) * 2);
206
+ }
207
+ .consent\:gap-4 {
208
+ gap: calc(var(--consent-spacing) * 4);
209
+ }
210
+ .consent\:space-y-2 {
211
+ :where(& > :not(:last-child)) {
212
+ --tw-space-y-reverse: 0;
213
+ margin-block-start: calc(calc(var(--consent-spacing) * 2) * var(--tw-space-y-reverse));
214
+ margin-block-end: calc(calc(var(--consent-spacing) * 2) * calc(1 - var(--tw-space-y-reverse)));
215
+ }
216
+ }
217
+ .consent\:rounded-lg {
218
+ border-radius: var(--consent-radius-lg);
219
+ }
220
+ .consent\:rounded-t-xl {
221
+ border-top-left-radius: var(--consent-radius-xl);
222
+ border-top-right-radius: var(--consent-radius-xl);
223
+ }
224
+ .consent\:border {
225
+ border-style: var(--tw-border-style);
226
+ border-width: 1px;
227
+ }
228
+ .consent\:border-b-0 {
229
+ border-bottom-style: var(--tw-border-style);
230
+ border-bottom-width: 0px;
231
+ }
232
+ .consent\:border-gray-200 {
233
+ border-color: var(--consent-color-gray-200);
234
+ }
235
+ .consent\:border-gray-300 {
236
+ border-color: var(--consent-color-gray-300);
237
+ }
238
+ .consent\:bg-gray-900 {
239
+ background-color: var(--consent-color-gray-900);
240
+ }
241
+ .consent\:bg-white {
242
+ background-color: var(--consent-color-white);
243
+ }
244
+ .consent\:p-4 {
245
+ padding: calc(var(--consent-spacing) * 4);
246
+ }
247
+ .consent\:px-4 {
248
+ padding-inline: calc(var(--consent-spacing) * 4);
249
+ }
250
+ .consent\:py-2 {
251
+ padding-block: calc(var(--consent-spacing) * 2);
252
+ }
253
+ .consent\:text-lg {
254
+ font-size: var(--consent-text-lg);
255
+ line-height: var(--tw-leading, var(--consent-text-lg--line-height));
256
+ }
257
+ .consent\:text-sm {
258
+ font-size: var(--consent-text-sm);
259
+ line-height: var(--tw-leading, var(--consent-text-sm--line-height));
260
+ }
261
+ .consent\:font-medium {
262
+ --tw-font-weight: var(--consent-font-weight-medium);
263
+ font-weight: var(--consent-font-weight-medium);
264
+ }
265
+ .consent\:font-semibold {
266
+ --tw-font-weight: var(--consent-font-weight-semibold);
267
+ font-weight: var(--consent-font-weight-semibold);
268
+ }
269
+ .consent\:text-gray-600 {
270
+ color: var(--consent-color-gray-600);
271
+ }
272
+ .consent\:text-gray-700 {
273
+ color: var(--consent-color-gray-700);
274
+ }
275
+ .consent\:text-gray-900 {
276
+ color: var(--consent-color-gray-900);
277
+ }
278
+ .consent\:text-red-600 {
279
+ color: var(--consent-color-red-600);
280
+ }
281
+ .consent\:text-white {
282
+ color: var(--consent-color-white);
283
+ }
284
+ .consent\:shadow-lg {
285
+ --tw-shadow: 0 10px 15px -3px var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 4px 6px -4px var(--tw-shadow-color, rgb(0 0 0 / 0.1));
286
+ box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
287
+ }
288
+ .consent\:shadow-sm {
289
+ --tw-shadow: 0 1px 3px 0 var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 1px 2px -1px var(--tw-shadow-color, rgb(0 0 0 / 0.1));
290
+ box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
291
+ }
292
+ .consent\:md\:right-auto {
293
+ @media (width >= 48rem) {
294
+ right: auto;
295
+ }
296
+ }
297
+ .consent\:md\:bottom-4 {
298
+ @media (width >= 48rem) {
299
+ bottom: calc(var(--consent-spacing) * 4);
300
+ }
301
+ }
302
+ .consent\:md\:left-4 {
303
+ @media (width >= 48rem) {
304
+ left: calc(var(--consent-spacing) * 4);
305
+ }
306
+ }
307
+ .consent\:md\:max-w-md {
308
+ @media (width >= 48rem) {
309
+ max-width: var(--consent-container-md);
310
+ }
311
+ }
312
+ .consent\:md\:rounded-xl {
313
+ @media (width >= 48rem) {
314
+ border-radius: var(--consent-radius-xl);
315
+ }
316
+ }
317
+ .consent\:md\:border {
318
+ @media (width >= 48rem) {
319
+ border-style: var(--tw-border-style);
320
+ border-width: 1px;
321
+ }
322
+ }
323
+ .consent\:md\:border-gray-200 {
324
+ @media (width >= 48rem) {
325
+ border-color: var(--consent-color-gray-200);
326
+ }
327
+ }
328
+ }
329
+ @property --tw-space-y-reverse {
330
+ syntax: "*";
331
+ inherits: false;
332
+ initial-value: 0;
333
+ }
334
+ @property --tw-border-style {
335
+ syntax: "*";
336
+ inherits: false;
337
+ initial-value: solid;
338
+ }
339
+ @property --tw-font-weight {
340
+ syntax: "*";
341
+ inherits: false;
342
+ }
343
+ @property --tw-shadow {
344
+ syntax: "*";
345
+ inherits: false;
346
+ initial-value: 0 0 #0000;
347
+ }
348
+ @property --tw-shadow-color {
349
+ syntax: "*";
350
+ inherits: false;
351
+ }
352
+ @property --tw-shadow-alpha {
353
+ syntax: "<percentage>";
354
+ inherits: false;
355
+ initial-value: 100%;
356
+ }
357
+ @property --tw-inset-shadow {
358
+ syntax: "*";
359
+ inherits: false;
360
+ initial-value: 0 0 #0000;
361
+ }
362
+ @property --tw-inset-shadow-color {
363
+ syntax: "*";
364
+ inherits: false;
365
+ }
366
+ @property --tw-inset-shadow-alpha {
367
+ syntax: "<percentage>";
368
+ inherits: false;
369
+ initial-value: 100%;
370
+ }
371
+ @property --tw-ring-color {
372
+ syntax: "*";
373
+ inherits: false;
374
+ }
375
+ @property --tw-ring-shadow {
376
+ syntax: "*";
377
+ inherits: false;
378
+ initial-value: 0 0 #0000;
379
+ }
380
+ @property --tw-inset-ring-color {
381
+ syntax: "*";
382
+ inherits: false;
383
+ }
384
+ @property --tw-inset-ring-shadow {
385
+ syntax: "*";
386
+ inherits: false;
387
+ initial-value: 0 0 #0000;
388
+ }
389
+ @property --tw-ring-inset {
390
+ syntax: "*";
391
+ inherits: false;
392
+ }
393
+ @property --tw-ring-offset-width {
394
+ syntax: "<length>";
395
+ inherits: false;
396
+ initial-value: 0px;
397
+ }
398
+ @property --tw-ring-offset-color {
399
+ syntax: "*";
400
+ inherits: false;
401
+ initial-value: #fff;
402
+ }
403
+ @property --tw-ring-offset-shadow {
404
+ syntax: "*";
405
+ inherits: false;
406
+ initial-value: 0 0 #0000;
407
+ }
408
+ @layer properties {
409
+ @supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {
410
+ *, ::before, ::after, ::backdrop {
411
+ --tw-space-y-reverse: 0;
412
+ --tw-border-style: solid;
413
+ --tw-font-weight: initial;
414
+ --tw-shadow: 0 0 #0000;
415
+ --tw-shadow-color: initial;
416
+ --tw-shadow-alpha: 100%;
417
+ --tw-inset-shadow: 0 0 #0000;
418
+ --tw-inset-shadow-color: initial;
419
+ --tw-inset-shadow-alpha: 100%;
420
+ --tw-ring-color: initial;
421
+ --tw-ring-shadow: 0 0 #0000;
422
+ --tw-inset-ring-color: initial;
423
+ --tw-inset-ring-shadow: 0 0 #0000;
424
+ --tw-ring-inset: initial;
425
+ --tw-ring-offset-width: 0px;
426
+ --tw-ring-offset-color: #fff;
427
+ --tw-ring-offset-shadow: 0 0 #0000;
428
+ }
429
+ }
430
+ }
package/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./src";
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@phygitallabs/phygital-consent",
3
+ "version": "1.0.0",
4
+ "private": false,
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "main": "./dist/index.cjs",
9
+ "module": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "scripts": {
12
+ "build": "tsup && bun run build:css",
13
+ "build:css": "postcss src/styles.css -o dist/phygital-consent.css",
14
+ "dev": "tsup --watch",
15
+ "prepublishOnly": "bun run build"
16
+ },
17
+ "dependencies": {
18
+ "axios": "^1.8.4"
19
+ },
20
+ "peerDependencies": {
21
+ "react": ">=19.0.0",
22
+ "react-dom": ">=19.0.0",
23
+ "@tanstack/react-query": "^5.66.8",
24
+ "@tanstack/react-query-devtools": "^5.74.7"
25
+ },
26
+ "devDependencies": {
27
+ "@tailwindcss/postcss": "^4.1.11",
28
+ "@types/react": "19.1.8",
29
+ "@tanstack/react-query-devtools": "^5.74.7",
30
+ "postcss": "^8.5.6",
31
+ "postcss-cli": "^11.0.0",
32
+ "tailwindcss": "^4.1.11",
33
+ "tsup": "latest",
34
+ "typescript": "latest"
35
+ },
36
+ "exports": {
37
+ ".": {
38
+ "types": "./dist/index.d.ts",
39
+ "import": "./dist/index.js",
40
+ "require": "./dist/index.cjs"
41
+ },
42
+ "./styles": "./dist/phygital-consent.css"
43
+ }
44
+ }
@@ -0,0 +1,6 @@
1
+ /** @type {import('postcss-load-config').Config} */
2
+ export default {
3
+ plugins: {
4
+ "@tailwindcss/postcss": {},
5
+ },
6
+ };
@@ -0,0 +1,112 @@
1
+ import { AxiosInstance } from "axios";
2
+ import type {
3
+ GetManyConsentParams,
4
+ GetManyConsentResponse,
5
+ GetConsentByIdParams,
6
+ GetConsentByIdResponse,
7
+ GetLatestConsentByUserIdParams,
8
+ GetLatestConsentByUserIdResponse,
9
+ GetLatestCookieConsentByDeviceIdParams,
10
+ GetLatestCookieConsentByDeviceIdResponse,
11
+ CreateUserConsentUpsertDTO,
12
+ CreateUserConsentResponse,
13
+ CreateDeviceCookieConsentUpsertDTO,
14
+ CreateDeviceCookieConsentResponse,
15
+ HealthResponse,
16
+ } from "../types";
17
+
18
+ const CONSENT_V1 = "/consent/v1";
19
+
20
+ export const consentService = (axiosInstance: AxiosInstance) => {
21
+ return {
22
+ /**
23
+ * Health check – GET /health
24
+ */
25
+ getHealth: async (): Promise<HealthResponse> => {
26
+ const { data } = await axiosInstance.get<HealthResponse>("/health");
27
+ return data;
28
+ },
29
+
30
+ /**
31
+ * Get all consent logs – GET /consent/v1/consent
32
+ * @param params - Optional filter by policy type (ACCOUNT_REGISTER | COOKIE_PREFERENCE)
33
+ */
34
+ getManyConsents: async (
35
+ params?: GetManyConsentParams
36
+ ): Promise<GetManyConsentResponse> => {
37
+ const { data } = await axiosInstance.get<GetManyConsentResponse>(
38
+ `${CONSENT_V1}/consent`,
39
+ { params: params ? { type: params.type } : undefined }
40
+ );
41
+ return data;
42
+ },
43
+
44
+ /**
45
+ * Get consent log by ID – GET /consent/v1/consent/{id}
46
+ */
47
+ getConsentById: async ({
48
+ id,
49
+ }: GetConsentByIdParams): Promise<GetConsentByIdResponse> => {
50
+ const { data } = await axiosInstance.get<GetConsentByIdResponse>(
51
+ `${CONSENT_V1}/consent/${id}`
52
+ );
53
+ return data;
54
+ },
55
+
56
+ /**
57
+ * Get latest consent for a user – GET /consent/v1/user-id?user_id=
58
+ */
59
+ getLatestConsentByUserId: async ({
60
+ user_id,
61
+ }: GetLatestConsentByUserIdParams): Promise<GetLatestConsentByUserIdResponse> => {
62
+ const { data } = await axiosInstance.get<GetLatestConsentByUserIdResponse>(
63
+ `${CONSENT_V1}/user-id`,
64
+ { params: { user_id } }
65
+ );
66
+ return data;
67
+ },
68
+
69
+ /**
70
+ * Create user consent (account register) – POST /consent/v1/user-id
71
+ * Consumer app must hash user_id/device_id (e.g. SHA-256) before passing.
72
+ */
73
+ createUserConsent: async (
74
+ body: CreateUserConsentUpsertDTO
75
+ ): Promise<CreateUserConsentResponse> => {
76
+ const { data } = await axiosInstance.post<CreateUserConsentResponse>(
77
+ `${CONSENT_V1}/user-id`,
78
+ body
79
+ );
80
+ return data;
81
+ },
82
+
83
+ /**
84
+ * Get latest cookie consent for a device – GET /consent/v1/cookies/device-id?device_id=
85
+ */
86
+ getLatestCookieConsentByDeviceId: async ({
87
+ device_id,
88
+ }: GetLatestCookieConsentByDeviceIdParams): Promise<GetLatestCookieConsentByDeviceIdResponse> => {
89
+ const { data } =
90
+ await axiosInstance.get<GetLatestCookieConsentByDeviceIdResponse>(
91
+ `${CONSENT_V1}/cookies/device-id`,
92
+ { params: { device_id } }
93
+ );
94
+ return data;
95
+ },
96
+
97
+ /**
98
+ * Create device cookie consent – POST /consent/v1/cookies/device-id
99
+ * Consumer app must hash device_id (e.g. SHA-256) before passing.
100
+ */
101
+ createDeviceCookieConsent: async (
102
+ body: CreateDeviceCookieConsentUpsertDTO
103
+ ): Promise<CreateDeviceCookieConsentResponse> => {
104
+ const { data } =
105
+ await axiosInstance.post<CreateDeviceCookieConsentResponse>(
106
+ `${CONSENT_V1}/cookies/device-id`,
107
+ body
108
+ );
109
+ return data;
110
+ },
111
+ };
112
+ };
@@ -0,0 +1 @@
1
+ export * from "./consent";