@codefast/tracking 0.5.0-canary.4 → 0.5.0-canary.6
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 +473 -0
- package/README.md +177 -95
- package/dist/adapters/tanstack-start.d.ts +80 -0
- package/dist/adapters/tanstack-start.d.ts.map +1 -0
- package/dist/adapters/tanstack-start.js +74 -0
- package/dist/adapters/tanstack-start.js.map +1 -0
- package/dist/client/ad-framework-consent.d.ts +62 -0
- package/dist/client/ad-framework-consent.d.ts.map +1 -0
- package/dist/client/ad-framework-consent.js +40 -0
- package/dist/client/ad-framework-consent.js.map +1 -0
- package/dist/client/browser-cookie.d.ts +9 -0
- package/dist/client/browser-cookie.d.ts.map +1 -0
- package/dist/client/browser-cookie.js +15 -0
- package/dist/client/browser-cookie.js.map +1 -0
- package/dist/client/consent-runtime.d.ts +53 -0
- package/dist/client/consent-runtime.d.ts.map +1 -0
- package/dist/client/consent-runtime.js +33 -0
- package/dist/client/consent-runtime.js.map +1 -0
- package/dist/client/{consent-storage.d.mts → consent-storage.d.ts} +8 -6
- package/dist/client/consent-storage.d.ts.map +1 -0
- package/dist/client/consent-storage.js +109 -0
- package/dist/client/consent-storage.js.map +1 -0
- package/dist/client/consent-withdrawal.d.ts +18 -0
- package/dist/client/consent-withdrawal.d.ts.map +1 -0
- package/dist/client/consent-withdrawal.js +17 -0
- package/dist/client/consent-withdrawal.js.map +1 -0
- package/dist/client/cookie-anonymous-id.d.ts +41 -0
- package/dist/client/cookie-anonymous-id.d.ts.map +1 -0
- package/dist/client/cookie-anonymous-id.js +65 -0
- package/dist/client/cookie-anonymous-id.js.map +1 -0
- package/dist/client/create-client-tracker.d.ts +60 -0
- package/dist/client/create-client-tracker.d.ts.map +1 -0
- package/dist/client/create-client-tracker.js +91 -0
- package/dist/client/create-client-tracker.js.map +1 -0
- package/dist/client/gpc.d.ts +10 -0
- package/dist/client/gpc.d.ts.map +1 -0
- package/dist/client/gpc.js +12 -0
- package/dist/client/gpc.js.map +1 -0
- package/dist/client/initial-consent-store.d.ts +63 -0
- package/dist/client/initial-consent-store.d.ts.map +1 -0
- package/dist/client/initial-consent-store.js +138 -0
- package/dist/client/initial-consent-store.js.map +1 -0
- package/dist/client/is-analytics-allowed.d.ts +26 -0
- package/dist/client/is-analytics-allowed.d.ts.map +1 -0
- package/dist/client/is-analytics-allowed.js +22 -0
- package/dist/client/is-analytics-allowed.js.map +1 -0
- package/dist/client/server-persisted-anonymous-id.d.ts +30 -0
- package/dist/client/server-persisted-anonymous-id.d.ts.map +1 -0
- package/dist/client/server-persisted-anonymous-id.js +72 -0
- package/dist/client/server-persisted-anonymous-id.js.map +1 -0
- package/dist/core/consent-config.d.ts +24 -0
- package/dist/core/consent-config.d.ts.map +1 -0
- package/dist/core/consent-config.js +9 -0
- package/dist/core/consent-config.js.map +1 -0
- package/dist/core/consent-receipt.d.ts +71 -0
- package/dist/core/consent-receipt.d.ts.map +1 -0
- package/dist/core/consent-receipt.js +39 -0
- package/dist/core/consent-receipt.js.map +1 -0
- package/dist/core/consent.d.ts +182 -0
- package/dist/core/consent.d.ts.map +1 -0
- package/dist/core/consent.js +159 -0
- package/dist/core/consent.js.map +1 -0
- package/dist/core/cookie.d.ts +15 -0
- package/dist/core/cookie.d.ts.map +1 -0
- package/dist/core/cookie.js +26 -0
- package/dist/core/cookie.js.map +1 -0
- package/dist/core/destination.d.ts +29 -0
- package/dist/core/destination.d.ts.map +1 -0
- package/dist/core/destination.js +2 -0
- package/dist/core/destination.js.map +1 -0
- package/dist/core/event-catalog.d.ts +35 -0
- package/dist/core/event-catalog.d.ts.map +1 -0
- package/dist/core/event-catalog.js +30 -0
- package/dist/core/event-catalog.js.map +1 -0
- package/dist/core/event-id.d.ts +7 -0
- package/dist/core/event-id.d.ts.map +1 -0
- package/dist/core/event-id.js +9 -0
- package/dist/core/event-id.js.map +1 -0
- package/dist/core/tracked-event.d.ts +15 -0
- package/dist/core/tracked-event.d.ts.map +1 -0
- package/dist/core/tracked-event.js +2 -0
- package/dist/core/tracked-event.js.map +1 -0
- package/dist/destinations/ad-consent.d.ts +23 -0
- package/dist/destinations/ad-consent.d.ts.map +1 -0
- package/dist/destinations/ad-consent.js +12 -0
- package/dist/destinations/ad-consent.js.map +1 -0
- package/dist/destinations/google-analytics.d.ts +148 -0
- package/dist/destinations/google-analytics.d.ts.map +1 -0
- package/dist/destinations/google-analytics.js +156 -0
- package/dist/destinations/google-analytics.js.map +1 -0
- package/dist/destinations/google-consent.d.ts +62 -0
- package/dist/destinations/google-consent.d.ts.map +1 -0
- package/dist/destinations/google-consent.js +109 -0
- package/dist/destinations/google-consent.js.map +1 -0
- package/dist/destinations/meta.d.ts +63 -0
- package/dist/destinations/meta.d.ts.map +1 -0
- package/dist/destinations/meta.js +44 -0
- package/dist/destinations/meta.js.map +1 -0
- package/dist/destinations/microsoft-uet.d.ts +56 -0
- package/dist/destinations/microsoft-uet.d.ts.map +1 -0
- package/dist/destinations/microsoft-uet.js +41 -0
- package/dist/destinations/microsoft-uet.js.map +1 -0
- package/dist/destinations/shared.d.ts +18 -0
- package/dist/destinations/shared.d.ts.map +1 -0
- package/dist/destinations/shared.js +19 -0
- package/dist/destinations/shared.js.map +1 -0
- package/dist/destinations/tiktok.d.ts +55 -0
- package/dist/destinations/tiktok.d.ts.map +1 -0
- package/dist/destinations/tiktok.js +40 -0
- package/dist/destinations/tiktok.js.map +1 -0
- package/dist/destinations/vercel-analytics.d.ts +25 -0
- package/dist/destinations/vercel-analytics.d.ts.map +1 -0
- package/dist/destinations/vercel-analytics.js +23 -0
- package/dist/destinations/vercel-analytics.js.map +1 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -0
- package/dist/react/consent-banner.d.ts +155 -0
- package/dist/react/consent-banner.d.ts.map +1 -0
- package/dist/react/consent-banner.js +171 -0
- package/dist/react/consent-banner.js.map +1 -0
- package/dist/react/gtag-consent-bootstrap.d.ts +17 -0
- package/dist/react/gtag-consent-bootstrap.d.ts.map +1 -0
- package/dist/react/gtag-consent-bootstrap.js +22 -0
- package/dist/react/gtag-consent-bootstrap.js.map +1 -0
- package/dist/react/use-consent.d.ts +42 -0
- package/dist/react/use-consent.d.ts.map +1 -0
- package/dist/react/use-consent.js +60 -0
- package/dist/react/use-consent.js.map +1 -0
- package/dist/react/use-google-consent-sync.d.ts +20 -0
- package/dist/react/use-google-consent-sync.d.ts.map +1 -0
- package/dist/react/use-google-consent-sync.js +22 -0
- package/dist/react/use-google-consent-sync.js.map +1 -0
- package/dist/react/use-initial-consent.d.ts +11 -0
- package/dist/react/use-initial-consent.d.ts.map +1 -0
- package/dist/react/use-initial-consent.js +18 -0
- package/dist/react/use-initial-consent.js.map +1 -0
- package/dist/server/anonymous-id-cookie.d.ts +67 -0
- package/dist/server/anonymous-id-cookie.d.ts.map +1 -0
- package/dist/server/anonymous-id-cookie.js +71 -0
- package/dist/server/anonymous-id-cookie.js.map +1 -0
- package/dist/server/consent-receipt-store.d.ts +56 -0
- package/dist/server/consent-receipt-store.d.ts.map +1 -0
- package/dist/server/consent-receipt-store.js +44 -0
- package/dist/server/consent-receipt-store.js.map +1 -0
- package/dist/server/consent-receipt.d.ts +41 -0
- package/dist/server/consent-receipt.d.ts.map +1 -0
- package/dist/server/consent-receipt.js +60 -0
- package/dist/server/consent-receipt.js.map +1 -0
- package/dist/server/initial-consent.d.ts +26 -0
- package/dist/server/initial-consent.d.ts.map +1 -0
- package/dist/server/initial-consent.js +31 -0
- package/dist/server/initial-consent.js.map +1 -0
- package/dist/server/measurement-protocol.d.ts +69 -0
- package/dist/server/measurement-protocol.d.ts.map +1 -0
- package/dist/server/measurement-protocol.js +61 -0
- package/dist/server/measurement-protocol.js.map +1 -0
- package/dist/server/region.d.ts +27 -0
- package/dist/server/region.d.ts.map +1 -0
- package/dist/server/region.js +69 -0
- package/dist/server/region.js.map +1 -0
- package/dist/server/user-deletion.d.ts +64 -0
- package/dist/server/user-deletion.d.ts.map +1 -0
- package/dist/server/user-deletion.js +54 -0
- package/dist/server/user-deletion.js.map +1 -0
- package/dist/tooling/import-protection.d.ts +19 -0
- package/dist/tooling/import-protection.d.ts.map +1 -0
- package/dist/tooling/import-protection.js +23 -0
- package/dist/tooling/import-protection.js.map +1 -0
- package/package.json +202 -107
- package/src/adapters/tanstack-start.ts +135 -0
- package/src/client/ad-framework-consent.ts +86 -0
- package/src/client/browser-cookie.ts +16 -0
- package/src/client/consent-runtime.ts +80 -0
- package/src/client/consent-storage.ts +31 -1
- package/src/client/consent-withdrawal.ts +32 -0
- package/src/client/cookie-anonymous-id.ts +112 -0
- package/src/client/create-client-tracker.ts +128 -86
- package/src/client/gpc.ts +4 -2
- package/src/client/initial-consent-store.ts +218 -0
- package/src/client/is-analytics-allowed.ts +43 -0
- package/src/client/server-persisted-anonymous-id.ts +102 -0
- package/src/core/consent-config.ts +27 -0
- package/src/core/consent-receipt.ts +115 -0
- package/src/core/consent.ts +164 -10
- package/src/core/cookie.ts +29 -0
- package/src/core/destination.ts +17 -8
- package/src/core/event-catalog.ts +29 -15
- package/src/core/event-id.ts +1 -2
- package/src/core/tracked-event.ts +4 -4
- package/src/css/consent.css +119 -0
- package/src/destinations/ad-consent.ts +29 -0
- package/src/destinations/google-analytics.ts +196 -133
- package/src/destinations/google-consent.ts +164 -0
- package/src/destinations/meta.ts +96 -0
- package/src/destinations/microsoft-uet.ts +86 -0
- package/src/destinations/shared.ts +45 -0
- package/src/destinations/tiktok.ts +85 -0
- package/src/destinations/vercel-analytics.ts +23 -24
- package/src/index.ts +165 -8
- package/src/react/consent-banner.tsx +308 -111
- package/src/react/gtag-consent-bootstrap.tsx +48 -0
- package/src/react/use-consent.ts +53 -45
- package/src/react/use-google-consent-sync.ts +38 -0
- package/src/react/use-initial-consent.ts +22 -0
- package/src/server/anonymous-id-cookie.ts +103 -0
- package/src/server/consent-receipt-store.ts +79 -0
- package/src/server/consent-receipt.ts +89 -0
- package/src/server/initial-consent.ts +46 -0
- package/src/server/measurement-protocol.ts +114 -0
- package/src/server/region.ts +22 -15
- package/src/server/user-deletion.ts +93 -0
- package/src/tooling/import-protection.ts +22 -0
- package/dist/client/consent-storage.mjs +0 -63
- package/dist/client/create-client-tracker.d.mts +0 -37
- package/dist/client/create-client-tracker.mjs +0 -66
- package/dist/client/gpc.d.mts +0 -10
- package/dist/client/gpc.mjs +0 -12
- package/dist/client/index.d.mts +0 -8
- package/dist/client/index.mjs +0 -8
- package/dist/client/lifecycle.d.mts +0 -23
- package/dist/client/lifecycle.mjs +0 -30
- package/dist/client/local-storage.d.mts +0 -13
- package/dist/client/local-storage.mjs +0 -31
- package/dist/client/queue.d.mts +0 -49
- package/dist/client/queue.mjs +0 -71
- package/dist/client/router.d.mts +0 -30
- package/dist/client/router.mjs +0 -17
- package/dist/core/consent.d.mts +0 -89
- package/dist/core/consent.mjs +0 -57
- package/dist/core/destination.d.mts +0 -23
- package/dist/core/destination.mjs +0 -1
- package/dist/core/event-catalog.d.mts +0 -36
- package/dist/core/event-catalog.mjs +0 -12
- package/dist/core/event-id.d.mts +0 -10
- package/dist/core/event-id.mjs +0 -12
- package/dist/core/index.d.mts +0 -6
- package/dist/core/index.mjs +0 -4
- package/dist/core/tracked-event.d.mts +0 -17
- package/dist/core/tracked-event.mjs +0 -1
- package/dist/destinations/ga4-measurement-protocol.d.mts +0 -54
- package/dist/destinations/ga4-measurement-protocol.mjs +0 -89
- package/dist/destinations/google-analytics.d.mts +0 -98
- package/dist/destinations/google-analytics.mjs +0 -126
- package/dist/destinations/http-destination.d.mts +0 -20
- package/dist/destinations/http-destination.mjs +0 -25
- package/dist/destinations/index.d.mts +0 -5
- package/dist/destinations/index.mjs +0 -5
- package/dist/destinations/vercel-analytics.d.mts +0 -13
- package/dist/destinations/vercel-analytics.mjs +0 -30
- package/dist/index.d.mts +0 -6
- package/dist/index.mjs +0 -4
- package/dist/react/consent-banner.d.mts +0 -75
- package/dist/react/consent-banner.mjs +0 -114
- package/dist/react/index.d.mts +0 -3
- package/dist/react/index.mjs +0 -3
- package/dist/react/use-consent.d.mts +0 -49
- package/dist/react/use-consent.mjs +0 -54
- package/dist/server/create-server-tracker.d.mts +0 -42
- package/dist/server/create-server-tracker.mjs +0 -67
- package/dist/server/index.d.mts +0 -3
- package/dist/server/index.mjs +0 -3
- package/dist/server/region.d.mts +0 -20
- package/dist/server/region.mjs +0 -56
- package/src/client/index.ts +0 -17
- package/src/client/lifecycle.ts +0 -50
- package/src/client/local-storage.ts +0 -44
- package/src/client/queue.ts +0 -117
- package/src/client/router.ts +0 -37
- package/src/core/index.ts +0 -24
- package/src/destinations/ga4-measurement-protocol.ts +0 -166
- package/src/destinations/http-destination.ts +0 -33
- package/src/destinations/index.ts +0 -20
- package/src/react/index.ts +0 -5
- package/src/server/create-server-tracker.ts +0 -128
- package/src/server/index.ts +0 -4
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `@codefast/tracking` subpaths every client bundle must deny (picomatch patterns) —
|
|
3
|
+
* framework-neutral data each build tool maps to its own guard: TanStack Start's
|
|
4
|
+
* `importProtection.client.specifiers`, Next's `server-only`, Remix's `.server` convention.
|
|
5
|
+
* Ships and versions with the package instead of going stale in each consumer's config.
|
|
6
|
+
* Nothing in this package imports it — its consumers are app build configs (see apps/ui
|
|
7
|
+
* vite.config.ts).
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* tanstackStart({
|
|
12
|
+
* importProtection: { client: { specifiers: [...SERVER_ONLY_SUBPATHS] } },
|
|
13
|
+
* });
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @since 1.0.0-canary.6
|
|
17
|
+
*/
|
|
18
|
+
export const SERVER_ONLY_SUBPATHS = [
|
|
19
|
+
"@codefast/tracking/server",
|
|
20
|
+
"@codefast/tracking/server/**",
|
|
21
|
+
"@codefast/tracking/adapters/**",
|
|
22
|
+
];
|
|
23
|
+
//# sourceMappingURL=import-protection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-protection.js","sourceRoot":"","sources":["../../src/tooling/import-protection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAA0B;IACzD,2BAA2B;IAC3B,8BAA8B;IAC9B,gCAAgC;CACjC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codefast/tracking",
|
|
3
|
-
"version": "0.5.0-canary.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.5.0-canary.6",
|
|
4
|
+
"description": "Consent-gated, type-safe event tracking for TanStack Start — client tracker and server consent helpers over a per-app Standard Schema event catalog",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"analytics",
|
|
7
7
|
"codefast",
|
|
8
8
|
"consent",
|
|
9
|
+
"standard-schema",
|
|
9
10
|
"tanstack-start",
|
|
10
11
|
"tracking",
|
|
11
|
-
"typescript"
|
|
12
|
-
"zod"
|
|
12
|
+
"typescript"
|
|
13
13
|
],
|
|
14
14
|
"homepage": "https://github.com/codefastlabs/codefast/tree/main/packages/tracking#readme",
|
|
15
15
|
"bugs": {
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
],
|
|
32
32
|
"type": "module",
|
|
33
33
|
"sideEffects": false,
|
|
34
|
-
"main": "./dist/index.
|
|
35
|
-
"module": "./dist/index.
|
|
36
|
-
"types": "./dist/index.d.
|
|
34
|
+
"main": "./dist/index.js",
|
|
35
|
+
"module": "./dist/index.js",
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
37
|
"imports": {
|
|
38
38
|
"#/tests/*": [
|
|
39
39
|
"./tests/*",
|
|
@@ -42,175 +42,267 @@
|
|
|
42
42
|
"./tests/*/index.ts",
|
|
43
43
|
"./tests/*/index.tsx"
|
|
44
44
|
],
|
|
45
|
-
"#/*":
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
"#/*": {
|
|
46
|
+
"source": [
|
|
47
|
+
"./src/*",
|
|
48
|
+
"./src/*.ts",
|
|
49
|
+
"./src/*.tsx",
|
|
50
|
+
"./src/*/index.ts",
|
|
51
|
+
"./src/*/index.tsx"
|
|
52
|
+
],
|
|
53
|
+
"types": [
|
|
54
|
+
"./dist/*.d.ts",
|
|
55
|
+
"./dist/*/index.d.ts"
|
|
56
|
+
],
|
|
57
|
+
"default": [
|
|
58
|
+
"./dist/*.js",
|
|
59
|
+
"./dist/*/index.js"
|
|
60
|
+
]
|
|
61
|
+
}
|
|
52
62
|
},
|
|
53
63
|
"exports": {
|
|
54
64
|
".": {
|
|
55
65
|
"source": "./src/index.ts",
|
|
56
|
-
"types": "./dist/index.d.
|
|
57
|
-
"import": "./dist/index.
|
|
66
|
+
"types": "./dist/index.d.ts",
|
|
67
|
+
"import": "./dist/index.js"
|
|
68
|
+
},
|
|
69
|
+
"./adapters/tanstack-start": {
|
|
70
|
+
"source": "./src/adapters/tanstack-start.ts",
|
|
71
|
+
"types": "./dist/adapters/tanstack-start.d.ts",
|
|
72
|
+
"import": "./dist/adapters/tanstack-start.js"
|
|
73
|
+
},
|
|
74
|
+
"./client/ad-framework-consent": {
|
|
75
|
+
"source": "./src/client/ad-framework-consent.ts",
|
|
76
|
+
"types": "./dist/client/ad-framework-consent.d.ts",
|
|
77
|
+
"import": "./dist/client/ad-framework-consent.js"
|
|
78
|
+
},
|
|
79
|
+
"./client/browser-cookie": {
|
|
80
|
+
"source": "./src/client/browser-cookie.ts",
|
|
81
|
+
"types": "./dist/client/browser-cookie.d.ts",
|
|
82
|
+
"import": "./dist/client/browser-cookie.js"
|
|
58
83
|
},
|
|
59
|
-
"./client": {
|
|
60
|
-
"source": "./src/client/
|
|
61
|
-
"types": "./dist/client/
|
|
62
|
-
"import": "./dist/client/
|
|
84
|
+
"./client/consent-runtime": {
|
|
85
|
+
"source": "./src/client/consent-runtime.ts",
|
|
86
|
+
"types": "./dist/client/consent-runtime.d.ts",
|
|
87
|
+
"import": "./dist/client/consent-runtime.js"
|
|
63
88
|
},
|
|
64
89
|
"./client/consent-storage": {
|
|
65
90
|
"source": "./src/client/consent-storage.ts",
|
|
66
|
-
"types": "./dist/client/consent-storage.d.
|
|
67
|
-
"import": "./dist/client/consent-storage.
|
|
91
|
+
"types": "./dist/client/consent-storage.d.ts",
|
|
92
|
+
"import": "./dist/client/consent-storage.js"
|
|
93
|
+
},
|
|
94
|
+
"./client/consent-withdrawal": {
|
|
95
|
+
"source": "./src/client/consent-withdrawal.ts",
|
|
96
|
+
"types": "./dist/client/consent-withdrawal.d.ts",
|
|
97
|
+
"import": "./dist/client/consent-withdrawal.js"
|
|
98
|
+
},
|
|
99
|
+
"./client/cookie-anonymous-id": {
|
|
100
|
+
"source": "./src/client/cookie-anonymous-id.ts",
|
|
101
|
+
"types": "./dist/client/cookie-anonymous-id.d.ts",
|
|
102
|
+
"import": "./dist/client/cookie-anonymous-id.js"
|
|
68
103
|
},
|
|
69
104
|
"./client/create-client-tracker": {
|
|
70
105
|
"source": "./src/client/create-client-tracker.ts",
|
|
71
|
-
"types": "./dist/client/create-client-tracker.d.
|
|
72
|
-
"import": "./dist/client/create-client-tracker.
|
|
106
|
+
"types": "./dist/client/create-client-tracker.d.ts",
|
|
107
|
+
"import": "./dist/client/create-client-tracker.js"
|
|
73
108
|
},
|
|
74
109
|
"./client/gpc": {
|
|
75
110
|
"source": "./src/client/gpc.ts",
|
|
76
|
-
"types": "./dist/client/gpc.d.
|
|
77
|
-
"import": "./dist/client/gpc.
|
|
78
|
-
},
|
|
79
|
-
"./client/
|
|
80
|
-
"source": "./src/client/
|
|
81
|
-
"types": "./dist/client/
|
|
82
|
-
"import": "./dist/client/
|
|
83
|
-
},
|
|
84
|
-
"./client/
|
|
85
|
-
"source": "./src/client/
|
|
86
|
-
"types": "./dist/client/
|
|
87
|
-
"import": "./dist/client/
|
|
88
|
-
},
|
|
89
|
-
"./client/
|
|
90
|
-
"source": "./src/client/
|
|
91
|
-
"types": "./dist/client/
|
|
92
|
-
"import": "./dist/client/
|
|
93
|
-
},
|
|
94
|
-
"./client/router": {
|
|
95
|
-
"source": "./src/client/router.ts",
|
|
96
|
-
"types": "./dist/client/router.d.mts",
|
|
97
|
-
"import": "./dist/client/router.mjs"
|
|
98
|
-
},
|
|
99
|
-
"./core": {
|
|
100
|
-
"source": "./src/core/index.ts",
|
|
101
|
-
"types": "./dist/core/index.d.mts",
|
|
102
|
-
"import": "./dist/core/index.mjs"
|
|
111
|
+
"types": "./dist/client/gpc.d.ts",
|
|
112
|
+
"import": "./dist/client/gpc.js"
|
|
113
|
+
},
|
|
114
|
+
"./client/initial-consent-store": {
|
|
115
|
+
"source": "./src/client/initial-consent-store.ts",
|
|
116
|
+
"types": "./dist/client/initial-consent-store.d.ts",
|
|
117
|
+
"import": "./dist/client/initial-consent-store.js"
|
|
118
|
+
},
|
|
119
|
+
"./client/is-analytics-allowed": {
|
|
120
|
+
"source": "./src/client/is-analytics-allowed.ts",
|
|
121
|
+
"types": "./dist/client/is-analytics-allowed.d.ts",
|
|
122
|
+
"import": "./dist/client/is-analytics-allowed.js"
|
|
123
|
+
},
|
|
124
|
+
"./client/server-persisted-anonymous-id": {
|
|
125
|
+
"source": "./src/client/server-persisted-anonymous-id.ts",
|
|
126
|
+
"types": "./dist/client/server-persisted-anonymous-id.d.ts",
|
|
127
|
+
"import": "./dist/client/server-persisted-anonymous-id.js"
|
|
103
128
|
},
|
|
104
129
|
"./core/consent": {
|
|
105
130
|
"source": "./src/core/consent.ts",
|
|
106
|
-
"types": "./dist/core/consent.d.
|
|
107
|
-
"import": "./dist/core/consent.
|
|
131
|
+
"types": "./dist/core/consent.d.ts",
|
|
132
|
+
"import": "./dist/core/consent.js"
|
|
133
|
+
},
|
|
134
|
+
"./core/consent-config": {
|
|
135
|
+
"source": "./src/core/consent-config.ts",
|
|
136
|
+
"types": "./dist/core/consent-config.d.ts",
|
|
137
|
+
"import": "./dist/core/consent-config.js"
|
|
138
|
+
},
|
|
139
|
+
"./core/consent-receipt": {
|
|
140
|
+
"source": "./src/core/consent-receipt.ts",
|
|
141
|
+
"types": "./dist/core/consent-receipt.d.ts",
|
|
142
|
+
"import": "./dist/core/consent-receipt.js"
|
|
143
|
+
},
|
|
144
|
+
"./core/cookie": {
|
|
145
|
+
"source": "./src/core/cookie.ts",
|
|
146
|
+
"types": "./dist/core/cookie.d.ts",
|
|
147
|
+
"import": "./dist/core/cookie.js"
|
|
108
148
|
},
|
|
109
149
|
"./core/destination": {
|
|
110
150
|
"source": "./src/core/destination.ts",
|
|
111
|
-
"types": "./dist/core/destination.d.
|
|
112
|
-
"import": "./dist/core/destination.
|
|
151
|
+
"types": "./dist/core/destination.d.ts",
|
|
152
|
+
"import": "./dist/core/destination.js"
|
|
113
153
|
},
|
|
114
154
|
"./core/event-catalog": {
|
|
115
155
|
"source": "./src/core/event-catalog.ts",
|
|
116
|
-
"types": "./dist/core/event-catalog.d.
|
|
117
|
-
"import": "./dist/core/event-catalog.
|
|
156
|
+
"types": "./dist/core/event-catalog.d.ts",
|
|
157
|
+
"import": "./dist/core/event-catalog.js"
|
|
118
158
|
},
|
|
119
159
|
"./core/event-id": {
|
|
120
160
|
"source": "./src/core/event-id.ts",
|
|
121
|
-
"types": "./dist/core/event-id.d.
|
|
122
|
-
"import": "./dist/core/event-id.
|
|
161
|
+
"types": "./dist/core/event-id.d.ts",
|
|
162
|
+
"import": "./dist/core/event-id.js"
|
|
123
163
|
},
|
|
124
164
|
"./core/tracked-event": {
|
|
125
165
|
"source": "./src/core/tracked-event.ts",
|
|
126
|
-
"types": "./dist/core/tracked-event.d.
|
|
127
|
-
"import": "./dist/core/tracked-event.
|
|
128
|
-
},
|
|
129
|
-
"./destinations": {
|
|
130
|
-
"source": "./src/destinations/index.ts",
|
|
131
|
-
"types": "./dist/destinations/index.d.mts",
|
|
132
|
-
"import": "./dist/destinations/index.mjs"
|
|
166
|
+
"types": "./dist/core/tracked-event.d.ts",
|
|
167
|
+
"import": "./dist/core/tracked-event.js"
|
|
133
168
|
},
|
|
134
|
-
"./destinations/
|
|
135
|
-
"source": "./src/destinations/
|
|
136
|
-
"types": "./dist/destinations/
|
|
137
|
-
"import": "./dist/destinations/
|
|
169
|
+
"./destinations/ad-consent": {
|
|
170
|
+
"source": "./src/destinations/ad-consent.ts",
|
|
171
|
+
"types": "./dist/destinations/ad-consent.d.ts",
|
|
172
|
+
"import": "./dist/destinations/ad-consent.js"
|
|
138
173
|
},
|
|
139
174
|
"./destinations/google-analytics": {
|
|
140
175
|
"source": "./src/destinations/google-analytics.ts",
|
|
141
|
-
"types": "./dist/destinations/google-analytics.d.
|
|
142
|
-
"import": "./dist/destinations/google-analytics.
|
|
176
|
+
"types": "./dist/destinations/google-analytics.d.ts",
|
|
177
|
+
"import": "./dist/destinations/google-analytics.js"
|
|
178
|
+
},
|
|
179
|
+
"./destinations/google-consent": {
|
|
180
|
+
"source": "./src/destinations/google-consent.ts",
|
|
181
|
+
"types": "./dist/destinations/google-consent.d.ts",
|
|
182
|
+
"import": "./dist/destinations/google-consent.js"
|
|
143
183
|
},
|
|
144
|
-
"./destinations/
|
|
145
|
-
"source": "./src/destinations/
|
|
146
|
-
"types": "./dist/destinations/
|
|
147
|
-
"import": "./dist/destinations/
|
|
184
|
+
"./destinations/meta": {
|
|
185
|
+
"source": "./src/destinations/meta.ts",
|
|
186
|
+
"types": "./dist/destinations/meta.d.ts",
|
|
187
|
+
"import": "./dist/destinations/meta.js"
|
|
188
|
+
},
|
|
189
|
+
"./destinations/microsoft-uet": {
|
|
190
|
+
"source": "./src/destinations/microsoft-uet.ts",
|
|
191
|
+
"types": "./dist/destinations/microsoft-uet.d.ts",
|
|
192
|
+
"import": "./dist/destinations/microsoft-uet.js"
|
|
193
|
+
},
|
|
194
|
+
"./destinations/shared": {
|
|
195
|
+
"source": "./src/destinations/shared.ts",
|
|
196
|
+
"types": "./dist/destinations/shared.d.ts",
|
|
197
|
+
"import": "./dist/destinations/shared.js"
|
|
198
|
+
},
|
|
199
|
+
"./destinations/tiktok": {
|
|
200
|
+
"source": "./src/destinations/tiktok.ts",
|
|
201
|
+
"types": "./dist/destinations/tiktok.d.ts",
|
|
202
|
+
"import": "./dist/destinations/tiktok.js"
|
|
148
203
|
},
|
|
149
204
|
"./destinations/vercel-analytics": {
|
|
150
205
|
"source": "./src/destinations/vercel-analytics.ts",
|
|
151
|
-
"types": "./dist/destinations/vercel-analytics.d.
|
|
152
|
-
"import": "./dist/destinations/vercel-analytics.
|
|
153
|
-
},
|
|
154
|
-
"./react": {
|
|
155
|
-
"source": "./src/react/index.ts",
|
|
156
|
-
"types": "./dist/react/index.d.mts",
|
|
157
|
-
"import": "./dist/react/index.mjs"
|
|
206
|
+
"types": "./dist/destinations/vercel-analytics.d.ts",
|
|
207
|
+
"import": "./dist/destinations/vercel-analytics.js"
|
|
158
208
|
},
|
|
159
209
|
"./react/consent-banner": {
|
|
160
210
|
"source": "./src/react/consent-banner.tsx",
|
|
161
|
-
"types": "./dist/react/consent-banner.d.
|
|
162
|
-
"import": "./dist/react/consent-banner.
|
|
211
|
+
"types": "./dist/react/consent-banner.d.ts",
|
|
212
|
+
"import": "./dist/react/consent-banner.js"
|
|
213
|
+
},
|
|
214
|
+
"./react/gtag-consent-bootstrap": {
|
|
215
|
+
"source": "./src/react/gtag-consent-bootstrap.tsx",
|
|
216
|
+
"types": "./dist/react/gtag-consent-bootstrap.d.ts",
|
|
217
|
+
"import": "./dist/react/gtag-consent-bootstrap.js"
|
|
163
218
|
},
|
|
164
219
|
"./react/use-consent": {
|
|
165
220
|
"source": "./src/react/use-consent.ts",
|
|
166
|
-
"types": "./dist/react/use-consent.d.
|
|
167
|
-
"import": "./dist/react/use-consent.
|
|
221
|
+
"types": "./dist/react/use-consent.d.ts",
|
|
222
|
+
"import": "./dist/react/use-consent.js"
|
|
223
|
+
},
|
|
224
|
+
"./react/use-google-consent-sync": {
|
|
225
|
+
"source": "./src/react/use-google-consent-sync.ts",
|
|
226
|
+
"types": "./dist/react/use-google-consent-sync.d.ts",
|
|
227
|
+
"import": "./dist/react/use-google-consent-sync.js"
|
|
228
|
+
},
|
|
229
|
+
"./react/use-initial-consent": {
|
|
230
|
+
"source": "./src/react/use-initial-consent.ts",
|
|
231
|
+
"types": "./dist/react/use-initial-consent.d.ts",
|
|
232
|
+
"import": "./dist/react/use-initial-consent.js"
|
|
168
233
|
},
|
|
169
|
-
"./server": {
|
|
170
|
-
"source": "./src/server/
|
|
171
|
-
"types": "./dist/server/
|
|
172
|
-
"import": "./dist/server/
|
|
234
|
+
"./server/anonymous-id-cookie": {
|
|
235
|
+
"source": "./src/server/anonymous-id-cookie.ts",
|
|
236
|
+
"types": "./dist/server/anonymous-id-cookie.d.ts",
|
|
237
|
+
"import": "./dist/server/anonymous-id-cookie.js"
|
|
173
238
|
},
|
|
174
|
-
"./server/
|
|
175
|
-
"source": "./src/server/
|
|
176
|
-
"types": "./dist/server/
|
|
177
|
-
"import": "./dist/server/
|
|
239
|
+
"./server/consent-receipt": {
|
|
240
|
+
"source": "./src/server/consent-receipt.ts",
|
|
241
|
+
"types": "./dist/server/consent-receipt.d.ts",
|
|
242
|
+
"import": "./dist/server/consent-receipt.js"
|
|
243
|
+
},
|
|
244
|
+
"./server/consent-receipt-store": {
|
|
245
|
+
"source": "./src/server/consent-receipt-store.ts",
|
|
246
|
+
"types": "./dist/server/consent-receipt-store.d.ts",
|
|
247
|
+
"import": "./dist/server/consent-receipt-store.js"
|
|
248
|
+
},
|
|
249
|
+
"./server/initial-consent": {
|
|
250
|
+
"source": "./src/server/initial-consent.ts",
|
|
251
|
+
"types": "./dist/server/initial-consent.d.ts",
|
|
252
|
+
"import": "./dist/server/initial-consent.js"
|
|
253
|
+
},
|
|
254
|
+
"./server/measurement-protocol": {
|
|
255
|
+
"source": "./src/server/measurement-protocol.ts",
|
|
256
|
+
"types": "./dist/server/measurement-protocol.d.ts",
|
|
257
|
+
"import": "./dist/server/measurement-protocol.js"
|
|
178
258
|
},
|
|
179
259
|
"./server/region": {
|
|
180
260
|
"source": "./src/server/region.ts",
|
|
181
|
-
"types": "./dist/server/region.d.
|
|
182
|
-
"import": "./dist/server/region.
|
|
261
|
+
"types": "./dist/server/region.d.ts",
|
|
262
|
+
"import": "./dist/server/region.js"
|
|
263
|
+
},
|
|
264
|
+
"./server/user-deletion": {
|
|
265
|
+
"source": "./src/server/user-deletion.ts",
|
|
266
|
+
"types": "./dist/server/user-deletion.d.ts",
|
|
267
|
+
"import": "./dist/server/user-deletion.js"
|
|
183
268
|
},
|
|
269
|
+
"./tooling/import-protection": {
|
|
270
|
+
"source": "./src/tooling/import-protection.ts",
|
|
271
|
+
"types": "./dist/tooling/import-protection.d.ts",
|
|
272
|
+
"import": "./dist/tooling/import-protection.js"
|
|
273
|
+
},
|
|
274
|
+
"./css/*": "./src/css/*",
|
|
184
275
|
"./package.json": "./package.json"
|
|
185
276
|
},
|
|
186
277
|
"publishConfig": {
|
|
187
278
|
"access": "public"
|
|
188
279
|
},
|
|
189
280
|
"dependencies": {
|
|
190
|
-
"
|
|
281
|
+
"@standard-schema/spec": "^1.1.0"
|
|
191
282
|
},
|
|
192
283
|
"devDependencies": {
|
|
284
|
+
"@tanstack/react-start": "^1.168.32",
|
|
193
285
|
"@testing-library/dom": "^10.4.1",
|
|
194
286
|
"@testing-library/jest-dom": "^6.9.1",
|
|
195
287
|
"@testing-library/react": "^16.3.2",
|
|
196
288
|
"@testing-library/user-event": "^14.6.1",
|
|
197
|
-
"@types/node": "^26.1.
|
|
289
|
+
"@types/node": "^26.1.1",
|
|
198
290
|
"@types/react": "^19.2.17",
|
|
199
291
|
"@types/react-dom": "^19.2.3",
|
|
200
|
-
"@typescript/native-preview": "7.0.0-dev.20260704.1",
|
|
201
292
|
"@vercel/analytics": "^2.0.1",
|
|
202
293
|
"@vitejs/plugin-react": "^6.0.3",
|
|
203
|
-
"@vitest/coverage-v8": "^4.1.
|
|
294
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
204
295
|
"expect-type": "^1.4.0",
|
|
205
296
|
"jsdom": "^29.1.1",
|
|
206
297
|
"react": "^19.2.7",
|
|
207
298
|
"react-dom": "^19.2.7",
|
|
208
|
-
"
|
|
209
|
-
"
|
|
210
|
-
"
|
|
211
|
-
"@codefast/typescript-config": "0.5.0-canary.
|
|
299
|
+
"typescript": "^7.0.2",
|
|
300
|
+
"vitest": "^4.1.10",
|
|
301
|
+
"zod": "^4.4.3",
|
|
302
|
+
"@codefast/typescript-config": "0.5.0-canary.6"
|
|
212
303
|
},
|
|
213
304
|
"peerDependencies": {
|
|
305
|
+
"@tanstack/react-start": ">=1.168.0",
|
|
214
306
|
"@types/react": ">=19.0.0",
|
|
215
307
|
"@types/react-dom": ">=19.0.0",
|
|
216
308
|
"@vercel/analytics": ">=1.0.0",
|
|
@@ -218,6 +310,9 @@
|
|
|
218
310
|
"react-dom": ">=19.0.0"
|
|
219
311
|
},
|
|
220
312
|
"peerDependenciesMeta": {
|
|
313
|
+
"@tanstack/react-start": {
|
|
314
|
+
"optional": true
|
|
315
|
+
},
|
|
221
316
|
"@types/react": {
|
|
222
317
|
"optional": true
|
|
223
318
|
},
|
|
@@ -238,8 +333,8 @@
|
|
|
238
333
|
"node": ">=24.0.0"
|
|
239
334
|
},
|
|
240
335
|
"scripts": {
|
|
241
|
-
"build": "
|
|
242
|
-
"check-types": "
|
|
336
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
337
|
+
"check-types": "tsc --noEmit",
|
|
243
338
|
"clean": "rm -rf dist",
|
|
244
339
|
"test": "vitest run",
|
|
245
340
|
"test:coverage": "vitest run --coverage",
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import {
|
|
2
|
+
deleteCookie,
|
|
3
|
+
getRequestHeader,
|
|
4
|
+
getRequestIP,
|
|
5
|
+
setCookie,
|
|
6
|
+
setResponseHeader,
|
|
7
|
+
} from "@tanstack/react-start/server";
|
|
8
|
+
|
|
9
|
+
import type { ConsentCategory, InitialConsent } from "#/core/consent";
|
|
10
|
+
import type { ConsentReceipt, ConsentReceiptInput } from "#/core/consent-receipt";
|
|
11
|
+
import { isConsentReceiptInput } from "#/core/consent-receipt";
|
|
12
|
+
import type { AnonymousIdCookieOptions } from "#/server/anonymous-id-cookie";
|
|
13
|
+
import { resolveAnonymousIdCookie, resolveClearAnonymousIdCookie } from "#/server/anonymous-id-cookie";
|
|
14
|
+
import { buildConsentReceipt } from "#/server/consent-receipt";
|
|
15
|
+
import type { ReceiptStore } from "#/server/consent-receipt-store";
|
|
16
|
+
import { resolveInitialConsent } from "#/server/initial-consent";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @since 1.0.0-canary.7
|
|
20
|
+
*/
|
|
21
|
+
export interface InitialConsentFromRequestOptions {
|
|
22
|
+
/**
|
|
23
|
+
* Header carrying the ISO 3166-1 alpha-2 country code.
|
|
24
|
+
*
|
|
25
|
+
* @defaultValue "x-vercel-ip-country"
|
|
26
|
+
*/
|
|
27
|
+
countryHeaderName?: string | undefined;
|
|
28
|
+
/** Categories the app's prompt asks about — opt-out regions grant exactly these by default. */
|
|
29
|
+
requestedCategories: ReadonlyArray<ConsentCategory>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Region-correct `InitialConsent` for the current request: reads the platform geo header
|
|
34
|
+
* and `sec-gpc`, fails closed when geo is missing, and stamps
|
|
35
|
+
* `cache-control: private, no-store` — the value is per-visitor by definition, so no
|
|
36
|
+
* shared cache may ever store the response carrying it.
|
|
37
|
+
*
|
|
38
|
+
* Server-only: deny this subpath in the client environment via Start's `importProtection`
|
|
39
|
+
* — the compiler already strips it with stubbed handler bodies.
|
|
40
|
+
*
|
|
41
|
+
* @since 1.0.0-canary.6
|
|
42
|
+
*/
|
|
43
|
+
export function resolveInitialConsentFromRequest(options: InitialConsentFromRequestOptions): InitialConsent {
|
|
44
|
+
setResponseHeader("cache-control", "private, no-store");
|
|
45
|
+
|
|
46
|
+
return resolveInitialConsent({
|
|
47
|
+
countryCode: getRequestHeader(options.countryHeaderName ?? "x-vercel-ip-country"),
|
|
48
|
+
hasGlobalPrivacyControlSignal: getRequestHeader("sec-gpc") === "1",
|
|
49
|
+
requestedCategories: options.requestedCategories,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Persists (or prolongs) a client-minted anonymous id via the framework's `setCookie` (which
|
|
55
|
+
* appends, so it never clobbers another `Set-Cookie` on the response) — the server re-issue
|
|
56
|
+
* that escapes Safari ITP's 7-day cap on script-written cookies. Validation lives in
|
|
57
|
+
* `resolveAnonymousIdCookie`: a non-UUID id throws, so this can safely back a public server
|
|
58
|
+
* function without echoing attacker input into a header.
|
|
59
|
+
*
|
|
60
|
+
* @since 1.0.0-canary.6
|
|
61
|
+
*/
|
|
62
|
+
export function setAnonymousIdResponseCookie(options: AnonymousIdCookieOptions): void {
|
|
63
|
+
const { name, value, ...attributes } = resolveAnonymousIdCookie({
|
|
64
|
+
cookieName: options.cookieName,
|
|
65
|
+
id: options.id,
|
|
66
|
+
maxAgeSeconds: options.maxAgeSeconds,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
setCookie(name, value, attributes);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Expires the anonymous-id cookie on the current response — the server half of a consent withdrawal.
|
|
74
|
+
*
|
|
75
|
+
* @since 1.0.0-canary.6
|
|
76
|
+
*/
|
|
77
|
+
export function clearAnonymousIdResponseCookie(cookieName: string): void {
|
|
78
|
+
const { name, ...attributes } = resolveClearAnonymousIdCookie(cookieName);
|
|
79
|
+
|
|
80
|
+
deleteCookie(name, attributes);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The client-visible acknowledgement of a recorded receipt — deliberately minimal so the
|
|
85
|
+
* stored PII (`subjectId`, `ipCoarse`) is never echoed back over the wire.
|
|
86
|
+
*
|
|
87
|
+
* @since 1.0.0-canary.7
|
|
88
|
+
*/
|
|
89
|
+
export interface ConsentReceiptAck {
|
|
90
|
+
receiptId: string;
|
|
91
|
+
timestamp: number;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @since 1.0.0-canary.7
|
|
96
|
+
*/
|
|
97
|
+
export interface RecordConsentReceiptFromRequestOptions {
|
|
98
|
+
input: ConsentReceiptInput;
|
|
99
|
+
/**
|
|
100
|
+
* Optional tamper-evidence signer — supply an HMAC/signature over the receipt to stamp an
|
|
101
|
+
* `integrityKey`. Omit it and the stored receipt carries none.
|
|
102
|
+
*/
|
|
103
|
+
sign?: ((receipt: Omit<ConsentReceipt, "integrityKey">) => string) | undefined;
|
|
104
|
+
store: ReceiptStore;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Records a consent receipt for the current request: rejects a body-supplied IP, derives a
|
|
109
|
+
* coarsened one from the connection, builds the server-stamped receipt, appends it to the
|
|
110
|
+
* store, and stamps `cache-control: no-store` — the response carries PII, so no cache
|
|
111
|
+
* (shared or private) may store it. Returns a minimal ack, never the stored record.
|
|
112
|
+
*
|
|
113
|
+
* @throws Error when `input` fails {@link isConsentReceiptInput} (including a body that
|
|
114
|
+
* carries an `ip`/`ipCoarse` field — the server owns IP derivation).
|
|
115
|
+
*
|
|
116
|
+
* @since 1.0.0-canary.7
|
|
117
|
+
*/
|
|
118
|
+
export async function recordConsentReceiptFromRequest(
|
|
119
|
+
options: RecordConsentReceiptFromRequestOptions,
|
|
120
|
+
): Promise<ConsentReceiptAck> {
|
|
121
|
+
setResponseHeader("cache-control", "no-store");
|
|
122
|
+
|
|
123
|
+
if (!isConsentReceiptInput(options.input)) {
|
|
124
|
+
throw new Error("Invalid consent receipt input");
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// getRequestIP reads the platform/socket IP, trusting X-Forwarded-For's first hop — safe
|
|
128
|
+
// behind the CDN/proxy this app deploys to, and the maintained path over hand-parsing headers.
|
|
129
|
+
const rawIp = getRequestIP({ xForwardedFor: true });
|
|
130
|
+
const receipt = buildConsentReceipt({ input: options.input, rawIp, sign: options.sign });
|
|
131
|
+
|
|
132
|
+
await options.store.append(receipt);
|
|
133
|
+
|
|
134
|
+
return { receiptId: receipt.receiptId, timestamp: receipt.timestamp };
|
|
135
|
+
}
|