@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 @@
|
|
|
1
|
+
{"version":3,"file":"consent-receipt-store.d.ts","sourceRoot":"","sources":["../../src/server/consent-receipt-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC1D,GAAG,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,cAAc,GAAG,SAAS,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAAC;CAC9F;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,0BAA0B,IAAI,YAAY,CAazD;AAED;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAAC;IAChE;;;;;;OAMG;IACH,GAAG,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACpE;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE;IAAE,OAAO,EAAE,mBAAmB,CAAA;CAAE,GAAG,YAAY,CASjG"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An in-memory {@link ReceiptStore} for development and tests — **not** durable across a
|
|
3
|
+
* process restart, and not a lawful production store on its own. A real deployment supplies
|
|
4
|
+
* a database-backed implementation; this exists so the endpoint is runnable end-to-end
|
|
5
|
+
* without standing up storage first.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Append is idempotent-by-id: re-appending the same `receiptId` is ignored, preserving the
|
|
9
|
+
* append-only guarantee even if a client retries.
|
|
10
|
+
*
|
|
11
|
+
* @since 1.0.0-canary.7
|
|
12
|
+
*/
|
|
13
|
+
export function createInMemoryReceiptStore() {
|
|
14
|
+
const receipts = new Map();
|
|
15
|
+
return {
|
|
16
|
+
append(receipt) {
|
|
17
|
+
if (!receipts.has(receipt.receiptId)) {
|
|
18
|
+
receipts.set(receipt.receiptId, receipt);
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
get(receiptId) {
|
|
22
|
+
return receipts.get(receiptId);
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A durable {@link ReceiptStore} over an injected {@link ReceiptStoreBackend} — the package
|
|
28
|
+
* supplies the append-only contract and adaptation, the deployment supplies the backend
|
|
29
|
+
* client (no database dependency is baked in). Pair it with a real backend in production,
|
|
30
|
+
* where {@link createInMemoryReceiptStore} is not a lawful store on its own.
|
|
31
|
+
*
|
|
32
|
+
* @since 1.0.0-canary.7
|
|
33
|
+
*/
|
|
34
|
+
export function createDurableReceiptStore(options) {
|
|
35
|
+
return {
|
|
36
|
+
async append(receipt) {
|
|
37
|
+
await options.backend.put(receipt.receiptId, receipt);
|
|
38
|
+
},
|
|
39
|
+
async get(receiptId) {
|
|
40
|
+
return options.backend.get(receiptId);
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=consent-receipt-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consent-receipt-store.js","sourceRoot":"","sources":["../../src/server/consent-receipt-store.ts"],"names":[],"mappings":"AAeA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,0BAA0B;IACxC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA0B,CAAC;IAEnD,OAAO;QACL,MAAM,CAAC,OAAuB;YAC5B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;gBACrC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;QACD,GAAG,CAAC,SAAiB;YACnB,OAAO,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACjC,CAAC;KACF,CAAC;AACJ,CAAC;AAqBD;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CAAC,OAAyC;IACjF,OAAO;QACL,KAAK,CAAC,MAAM,CAAC,OAAuB;YAClC,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACxD,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,SAAiB;YACzB,OAAO,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACxC,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ConsentReceipt, ConsentReceiptInput } from "#/core/consent-receipt";
|
|
2
|
+
/**
|
|
3
|
+
* The receipt information-structure version this builder emits (ISO/IEC TS 27560-shaped).
|
|
4
|
+
* Bump when the receipt field set changes; stored receipts carry it so a reader can migrate.
|
|
5
|
+
*
|
|
6
|
+
* @since 1.0.0-canary.7
|
|
7
|
+
*/
|
|
8
|
+
export declare const RECEIPT_SCHEMA_VERSION = "1.0.0";
|
|
9
|
+
/**
|
|
10
|
+
* Coarsens an IP for storage — a full address MUST never be persisted (spec-consent-receipts
|
|
11
|
+
* §4, R5). IPv4 drops the last two octets; IPv6 keeps only the first two hextets. This mirrors
|
|
12
|
+
* the Cookiebot-style anonymization cited in the spec and is the maximally-private default;
|
|
13
|
+
* a controller may widen it under counsel, but the builder never returns a full address.
|
|
14
|
+
* Returns `undefined` for a missing or malformed input rather than storing a bad value.
|
|
15
|
+
*
|
|
16
|
+
* @since 1.0.0-canary.7
|
|
17
|
+
*/
|
|
18
|
+
export declare function coarsenIp(ip: string | null | undefined): string | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* @remarks
|
|
21
|
+
* `sign` is optional so the package never bakes a crypto secret: supply an HMAC/signature
|
|
22
|
+
* function to stamp an `integrityKey`, letting a client prove its state matches the stored
|
|
23
|
+
* original (spec-consent-receipts §5). Omit it and receipts carry no integrity key.
|
|
24
|
+
*
|
|
25
|
+
* @since 1.0.0-canary.7
|
|
26
|
+
*/
|
|
27
|
+
export interface BuildConsentReceiptOptions {
|
|
28
|
+
input: ConsentReceiptInput;
|
|
29
|
+
/** The connection IP, read server-side — never accepted from the request body. */
|
|
30
|
+
rawIp?: string | null | undefined;
|
|
31
|
+
sign?: ((receipt: Omit<ConsentReceipt, "integrityKey">) => string) | undefined;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Builds a stored consent receipt from caller input plus server-derived fields
|
|
35
|
+
* (`receiptId`, `timestamp`, coarsened IP, optional `integrityKey`). Pure except for the
|
|
36
|
+
* id/clock it stamps — pass those in via a seam if a deterministic build is needed.
|
|
37
|
+
*
|
|
38
|
+
* @since 1.0.0-canary.7
|
|
39
|
+
*/
|
|
40
|
+
export declare function buildConsentReceipt(options: BuildConsentReceiptOptions): ConsentReceipt;
|
|
41
|
+
//# sourceMappingURL=consent-receipt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consent-receipt.d.ts","sourceRoot":"","sources":["../../src/server/consent-receipt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAElF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,UAAU,CAAC;AAI9C;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CA+B3E;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,mBAAmB,CAAC;IAC3B,kFAAkF;IAClF,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAClC,IAAI,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,cAAc,CAAC,KAAK,MAAM,CAAC,GAAG,SAAS,CAAC;CAChF;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,cAAc,CAYvF"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The receipt information-structure version this builder emits (ISO/IEC TS 27560-shaped).
|
|
3
|
+
* Bump when the receipt field set changes; stored receipts carry it so a reader can migrate.
|
|
4
|
+
*
|
|
5
|
+
* @since 1.0.0-canary.7
|
|
6
|
+
*/
|
|
7
|
+
export const RECEIPT_SCHEMA_VERSION = "1.0.0";
|
|
8
|
+
const IPV4_PATTERN = /^(\d{1,3}\.){3}\d{1,3}$/;
|
|
9
|
+
/**
|
|
10
|
+
* Coarsens an IP for storage — a full address MUST never be persisted (spec-consent-receipts
|
|
11
|
+
* §4, R5). IPv4 drops the last two octets; IPv6 keeps only the first two hextets. This mirrors
|
|
12
|
+
* the Cookiebot-style anonymization cited in the spec and is the maximally-private default;
|
|
13
|
+
* a controller may widen it under counsel, but the builder never returns a full address.
|
|
14
|
+
* Returns `undefined` for a missing or malformed input rather than storing a bad value.
|
|
15
|
+
*
|
|
16
|
+
* @since 1.0.0-canary.7
|
|
17
|
+
*/
|
|
18
|
+
export function coarsenIp(ip) {
|
|
19
|
+
if (!ip) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
const trimmed = ip.trim();
|
|
23
|
+
if (IPV4_PATTERN.test(trimmed)) {
|
|
24
|
+
const octets = trimmed.split(".");
|
|
25
|
+
// Reject out-of-range octets (e.g. "999.1.1.1") rather than storing a malformed coarse value.
|
|
26
|
+
if (octets.some((octet) => Number(octet) > 255)) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
return `${octets[0]}.${octets[1]}.0.0`;
|
|
30
|
+
}
|
|
31
|
+
if (trimmed.includes(":")) {
|
|
32
|
+
const [first, second] = trimmed.split(":");
|
|
33
|
+
// Require two explicit leading hextets — a compressed-leading address ("::1", "fe80::1")
|
|
34
|
+
// can't be coarsened without full expansion, so degrade to no stored value.
|
|
35
|
+
if (!first || !second) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
return `${first}:${second}::`;
|
|
39
|
+
}
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Builds a stored consent receipt from caller input plus server-derived fields
|
|
44
|
+
* (`receiptId`, `timestamp`, coarsened IP, optional `integrityKey`). Pure except for the
|
|
45
|
+
* id/clock it stamps — pass those in via a seam if a deterministic build is needed.
|
|
46
|
+
*
|
|
47
|
+
* @since 1.0.0-canary.7
|
|
48
|
+
*/
|
|
49
|
+
export function buildConsentReceipt(options) {
|
|
50
|
+
const base = {
|
|
51
|
+
...options.input,
|
|
52
|
+
ipCoarse: coarsenIp(options.rawIp),
|
|
53
|
+
receiptId: crypto.randomUUID(),
|
|
54
|
+
schemaVersion: RECEIPT_SCHEMA_VERSION,
|
|
55
|
+
timestamp: Date.now(),
|
|
56
|
+
};
|
|
57
|
+
const integrityKey = options.sign?.(base);
|
|
58
|
+
return integrityKey === undefined ? base : { ...base, integrityKey };
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=consent-receipt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consent-receipt.js","sourceRoot":"","sources":["../../src/server/consent-receipt.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,OAAO,CAAC;AAE9C,MAAM,YAAY,GAAG,yBAAyB,CAAC;AAE/C;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CAAC,EAA6B;IACrD,IAAI,CAAC,EAAE,EAAE,CAAC;QACR,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,OAAO,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;IAE1B,IAAI,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/B,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAElC,8FAA8F;QAC9F,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC;YAChD,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;IACzC,CAAC;IAED,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1B,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAE3C,yFAAyF;QACzF,4EAA4E;QAC5E,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC;YACtB,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,OAAO,GAAG,KAAK,IAAI,MAAM,IAAI,CAAC;IAChC,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAiBD;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAmC;IACrE,MAAM,IAAI,GAAyC;QACjD,GAAG,OAAO,CAAC,KAAK;QAChB,QAAQ,EAAE,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC;QAClC,SAAS,EAAE,MAAM,CAAC,UAAU,EAAE;QAC9B,aAAa,EAAE,sBAAsB;QACrC,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;KACtB,CAAC;IAEF,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC;IAE1C,OAAO,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,YAAY,EAAE,CAAC;AACvE,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ConsentCategory, InitialConsent } from "#/core/consent";
|
|
2
|
+
/**
|
|
3
|
+
* @since 1.0.0-canary.6
|
|
4
|
+
*/
|
|
5
|
+
export interface InitialConsentOptions {
|
|
6
|
+
/** ISO 3166-1 alpha-2 from the geo header; missing → the strictest opt-in default. */
|
|
7
|
+
countryCode: string | undefined;
|
|
8
|
+
/** Honored as an ads-only opt-out on the default decision. */
|
|
9
|
+
hasGlobalPrivacyControlSignal?: boolean | undefined;
|
|
10
|
+
/** Categories the app's prompt asks about — opt-out regions grant exactly these by default. */
|
|
11
|
+
requestedCategories: ReadonlyArray<ConsentCategory>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Pure region → mode → default-consent resolution for server functions (or a fail-closed
|
|
15
|
+
* bake when country is unknown). Named with the `resolve*` family it composes.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* A missing country code means an unknown visitor (a prerender crawl, a host without a
|
|
19
|
+
* geo header) — not a known non-EU visitor — so it fails closed to
|
|
20
|
+
* {@link STRICTEST_INITIAL_CONSENT} instead of `"other"`'s opt-out. Conflating the two
|
|
21
|
+
* would grant analytics by default to every visitor, EU included, on a geo-less host.
|
|
22
|
+
*
|
|
23
|
+
* @since 1.0.0-canary.6
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolveInitialConsent(options: InitialConsentOptions): InitialConsent;
|
|
26
|
+
//# sourceMappingURL=initial-consent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initial-consent.d.ts","sourceRoot":"","sources":["../../src/server/initial-consent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAItE;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,sFAAsF;IACtF,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,8DAA8D;IAC9D,6BAA6B,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACpD,+FAA+F;IAC/F,mBAAmB,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;CACrD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,qBAAqB,GAAG,cAAc,CAiBpF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { resolveConsentMode, resolveDefaultConsent, STRICTEST_INITIAL_CONSENT } from "#/core/consent";
|
|
2
|
+
import { resolveRegionFromCountryCode } from "#/server/region";
|
|
3
|
+
/**
|
|
4
|
+
* Pure region → mode → default-consent resolution for server functions (or a fail-closed
|
|
5
|
+
* bake when country is unknown). Named with the `resolve*` family it composes.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* A missing country code means an unknown visitor (a prerender crawl, a host without a
|
|
9
|
+
* geo header) — not a known non-EU visitor — so it fails closed to
|
|
10
|
+
* {@link STRICTEST_INITIAL_CONSENT} instead of `"other"`'s opt-out. Conflating the two
|
|
11
|
+
* would grant analytics by default to every visitor, EU included, on a geo-less host.
|
|
12
|
+
*
|
|
13
|
+
* @since 1.0.0-canary.6
|
|
14
|
+
*/
|
|
15
|
+
export function resolveInitialConsent(options) {
|
|
16
|
+
if (!options.countryCode) {
|
|
17
|
+
return STRICTEST_INITIAL_CONSENT;
|
|
18
|
+
}
|
|
19
|
+
const region = resolveRegionFromCountryCode(options.countryCode);
|
|
20
|
+
const mode = resolveConsentMode(region);
|
|
21
|
+
return {
|
|
22
|
+
defaultConsent: resolveDefaultConsent({
|
|
23
|
+
hasGlobalPrivacyControlSignal: options.hasGlobalPrivacyControlSignal ?? false,
|
|
24
|
+
mode,
|
|
25
|
+
requestedCategories: options.requestedCategories,
|
|
26
|
+
}),
|
|
27
|
+
mode,
|
|
28
|
+
region,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=initial-consent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initial-consent.js","sourceRoot":"","sources":["../../src/server/initial-consent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AACtG,OAAO,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAc/D;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAA8B;IAClE,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QACzB,OAAO,yBAAyB,CAAC;IACnC,CAAC;IAED,MAAM,MAAM,GAAG,4BAA4B,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACjE,MAAM,IAAI,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAExC,OAAO;QACL,cAAc,EAAE,qBAAqB,CAAC;YACpC,6BAA6B,EAAE,OAAO,CAAC,6BAA6B,IAAI,KAAK;YAC7E,IAAI;YACJ,mBAAmB,EAAE,OAAO,CAAC,mBAAmB;SACjD,CAAC;QACF,IAAI;QACJ,MAAM;KACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { ConsentDecision } from "#/core/consent";
|
|
2
|
+
/**
|
|
3
|
+
* A GA4 event for the Measurement Protocol. `params` are flat scalars — GA4 rejects nested values and booleans.
|
|
4
|
+
*
|
|
5
|
+
* @since 1.0.0-canary.7
|
|
6
|
+
*/
|
|
7
|
+
export interface MeasurementProtocolEvent {
|
|
8
|
+
name: string;
|
|
9
|
+
params?: Record<string, number | string> | undefined;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The GA4 MP `consent` object — the two ad-consent signals the payload accepts.
|
|
13
|
+
*
|
|
14
|
+
* @since 1.0.0-canary.7
|
|
15
|
+
*/
|
|
16
|
+
export interface MeasurementProtocolConsent {
|
|
17
|
+
ad_personalization: "DENIED" | "GRANTED";
|
|
18
|
+
ad_user_data: "DENIED" | "GRANTED";
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Maps the package `ConsentDecision` to GA4 MP consent signals — `ads` drives both ad fields.
|
|
22
|
+
*
|
|
23
|
+
* @since 1.0.0-canary.7
|
|
24
|
+
*/
|
|
25
|
+
export declare function toMeasurementProtocolConsent(decision: ConsentDecision): MeasurementProtocolConsent;
|
|
26
|
+
/**
|
|
27
|
+
* Extracts the GA4 `client_id` from a `_ga` cookie value, e.g.
|
|
28
|
+
* `GA1.1.1809596761.1693829043` → `1809596761.1693829043` (everything past the
|
|
29
|
+
* `GA1.<version>.` prefix). The `_ga` layout is community-established, not part of the
|
|
30
|
+
* Measurement Protocol reference, so anything that doesn't parse returns `undefined` rather
|
|
31
|
+
* than sending a malformed id.
|
|
32
|
+
*
|
|
33
|
+
* @since 1.0.0-canary.7
|
|
34
|
+
*/
|
|
35
|
+
export declare function extractGaClientId(gaCookieValue: string | undefined): string | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* The one network primitive the sender needs — injected so the package ships no HTTP client.
|
|
38
|
+
*
|
|
39
|
+
* @since 1.0.0-canary.7
|
|
40
|
+
*/
|
|
41
|
+
export type MeasurementProtocolTransport = (request: {
|
|
42
|
+
body: string;
|
|
43
|
+
url: string;
|
|
44
|
+
}) => Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* @since 1.0.0-canary.7
|
|
47
|
+
*/
|
|
48
|
+
export interface SendMeasurementProtocolEventsOptions {
|
|
49
|
+
/** GA4 **API Secret** — read server-side from config, never a client-exposed var. */
|
|
50
|
+
apiSecret: string;
|
|
51
|
+
/** The visitor's GA4 client id (see {@link extractGaClientId}). */
|
|
52
|
+
clientId: string;
|
|
53
|
+
consent?: MeasurementProtocolConsent | undefined;
|
|
54
|
+
endpointOrigin?: string | undefined;
|
|
55
|
+
events: ReadonlyArray<MeasurementProtocolEvent>;
|
|
56
|
+
measurementId: string;
|
|
57
|
+
transport?: MeasurementProtocolTransport | undefined;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* POSTs one or more events to the GA4 Measurement Protocol for a known `client_id` — the
|
|
61
|
+
* server-side counterpart to gtag.js. The caller owns credentials (never bake them) and the
|
|
62
|
+
* consent gate: send only for a server-owned event the visitor's consent permits.
|
|
63
|
+
*
|
|
64
|
+
* @see https://developers.google.com/analytics/devguides/collection/protocol/ga4/sending-events
|
|
65
|
+
*
|
|
66
|
+
* @since 1.0.0-canary.7
|
|
67
|
+
*/
|
|
68
|
+
export declare function sendMeasurementProtocolEvents(options: SendMeasurementProtocolEventsOptions): Promise<void>;
|
|
69
|
+
//# sourceMappingURL=measurement-protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"measurement-protocol.d.ts","sourceRoot":"","sources":["../../src/server/measurement-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG,SAAS,CAAC;CACtD;AAED;;;;GAIG;AACH,MAAM,WAAW,0BAA0B;IACzC,kBAAkB,EAAE,QAAQ,GAAG,SAAS,CAAC;IACzC,YAAY,EAAE,QAAQ,GAAG,SAAS,CAAC;CACpC;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,eAAe,GAAG,0BAA0B,CAIlG;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAYvF;AAED;;;;GAIG;AACH,MAAM,MAAM,4BAA4B,GAAG,CAAC,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAkBrG;;GAEG;AACH,MAAM,WAAW,oCAAoC;IACnD,qFAAqF;IACrF,SAAS,EAAE,MAAM,CAAC;IAClB,mEAAmE;IACnE,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,0BAA0B,GAAG,SAAS,CAAC;IACjD,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,MAAM,EAAE,aAAa,CAAC,wBAAwB,CAAC,CAAC;IAChD,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,4BAA4B,GAAG,SAAS,CAAC;CACtD;AAED;;;;;;;;GAQG;AACH,wBAAsB,6BAA6B,CAAC,OAAO,EAAE,oCAAoC,GAAG,OAAO,CAAC,IAAI,CAAC,CAUhH"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps the package `ConsentDecision` to GA4 MP consent signals — `ads` drives both ad fields.
|
|
3
|
+
*
|
|
4
|
+
* @since 1.0.0-canary.7
|
|
5
|
+
*/
|
|
6
|
+
export function toMeasurementProtocolConsent(decision) {
|
|
7
|
+
const state = decision.ads ? "GRANTED" : "DENIED";
|
|
8
|
+
return { ad_personalization: state, ad_user_data: state };
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Extracts the GA4 `client_id` from a `_ga` cookie value, e.g.
|
|
12
|
+
* `GA1.1.1809596761.1693829043` → `1809596761.1693829043` (everything past the
|
|
13
|
+
* `GA1.<version>.` prefix). The `_ga` layout is community-established, not part of the
|
|
14
|
+
* Measurement Protocol reference, so anything that doesn't parse returns `undefined` rather
|
|
15
|
+
* than sending a malformed id.
|
|
16
|
+
*
|
|
17
|
+
* @since 1.0.0-canary.7
|
|
18
|
+
*/
|
|
19
|
+
export function extractGaClientId(gaCookieValue) {
|
|
20
|
+
if (!gaCookieValue) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
const segments = gaCookieValue.split(".");
|
|
24
|
+
if (segments.length < 4 || segments[0] !== "GA1") {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
return segments.slice(2).join(".");
|
|
28
|
+
}
|
|
29
|
+
/** Default GA4 collection origin; use `https://region1.google-analytics.com` for EU data residency. */
|
|
30
|
+
const DEFAULT_ENDPOINT_ORIGIN = "https://www.google-analytics.com";
|
|
31
|
+
async function defaultTransport(request) {
|
|
32
|
+
const response = await fetch(request.url, {
|
|
33
|
+
body: request.body,
|
|
34
|
+
headers: { "content-type": "application/json" },
|
|
35
|
+
method: "POST",
|
|
36
|
+
});
|
|
37
|
+
// MP returns 2xx with no useful body; a non-2xx is a config error worth surfacing.
|
|
38
|
+
if (!response.ok) {
|
|
39
|
+
throw new Error(`Measurement Protocol responded ${String(response.status)}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* POSTs one or more events to the GA4 Measurement Protocol for a known `client_id` — the
|
|
44
|
+
* server-side counterpart to gtag.js. The caller owns credentials (never bake them) and the
|
|
45
|
+
* consent gate: send only for a server-owned event the visitor's consent permits.
|
|
46
|
+
*
|
|
47
|
+
* @see https://developers.google.com/analytics/devguides/collection/protocol/ga4/sending-events
|
|
48
|
+
*
|
|
49
|
+
* @since 1.0.0-canary.7
|
|
50
|
+
*/
|
|
51
|
+
export async function sendMeasurementProtocolEvents(options) {
|
|
52
|
+
const origin = options.endpointOrigin ?? DEFAULT_ENDPOINT_ORIGIN;
|
|
53
|
+
const url = `${origin}/mp/collect?measurement_id=${encodeURIComponent(options.measurementId)}&api_secret=${encodeURIComponent(options.apiSecret)}`;
|
|
54
|
+
const body = JSON.stringify({
|
|
55
|
+
client_id: options.clientId,
|
|
56
|
+
events: options.events,
|
|
57
|
+
...(options.consent ? { consent: options.consent } : {}),
|
|
58
|
+
});
|
|
59
|
+
await (options.transport ?? defaultTransport)({ body, url });
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=measurement-protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"measurement-protocol.js","sourceRoot":"","sources":["../../src/server/measurement-protocol.ts"],"names":[],"mappings":"AAsBA;;;;GAIG;AACH,MAAM,UAAU,4BAA4B,CAAC,QAAyB;IACpE,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC;IAElD,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;AAC5D,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,aAAiC;IACjE,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,QAAQ,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE1C,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE,CAAC;QACjD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACrC,CAAC;AASD,uGAAuG;AACvG,MAAM,uBAAuB,GAAG,kCAAkC,CAAC;AAEnE,KAAK,UAAU,gBAAgB,CAAC,OAAsC;IACpE,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACxC,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;QAC/C,MAAM,EAAE,MAAM;KACf,CAAC,CAAC;IAEH,mFAAmF;IACnF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,kCAAkC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC/E,CAAC;AACH,CAAC;AAiBD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,6BAA6B,CAAC,OAA6C;IAC/F,MAAM,MAAM,GAAG,OAAO,CAAC,cAAc,IAAI,uBAAuB,CAAC;IACjE,MAAM,GAAG,GAAG,GAAG,MAAM,8BAA8B,kBAAkB,CAAC,OAAO,CAAC,aAAa,CAAC,eAAe,kBAAkB,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;IACnJ,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC;QAC1B,SAAS,EAAE,OAAO,CAAC,QAAQ;QAC3B,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACzD,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,SAAS,IAAI,gBAAgB,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ConsentRegion } from "#/core/consent";
|
|
2
|
+
/**
|
|
3
|
+
* EU member states — GDPR opt-in via `resolveConsentMode("eu")`.
|
|
4
|
+
*
|
|
5
|
+
* @since 1.0.0-canary.6
|
|
6
|
+
*/
|
|
7
|
+
export declare const EU_COUNTRY_CODES: ReadonlySet<string>;
|
|
8
|
+
/**
|
|
9
|
+
* UK GDPR (post-Brexit) and EEA/EFTA states that apply GDPR-equivalent rules — mapped to
|
|
10
|
+
* the same `"eu"` consent region so they get opt-in, not the `"other"` opt-out default.
|
|
11
|
+
*
|
|
12
|
+
* Restricted edge runtimes that cannot import this package should duplicate these codes
|
|
13
|
+
* and keep a sync test against this export.
|
|
14
|
+
*
|
|
15
|
+
* @since 1.0.0-canary.6
|
|
16
|
+
*/
|
|
17
|
+
export declare const OPT_IN_EQUIVALENT_COUNTRY_CODES: ReadonlySet<string>;
|
|
18
|
+
/**
|
|
19
|
+
* Unrecognized codes fall back to "other", which `resolveConsentMode` treats as
|
|
20
|
+
* opt-out — safe only because opt-in regions (EU/VN plus UK/EEA/EFTA above) are matched
|
|
21
|
+
* explicitly. A *missing* code also maps to "other" here, but `resolveInitialConsent`
|
|
22
|
+
* intercepts that case first and fails closed — unknown is not known-elsewhere.
|
|
23
|
+
*
|
|
24
|
+
* @since 0.5.0-canary.4
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveRegionFromCountryCode(countryCode: string | undefined): ConsentRegion;
|
|
27
|
+
//# sourceMappingURL=region.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"region.d.ts","sourceRoot":"","sources":["../../src/server/region.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,MAAM,CA4B/C,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,+BAA+B,EAAE,WAAW,CAAC,MAAM,CAAqC,CAAC;AAEtG;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa,CAoB3F"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EU member states — GDPR opt-in via `resolveConsentMode("eu")`.
|
|
3
|
+
*
|
|
4
|
+
* @since 1.0.0-canary.6
|
|
5
|
+
*/
|
|
6
|
+
export const EU_COUNTRY_CODES = new Set([
|
|
7
|
+
"AT",
|
|
8
|
+
"BE",
|
|
9
|
+
"BG",
|
|
10
|
+
"HR",
|
|
11
|
+
"CY",
|
|
12
|
+
"CZ",
|
|
13
|
+
"DK",
|
|
14
|
+
"EE",
|
|
15
|
+
"FI",
|
|
16
|
+
"FR",
|
|
17
|
+
"DE",
|
|
18
|
+
"GR",
|
|
19
|
+
"HU",
|
|
20
|
+
"IE",
|
|
21
|
+
"IT",
|
|
22
|
+
"LV",
|
|
23
|
+
"LT",
|
|
24
|
+
"LU",
|
|
25
|
+
"MT",
|
|
26
|
+
"NL",
|
|
27
|
+
"PL",
|
|
28
|
+
"PT",
|
|
29
|
+
"RO",
|
|
30
|
+
"SK",
|
|
31
|
+
"SI",
|
|
32
|
+
"ES",
|
|
33
|
+
"SE",
|
|
34
|
+
]);
|
|
35
|
+
/**
|
|
36
|
+
* UK GDPR (post-Brexit) and EEA/EFTA states that apply GDPR-equivalent rules — mapped to
|
|
37
|
+
* the same `"eu"` consent region so they get opt-in, not the `"other"` opt-out default.
|
|
38
|
+
*
|
|
39
|
+
* Restricted edge runtimes that cannot import this package should duplicate these codes
|
|
40
|
+
* and keep a sync test against this export.
|
|
41
|
+
*
|
|
42
|
+
* @since 1.0.0-canary.6
|
|
43
|
+
*/
|
|
44
|
+
export const OPT_IN_EQUIVALENT_COUNTRY_CODES = new Set(["GB", "IS", "LI", "NO"]);
|
|
45
|
+
/**
|
|
46
|
+
* Unrecognized codes fall back to "other", which `resolveConsentMode` treats as
|
|
47
|
+
* opt-out — safe only because opt-in regions (EU/VN plus UK/EEA/EFTA above) are matched
|
|
48
|
+
* explicitly. A *missing* code also maps to "other" here, but `resolveInitialConsent`
|
|
49
|
+
* intercepts that case first and fails closed — unknown is not known-elsewhere.
|
|
50
|
+
*
|
|
51
|
+
* @since 0.5.0-canary.4
|
|
52
|
+
*/
|
|
53
|
+
export function resolveRegionFromCountryCode(countryCode) {
|
|
54
|
+
if (!countryCode) {
|
|
55
|
+
return "other";
|
|
56
|
+
}
|
|
57
|
+
const normalized = countryCode.toUpperCase();
|
|
58
|
+
if (EU_COUNTRY_CODES.has(normalized) || OPT_IN_EQUIVALENT_COUNTRY_CODES.has(normalized)) {
|
|
59
|
+
return "eu";
|
|
60
|
+
}
|
|
61
|
+
if (normalized === "VN") {
|
|
62
|
+
return "vn";
|
|
63
|
+
}
|
|
64
|
+
if (normalized === "US") {
|
|
65
|
+
return "us";
|
|
66
|
+
}
|
|
67
|
+
return "other";
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=region.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"region.js","sourceRoot":"","sources":["../../src/server/region.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAwB,IAAI,GAAG,CAAC;IAC3D,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;CACL,CAAC,CAAC;AAEH;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAwB,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAEtG;;;;;;;GAOG;AACH,MAAM,UAAU,4BAA4B,CAAC,WAA+B;IAC1E,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,UAAU,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC;IAE7C,IAAI,gBAAgB,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,+BAA+B,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;QACxF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DSR delegation for GA4 (spec-data-subject-rights §3): the platform ships its own
|
|
3
|
+
* per-visitor deletion, so the system **delegates** rather than reimplementing a deletion
|
|
4
|
+
* store. Targets the current **Analytics Admin API** `properties.submitUserDeletion` — the
|
|
5
|
+
* legacy v3 `userDeletionRequests:upsert` was sunset with Universal Analytics, so the spec's
|
|
6
|
+
* DSR-V3 `{ id: { type: "CLIENT_ID", userId } }` shape is stale; the current request keys the
|
|
7
|
+
* subject with a flat `clientId` (a oneof with `userId`/`appInstanceId`/`userProvidedData`).
|
|
8
|
+
*
|
|
9
|
+
* @see https://developers.google.com/analytics/devguides/config/userdeletion/migration
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* @since 1.0.0-canary.7
|
|
13
|
+
*/
|
|
14
|
+
export interface Ga4UserDeletionRequest {
|
|
15
|
+
body: {
|
|
16
|
+
clientId: string;
|
|
17
|
+
};
|
|
18
|
+
url: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Builds the Admin API `submitUserDeletion` request that erases one GA4 subject by
|
|
22
|
+
* `clientId` (the `_ga`-cookie id — see `extractGaClientId`). Pure and network-free so the
|
|
23
|
+
* request shape can be snapshotted/verified; pair it with {@link submitGa4UserDeletion} or
|
|
24
|
+
* any authenticated transport.
|
|
25
|
+
*
|
|
26
|
+
* @param options - `propertyId` is the numeric GA4 property (no `properties/` prefix).
|
|
27
|
+
*
|
|
28
|
+
* @since 1.0.0-canary.7
|
|
29
|
+
*/
|
|
30
|
+
export declare function buildGa4UserDeletionRequest(options: {
|
|
31
|
+
clientId: string;
|
|
32
|
+
propertyId: string;
|
|
33
|
+
}): Ga4UserDeletionRequest;
|
|
34
|
+
/**
|
|
35
|
+
* The one network primitive the sender needs — injected so the package ships no HTTP client.
|
|
36
|
+
*
|
|
37
|
+
* @since 1.0.0-canary.7
|
|
38
|
+
*/
|
|
39
|
+
export type Ga4UserDeletionTransport = (request: {
|
|
40
|
+
body: string;
|
|
41
|
+
headers: Record<string, string>;
|
|
42
|
+
url: string;
|
|
43
|
+
}) => Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* @since 1.0.0-canary.7
|
|
46
|
+
*/
|
|
47
|
+
export interface SubmitGa4UserDeletionOptions {
|
|
48
|
+
/** A bearer token for the `https://www.googleapis.com/auth/analytics.edit` scope — the caller owns OAuth. */
|
|
49
|
+
accessToken: string;
|
|
50
|
+
clientId: string;
|
|
51
|
+
propertyId: string;
|
|
52
|
+
transport?: Ga4UserDeletionTransport | undefined;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Submits a GA4 user-deletion request for one `clientId`. Authorization is the caller's:
|
|
56
|
+
* pass a bearer token minted from a service account (never baked into the package). The
|
|
57
|
+
* deletion removes the subject from the Individual User report within ~72h and purges at the
|
|
58
|
+
* next run; it does **not** reach previously-aggregated reports or BigQuery exports
|
|
59
|
+
* (spec-data-subject-rights §3).
|
|
60
|
+
*
|
|
61
|
+
* @since 1.0.0-canary.7
|
|
62
|
+
*/
|
|
63
|
+
export declare function submitGa4UserDeletion(options: SubmitGa4UserDeletionOptions): Promise<void>;
|
|
64
|
+
//# sourceMappingURL=user-deletion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-deletion.d.ts","sourceRoot":"","sources":["../../src/server/user-deletion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3B,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,sBAAsB,CAKrH;AAED;;;;GAIG;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,OAAO,EAAE;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,GAAG,EAAE,MAAM,CAAC;CACb,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAcpB;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,6GAA6G;IAC7G,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,wBAAwB,GAAG,SAAS,CAAC;CAClD;AAED;;;;;;;;GAQG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,4BAA4B,GAAG,OAAO,CAAC,IAAI,CAAC,CAWhG"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DSR delegation for GA4 (spec-data-subject-rights §3): the platform ships its own
|
|
3
|
+
* per-visitor deletion, so the system **delegates** rather than reimplementing a deletion
|
|
4
|
+
* store. Targets the current **Analytics Admin API** `properties.submitUserDeletion` — the
|
|
5
|
+
* legacy v3 `userDeletionRequests:upsert` was sunset with Universal Analytics, so the spec's
|
|
6
|
+
* DSR-V3 `{ id: { type: "CLIENT_ID", userId } }` shape is stale; the current request keys the
|
|
7
|
+
* subject with a flat `clientId` (a oneof with `userId`/`appInstanceId`/`userProvidedData`).
|
|
8
|
+
*
|
|
9
|
+
* @see https://developers.google.com/analytics/devguides/config/userdeletion/migration
|
|
10
|
+
*/
|
|
11
|
+
const ADMIN_API_ORIGIN = "https://analyticsadmin.googleapis.com";
|
|
12
|
+
/**
|
|
13
|
+
* Builds the Admin API `submitUserDeletion` request that erases one GA4 subject by
|
|
14
|
+
* `clientId` (the `_ga`-cookie id — see `extractGaClientId`). Pure and network-free so the
|
|
15
|
+
* request shape can be snapshotted/verified; pair it with {@link submitGa4UserDeletion} or
|
|
16
|
+
* any authenticated transport.
|
|
17
|
+
*
|
|
18
|
+
* @param options - `propertyId` is the numeric GA4 property (no `properties/` prefix).
|
|
19
|
+
*
|
|
20
|
+
* @since 1.0.0-canary.7
|
|
21
|
+
*/
|
|
22
|
+
export function buildGa4UserDeletionRequest(options) {
|
|
23
|
+
return {
|
|
24
|
+
body: { clientId: options.clientId },
|
|
25
|
+
url: `${ADMIN_API_ORIGIN}/v1alpha/properties/${options.propertyId}:submitUserDeletion`,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
async function defaultTransport(request) {
|
|
29
|
+
const response = await fetch(request.url, { body: request.body, headers: request.headers, method: "POST" });
|
|
30
|
+
if (!response.ok) {
|
|
31
|
+
throw new Error(`GA4 user deletion responded ${String(response.status)}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Submits a GA4 user-deletion request for one `clientId`. Authorization is the caller's:
|
|
36
|
+
* pass a bearer token minted from a service account (never baked into the package). The
|
|
37
|
+
* deletion removes the subject from the Individual User report within ~72h and purges at the
|
|
38
|
+
* next run; it does **not** reach previously-aggregated reports or BigQuery exports
|
|
39
|
+
* (spec-data-subject-rights §3).
|
|
40
|
+
*
|
|
41
|
+
* @since 1.0.0-canary.7
|
|
42
|
+
*/
|
|
43
|
+
export async function submitGa4UserDeletion(options) {
|
|
44
|
+
const request = buildGa4UserDeletionRequest({ clientId: options.clientId, propertyId: options.propertyId });
|
|
45
|
+
await (options.transport ?? defaultTransport)({
|
|
46
|
+
body: JSON.stringify(request.body),
|
|
47
|
+
headers: {
|
|
48
|
+
authorization: `Bearer ${options.accessToken}`,
|
|
49
|
+
"content-type": "application/json",
|
|
50
|
+
},
|
|
51
|
+
url: request.url,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=user-deletion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-deletion.js","sourceRoot":"","sources":["../../src/server/user-deletion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,gBAAgB,GAAG,uCAAuC,CAAC;AAUjE;;;;;;;;;GASG;AACH,MAAM,UAAU,2BAA2B,CAAC,OAAiD;IAC3F,OAAO;QACL,IAAI,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE;QACpC,GAAG,EAAE,GAAG,gBAAgB,uBAAuB,OAAO,CAAC,UAAU,qBAAqB;KACvF,CAAC;AACJ,CAAC;AAaD,KAAK,UAAU,gBAAgB,CAAC,OAI/B;IACC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAE5G,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,+BAA+B,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC5E,CAAC;AACH,CAAC;AAaD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,OAAqC;IAC/E,MAAM,OAAO,GAAG,2BAA2B,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IAE5G,MAAM,CAAC,OAAO,CAAC,SAAS,IAAI,gBAAgB,CAAC,CAAC;QAC5C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;QAClC,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,OAAO,CAAC,WAAW,EAAE;YAC9C,cAAc,EAAE,kBAAkB;SACnC;QACD,GAAG,EAAE,OAAO,CAAC,GAAG;KACjB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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 declare const SERVER_ONLY_SUBPATHS: ReadonlyArray<string>;
|
|
19
|
+
//# sourceMappingURL=import-protection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-protection.d.ts","sourceRoot":"","sources":["../../src/tooling/import-protection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,oBAAoB,EAAE,aAAa,CAAC,MAAM,CAItD,CAAC"}
|