@feelflow/ffid-sdk 4.3.0 → 5.0.1

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.
@@ -838,7 +838,7 @@ function createProfileMethods(deps) {
838
838
  }
839
839
 
840
840
  // src/client/version-check.ts
841
- var SDK_VERSION = "4.3.0";
841
+ var SDK_VERSION = "5.0.1";
842
842
  var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
843
843
  var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
844
844
  function sdkHeaders() {
@@ -1,34 +1,34 @@
1
1
  'use strict';
2
2
 
3
- var chunk5MO7G2JW_cjs = require('../chunk-5MO7G2JW.cjs');
3
+ var chunk223MPEBU_cjs = require('../chunk-223MPEBU.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "FFIDAnnouncementBadge", {
8
8
  enumerable: true,
9
- get: function () { return chunk5MO7G2JW_cjs.FFIDAnnouncementBadge; }
9
+ get: function () { return chunk223MPEBU_cjs.FFIDAnnouncementBadge; }
10
10
  });
11
11
  Object.defineProperty(exports, "FFIDAnnouncementList", {
12
12
  enumerable: true,
13
- get: function () { return chunk5MO7G2JW_cjs.FFIDAnnouncementList; }
13
+ get: function () { return chunk223MPEBU_cjs.FFIDAnnouncementList; }
14
14
  });
15
15
  Object.defineProperty(exports, "FFIDInquiryForm", {
16
16
  enumerable: true,
17
- get: function () { return chunk5MO7G2JW_cjs.FFIDInquiryForm; }
17
+ get: function () { return chunk223MPEBU_cjs.FFIDInquiryForm; }
18
18
  });
19
19
  Object.defineProperty(exports, "FFIDLoginButton", {
20
20
  enumerable: true,
21
- get: function () { return chunk5MO7G2JW_cjs.FFIDLoginButton; }
21
+ get: function () { return chunk223MPEBU_cjs.FFIDLoginButton; }
22
22
  });
23
23
  Object.defineProperty(exports, "FFIDOrganizationSwitcher", {
24
24
  enumerable: true,
25
- get: function () { return chunk5MO7G2JW_cjs.FFIDOrganizationSwitcher; }
25
+ get: function () { return chunk223MPEBU_cjs.FFIDOrganizationSwitcher; }
26
26
  });
27
27
  Object.defineProperty(exports, "FFIDSubscriptionBadge", {
28
28
  enumerable: true,
29
- get: function () { return chunk5MO7G2JW_cjs.FFIDSubscriptionBadge; }
29
+ get: function () { return chunk223MPEBU_cjs.FFIDSubscriptionBadge; }
30
30
  });
31
31
  Object.defineProperty(exports, "FFIDUserMenu", {
32
32
  enumerable: true,
33
- get: function () { return chunk5MO7G2JW_cjs.FFIDUserMenu; }
33
+ get: function () { return chunk223MPEBU_cjs.FFIDUserMenu; }
34
34
  });
@@ -1 +1 @@
1
- export { FFIDAnnouncementBadge, FFIDAnnouncementList, FFIDInquiryForm, FFIDLoginButton, FFIDOrganizationSwitcher, FFIDSubscriptionBadge, FFIDUserMenu } from '../chunk-35UOD62N.js';
1
+ export { FFIDAnnouncementBadge, FFIDAnnouncementList, FFIDInquiryForm, FFIDLoginButton, FFIDOrganizationSwitcher, FFIDSubscriptionBadge, FFIDUserMenu } from '../chunk-YOJJ433H.js';
@@ -0,0 +1,242 @@
1
+ 'use strict';
2
+
3
+ var chunkIIC2LBD2_cjs = require('../chunk-IIC2LBD2.cjs');
4
+
5
+
6
+
7
+ Object.defineProperty(exports, "ALL_DENIED_EXCEPT_NECESSARY", {
8
+ enumerable: true,
9
+ get: function () { return chunkIIC2LBD2_cjs.ALL_DENIED_EXCEPT_NECESSARY; }
10
+ });
11
+ Object.defineProperty(exports, "CONSENT_COOKIE_MAX_AGE_SEC", {
12
+ enumerable: true,
13
+ get: function () { return chunkIIC2LBD2_cjs.CONSENT_COOKIE_MAX_AGE_SEC; }
14
+ });
15
+ Object.defineProperty(exports, "CONSENT_COOKIE_NAME", {
16
+ enumerable: true,
17
+ get: function () { return chunkIIC2LBD2_cjs.CONSENT_COOKIE_NAME; }
18
+ });
19
+ Object.defineProperty(exports, "CONSENT_SESSION_STORAGE_KEY", {
20
+ enumerable: true,
21
+ get: function () { return chunkIIC2LBD2_cjs.CONSENT_SESSION_STORAGE_KEY; }
22
+ });
23
+ Object.defineProperty(exports, "COOKIE_VERSION", {
24
+ enumerable: true,
25
+ get: function () { return chunkIIC2LBD2_cjs.COOKIE_VERSION; }
26
+ });
27
+ Object.defineProperty(exports, "DEFAULT_CONSENT_ERROR_MESSAGES", {
28
+ enumerable: true,
29
+ get: function () { return chunkIIC2LBD2_cjs.DEFAULT_CONSENT_ERROR_MESSAGES; }
30
+ });
31
+ Object.defineProperty(exports, "DEFAULT_MERGE_WARNING_MESSAGES", {
32
+ enumerable: true,
33
+ get: function () { return chunkIIC2LBD2_cjs.DEFAULT_MERGE_WARNING_MESSAGES; }
34
+ });
35
+ Object.defineProperty(exports, "DEVICE_ID_LOCAL_STORAGE_KEY", {
36
+ enumerable: true,
37
+ get: function () { return chunkIIC2LBD2_cjs.DEVICE_ID_LOCAL_STORAGE_KEY; }
38
+ });
39
+ Object.defineProperty(exports, "DEVICE_ID_SESSION_STORAGE_KEY", {
40
+ enumerable: true,
41
+ get: function () { return chunkIIC2LBD2_cjs.DEVICE_ID_SESSION_STORAGE_KEY; }
42
+ });
43
+ Object.defineProperty(exports, "DeviceIdSchema", {
44
+ enumerable: true,
45
+ get: function () { return chunkIIC2LBD2_cjs.DeviceIdSchema; }
46
+ });
47
+ Object.defineProperty(exports, "FFIDAnalyticsProvider", {
48
+ enumerable: true,
49
+ get: function () { return chunkIIC2LBD2_cjs.FFIDAnalyticsProvider; }
50
+ });
51
+ Object.defineProperty(exports, "FFIDConsentCategoriesSchema", {
52
+ enumerable: true,
53
+ get: function () { return chunkIIC2LBD2_cjs.FFIDConsentCategoriesSchema; }
54
+ });
55
+ Object.defineProperty(exports, "FFIDConsentCategoryCodeSchema", {
56
+ enumerable: true,
57
+ get: function () { return chunkIIC2LBD2_cjs.FFIDConsentCategoryCodeSchema; }
58
+ });
59
+ Object.defineProperty(exports, "FFIDConsentCategoryMetadataSchema", {
60
+ enumerable: true,
61
+ get: function () { return chunkIIC2LBD2_cjs.FFIDConsentCategoryMetadataSchema; }
62
+ });
63
+ Object.defineProperty(exports, "FFIDConsentContext", {
64
+ enumerable: true,
65
+ get: function () { return chunkIIC2LBD2_cjs.FFIDConsentContext; }
66
+ });
67
+ Object.defineProperty(exports, "FFIDConsentError", {
68
+ enumerable: true,
69
+ get: function () { return chunkIIC2LBD2_cjs.FFIDConsentError; }
70
+ });
71
+ Object.defineProperty(exports, "FFIDConsentMergeStrategySchema", {
72
+ enumerable: true,
73
+ get: function () { return chunkIIC2LBD2_cjs.FFIDConsentMergeStrategySchema; }
74
+ });
75
+ Object.defineProperty(exports, "FFIDConsentMergeWarningSchema", {
76
+ enumerable: true,
77
+ get: function () { return chunkIIC2LBD2_cjs.FFIDConsentMergeWarningSchema; }
78
+ });
79
+ Object.defineProperty(exports, "FFIDConsentSourceSchema", {
80
+ enumerable: true,
81
+ get: function () { return chunkIIC2LBD2_cjs.FFIDConsentSourceSchema; }
82
+ });
83
+ Object.defineProperty(exports, "FFIDConsentStateSchema", {
84
+ enumerable: true,
85
+ get: function () { return chunkIIC2LBD2_cjs.FFIDConsentStateSchema; }
86
+ });
87
+ Object.defineProperty(exports, "FFIDConsentUpdateSchema", {
88
+ enumerable: true,
89
+ get: function () { return chunkIIC2LBD2_cjs.FFIDConsentUpdateSchema; }
90
+ });
91
+ Object.defineProperty(exports, "FFIDCookieBanner", {
92
+ enumerable: true,
93
+ get: function () { return chunkIIC2LBD2_cjs.FFIDCookieBanner; }
94
+ });
95
+ Object.defineProperty(exports, "FFIDCookieLink", {
96
+ enumerable: true,
97
+ get: function () { return chunkIIC2LBD2_cjs.FFIDCookieLink; }
98
+ });
99
+ Object.defineProperty(exports, "FFIDCookiePolicySchema", {
100
+ enumerable: true,
101
+ get: function () { return chunkIIC2LBD2_cjs.FFIDCookiePolicySchema; }
102
+ });
103
+ Object.defineProperty(exports, "FFIDCookieSettings", {
104
+ enumerable: true,
105
+ get: function () { return chunkIIC2LBD2_cjs.FFIDCookieSettings; }
106
+ });
107
+ Object.defineProperty(exports, "FFIDInternalConsentSourceSchema", {
108
+ enumerable: true,
109
+ get: function () { return chunkIIC2LBD2_cjs.FFIDInternalConsentSourceSchema; }
110
+ });
111
+ Object.defineProperty(exports, "FFIDPublicConsentSourceSchema", {
112
+ enumerable: true,
113
+ get: function () { return chunkIIC2LBD2_cjs.FFIDPublicConsentSourceSchema; }
114
+ });
115
+ Object.defineProperty(exports, "FFID_CONSENT_ERROR_CODES", {
116
+ enumerable: true,
117
+ get: function () { return chunkIIC2LBD2_cjs.FFID_CONSENT_ERROR_CODES; }
118
+ });
119
+ Object.defineProperty(exports, "FFID_CONSENT_NOT_DECIDED_STATE", {
120
+ enumerable: true,
121
+ get: function () { return chunkIIC2LBD2_cjs.FFID_CONSENT_NOT_DECIDED_STATE; }
122
+ });
123
+ Object.defineProperty(exports, "GetCategoriesWireSchema", {
124
+ enumerable: true,
125
+ get: function () { return chunkIIC2LBD2_cjs.GetCategoriesWireSchema; }
126
+ });
127
+ Object.defineProperty(exports, "GetConsentMeWireSchema", {
128
+ enumerable: true,
129
+ get: function () { return chunkIIC2LBD2_cjs.GetConsentMeWireSchema; }
130
+ });
131
+ Object.defineProperty(exports, "GetDocumentWireSchema", {
132
+ enumerable: true,
133
+ get: function () { return chunkIIC2LBD2_cjs.GetDocumentWireSchema; }
134
+ });
135
+ Object.defineProperty(exports, "PostConsentRequestSchema", {
136
+ enumerable: true,
137
+ get: function () { return chunkIIC2LBD2_cjs.PostConsentRequestSchema; }
138
+ });
139
+ Object.defineProperty(exports, "PostConsentWireSchema", {
140
+ enumerable: true,
141
+ get: function () { return chunkIIC2LBD2_cjs.PostConsentWireSchema; }
142
+ });
143
+ Object.defineProperty(exports, "PostSyncRequestSchema", {
144
+ enumerable: true,
145
+ get: function () { return chunkIIC2LBD2_cjs.PostSyncRequestSchema; }
146
+ });
147
+ Object.defineProperty(exports, "PostSyncWireSchema", {
148
+ enumerable: true,
149
+ get: function () { return chunkIIC2LBD2_cjs.PostSyncWireSchema; }
150
+ });
151
+ Object.defineProperty(exports, "PostWithdrawWireSchema", {
152
+ enumerable: true,
153
+ get: function () { return chunkIIC2LBD2_cjs.PostWithdrawWireSchema; }
154
+ });
155
+ Object.defineProperty(exports, "clearConsentSessionMirror", {
156
+ enumerable: true,
157
+ get: function () { return chunkIIC2LBD2_cjs.clearConsentSessionMirror; }
158
+ });
159
+ Object.defineProperty(exports, "clearDeviceId", {
160
+ enumerable: true,
161
+ get: function () { return chunkIIC2LBD2_cjs.clearDeviceId; }
162
+ });
163
+ Object.defineProperty(exports, "createConsentClient", {
164
+ enumerable: true,
165
+ get: function () { return chunkIIC2LBD2_cjs.createConsentClient; }
166
+ });
167
+ Object.defineProperty(exports, "createGtagBridge", {
168
+ enumerable: true,
169
+ get: function () { return chunkIIC2LBD2_cjs.createGtagBridge; }
170
+ });
171
+ Object.defineProperty(exports, "decodeConsentCookie", {
172
+ enumerable: true,
173
+ get: function () { return chunkIIC2LBD2_cjs.decodeConsentCookie; }
174
+ });
175
+ Object.defineProperty(exports, "deleteConsentCookie", {
176
+ enumerable: true,
177
+ get: function () { return chunkIIC2LBD2_cjs.deleteConsentCookie; }
178
+ });
179
+ Object.defineProperty(exports, "encodeConsentCookie", {
180
+ enumerable: true,
181
+ get: function () { return chunkIIC2LBD2_cjs.encodeConsentCookie; }
182
+ });
183
+ Object.defineProperty(exports, "generateDeviceId", {
184
+ enumerable: true,
185
+ get: function () { return chunkIIC2LBD2_cjs.generateDeviceId; }
186
+ });
187
+ Object.defineProperty(exports, "getOrCreateDeviceId", {
188
+ enumerable: true,
189
+ get: function () { return chunkIIC2LBD2_cjs.getOrCreateDeviceId; }
190
+ });
191
+ Object.defineProperty(exports, "isUuidV7", {
192
+ enumerable: true,
193
+ get: function () { return chunkIIC2LBD2_cjs.isUuidV7; }
194
+ });
195
+ Object.defineProperty(exports, "isValidDeviceId", {
196
+ enumerable: true,
197
+ get: function () { return chunkIIC2LBD2_cjs.isValidDeviceId; }
198
+ });
199
+ Object.defineProperty(exports, "mapCategoriesToGtagParams", {
200
+ enumerable: true,
201
+ get: function () { return chunkIIC2LBD2_cjs.mapCategoriesToGtagParams; }
202
+ });
203
+ Object.defineProperty(exports, "mapConsentWireToState", {
204
+ enumerable: true,
205
+ get: function () { return chunkIIC2LBD2_cjs.mapConsentWireToState; }
206
+ });
207
+ Object.defineProperty(exports, "mapMeWireToState", {
208
+ enumerable: true,
209
+ get: function () { return chunkIIC2LBD2_cjs.mapMeWireToState; }
210
+ });
211
+ Object.defineProperty(exports, "mapSyncWireToResult", {
212
+ enumerable: true,
213
+ get: function () { return chunkIIC2LBD2_cjs.mapSyncWireToResult; }
214
+ });
215
+ Object.defineProperty(exports, "mapWithdrawWireToState", {
216
+ enumerable: true,
217
+ get: function () { return chunkIIC2LBD2_cjs.mapWithdrawWireToState; }
218
+ });
219
+ Object.defineProperty(exports, "readConsentCookie", {
220
+ enumerable: true,
221
+ get: function () { return chunkIIC2LBD2_cjs.readConsentCookie; }
222
+ });
223
+ Object.defineProperty(exports, "readConsentSessionMirror", {
224
+ enumerable: true,
225
+ get: function () { return chunkIIC2LBD2_cjs.readConsentSessionMirror; }
226
+ });
227
+ Object.defineProperty(exports, "useFFIDConsent", {
228
+ enumerable: true,
229
+ get: function () { return chunkIIC2LBD2_cjs.useFFIDConsent; }
230
+ });
231
+ Object.defineProperty(exports, "useFFIDConsentPreferences", {
232
+ enumerable: true,
233
+ get: function () { return chunkIIC2LBD2_cjs.useFFIDConsentPreferences; }
234
+ });
235
+ Object.defineProperty(exports, "writeConsentCookie", {
236
+ enumerable: true,
237
+ get: function () { return chunkIIC2LBD2_cjs.writeConsentCookie; }
238
+ });
239
+ Object.defineProperty(exports, "writeConsentSessionMirror", {
240
+ enumerable: true,
241
+ get: function () { return chunkIIC2LBD2_cjs.writeConsentSessionMirror; }
242
+ });
@@ -0,0 +1,166 @@
1
+ import { F as FFIDConsentResult, a as FFIDConsentState, b as FFIDConsentUpdate, c as FFIDConsentCategories, d as FFIDConsentSyncResult, e as FFIDConsentCategoryMetadata, f as FFIDCookiePolicy, P as PostConsentWire, G as GetConsentMeWire, g as PostSyncWire, h as PostWithdrawWire } from '../FFIDCookieLink-VYI2cSAB.cjs';
2
+ export { A as ALL_DENIED_EXCEPT_NECESSARY, C as CONSENT_COOKIE_MAX_AGE_SEC, i as CONSENT_COOKIE_NAME, j as CONSENT_SESSION_STORAGE_KEY, k as COOKIE_VERSION, D as DEFAULT_CONSENT_ERROR_MESSAGES, l as DEFAULT_MERGE_WARNING_MESSAGES, m as DeviceIdSchema, n as FFIDAnalyticsProvider, o as FFIDAnalyticsProviderProps, p as FFIDConsentCategoriesSchema, q as FFIDConsentCategoryCode, r as FFIDConsentCategoryCodeSchema, s as FFIDConsentCategoryMetadataSchema, t as FFIDConsentContext, u as FFIDConsentContextValue, v as FFIDConsentError, w as FFIDConsentErrorCode, x as FFIDConsentMergeStrategy, y as FFIDConsentMergeStrategySchema, z as FFIDConsentMergeWarning, B as FFIDConsentMergeWarningSchema, E as FFIDConsentSource, H as FFIDConsentSourceSchema, I as FFIDConsentStateSchema, J as FFIDConsentUpdateSchema, K as FFIDCookieBanner, L as FFIDCookieBannerClassNames, M as FFIDCookieBannerProps, N as FFIDCookieLink, O as FFIDCookieLinkProps, Q as FFIDCookiePolicySchema, R as FFIDCookieSettings, S as FFIDCookieSettingsClassNames, T as FFIDCookieSettingsProps, U as FFIDInternalConsentSource, V as FFIDInternalConsentSourceSchema, W as FFIDPublicConsentSource, X as FFIDPublicConsentSourceSchema, Y as FFID_CONSENT_ERROR_CODES, Z as FFID_CONSENT_NOT_DECIDED_STATE, _ as GetCategoriesWire, $ as GetCategoriesWireSchema, a0 as GetConsentMeWireSchema, a1 as GetDocumentWire, a2 as GetDocumentWireSchema, a3 as GtagBridge, a4 as GtagBridgeOptions, a5 as PostConsentRequest, a6 as PostConsentRequestSchema, a7 as PostConsentWireSchema, a8 as PostSyncRequest, a9 as PostSyncRequestSchema, aa as PostSyncWireSchema, ab as PostWithdrawWireSchema, ac as UseFFIDConsentPreferencesReturn, ad as UseFFIDConsentReturn, ae as clearConsentSessionMirror, af as createGtagBridge, ag as decodeConsentCookie, ah as deleteConsentCookie, ai as encodeConsentCookie, aj as mapCategoriesToGtagParams, ak as readConsentCookie, al as readConsentSessionMirror, am as useFFIDConsent, an as useFFIDConsentPreferences, ao as writeConsentCookie, ap as writeConsentSessionMirror } from '../FFIDCookieLink-VYI2cSAB.cjs';
3
+ import 'react';
4
+ import 'zod';
5
+
6
+ /**
7
+ * Cookie Consent — Device ID generation and persistence.
8
+ *
9
+ * Spec §5.3 / §6.5:
10
+ * - 36-char UUIDv7 (time-ordered) stored in `localStorage:ffid_device_id`
11
+ * - sessionStorage ephemeral fallback when localStorage is unavailable
12
+ * (Safari Private Browsing, ITP cookie partition edge cases, etc.)
13
+ * - Server validates against `DeviceIdSchema` (UUIDv4 or UUIDv7 accepted).
14
+ *
15
+ * UUIDv7 layout (RFC 9562):
16
+ * - 48 bits: unix milliseconds (big-endian)
17
+ * - 4 bits: version (0b0111)
18
+ * - 12 bits: random
19
+ * - 2 bits: variant (0b10)
20
+ * - 62 bits: random
21
+ *
22
+ * Refs: docs/02-design/COOKIE_CONSENT.md §5.3, §6.5
23
+ */
24
+ declare const DEVICE_ID_LOCAL_STORAGE_KEY = "ffid_device_id";
25
+ declare const DEVICE_ID_SESSION_STORAGE_KEY = "ffid_device_id_ephemeral";
26
+ /**
27
+ * Generate a UUIDv7 string. Falls back to crypto.randomUUID() (v4) if
28
+ * `crypto.getRandomValues` is unavailable.
29
+ */
30
+ declare function generateDeviceId(): string;
31
+ declare function isValidDeviceId(id: string): boolean;
32
+ declare function isUuidV7(id: string): boolean;
33
+ /**
34
+ * Return existing device ID or create + persist a new one.
35
+ *
36
+ * Persistence order: localStorage (preferred) → sessionStorage (ephemeral
37
+ * fallback). If neither is available the ID is still returned but not
38
+ * persisted; the caller can pass it in headers but each call will get a fresh
39
+ * value (acceptable degradation per spec §5.3).
40
+ *
41
+ * Falling through to ephemeral triggers a one-time `console.warn` so the
42
+ * operator can debug Safari Private Browsing / quota / ITP cases without
43
+ * silently breaking the shared-device merge UX.
44
+ */
45
+ declare function getOrCreateDeviceId(): string;
46
+ /** Clear all stored device IDs (used by full withdrawal flows + tests). */
47
+ declare function clearDeviceId(): void;
48
+
49
+ /**
50
+ * Cookie Consent — FFID API client (6 endpoints, Zod-validated).
51
+ *
52
+ * All responses are safe-parsed against `*WireSchema`. Parse failures or
53
+ * network errors are mapped to `FFIDConsentError` so consumers receive a
54
+ * uniform error surface via `Result<T>` returns.
55
+ *
56
+ * **HTTP 429 auto-retry** (spec §5.6): one transparent retry with
57
+ * `Retry-After + ±20% jitter`. On the second 429 (or any other error) the
58
+ * mapped `FFIDConsentError` surfaces to `Result.error`.
59
+ *
60
+ * Auth:
61
+ * - `X-Service-Api-Key`: required for all endpoints (spec §5.2).
62
+ * - `X-FFID-Device-Id`: required for write paths (`/consent`, `/sync`,
63
+ * `/withdraw`) and recommended for reads.
64
+ * - `Authorization: Bearer <jwt>`: required only for `/sync`; optional for
65
+ * other endpoints. When present, server links the row to the user_id.
66
+ *
67
+ * Refs: docs/02-design/COOKIE_CONSENT.md §5 + §8
68
+ */
69
+
70
+ interface ConsentClientOptions {
71
+ /** FFID API base URL, e.g., `https://id.feelflow.net`. */
72
+ baseUrl: string;
73
+ /**
74
+ * Service API key that scopes this client to a registered FFID service.
75
+ * Surfaced through the `X-Service-Api-Key` header on every request.
76
+ */
77
+ serviceApiKey: string;
78
+ /** Resolves the current Bearer token, or null when the user is logged out. */
79
+ getAccessToken?: () => string | null | Promise<string | null>;
80
+ /**
81
+ * Resolves the device ID (UUIDv7). MUST return a non-empty string; the
82
+ * SDK throws `auth_failure` if this returns empty (state-not-ready guard).
83
+ */
84
+ getDeviceId: () => string;
85
+ /**
86
+ * Optional fetch implementation override. Defaults to global `fetch`.
87
+ * Useful for SSR contexts and tests.
88
+ */
89
+ fetchImpl?: typeof fetch;
90
+ /**
91
+ * Optional language code for `/categories` and `/document` (defaults to 'ja').
92
+ * The server falls back to JA when EN content is missing.
93
+ */
94
+ defaultLang?: 'ja' | 'en';
95
+ /**
96
+ * Maximum number of auto-retries on HTTP 429 (default: 1, per spec §5.6).
97
+ * Set to 0 to disable.
98
+ */
99
+ maxAutoRetry429?: number;
100
+ }
101
+ interface FFIDConsentClient {
102
+ /** `GET /api/v1/ext/consent/me` */
103
+ getMe(signal?: AbortSignal): Promise<FFIDConsentResult<FFIDConsentState>>;
104
+ /** `POST /api/v1/ext/consent` (banner / preference_center submit) */
105
+ submit(categories: Required<FFIDConsentUpdate>, source: 'banner' | 'preference_center', cookiePolicyVersion: string, signal?: AbortSignal): Promise<FFIDConsentResult<FFIDConsentState>>;
106
+ /** `POST /api/v1/ext/consent/sync` */
107
+ sync(localConsent: (FFIDConsentCategories & {
108
+ cookiePolicyVersion: string;
109
+ }) | null, signal?: AbortSignal): Promise<FFIDConsentResult<FFIDConsentSyncResult>>;
110
+ /** `POST /api/v1/ext/consent/withdraw` */
111
+ withdraw(signal?: AbortSignal): Promise<FFIDConsentResult<FFIDConsentState>>;
112
+ /** `GET /api/v1/ext/consent/categories` */
113
+ getCategories(lang?: 'ja' | 'en', signal?: AbortSignal): Promise<FFIDConsentResult<FFIDConsentCategoryMetadata[]>>;
114
+ /** `GET /api/v1/ext/consent/document` */
115
+ getDocument(lang?: 'ja' | 'en', signal?: AbortSignal): Promise<FFIDConsentResult<FFIDCookiePolicy>>;
116
+ }
117
+ /**
118
+ * Factory function returning a configured client. Idiomatic to the rest of
119
+ * the SDK (see `createFFIDClient`, `createKVCacheAdapter` etc.) — avoids
120
+ * exposing a class so the API surface stays narrow.
121
+ */
122
+ declare function createConsentClient(opts: ConsentClientOptions): FFIDConsentClient;
123
+
124
+ /**
125
+ * Cookie Consent — wire ↔ consumer type mappers.
126
+ *
127
+ * Routes return snake_case envelopes ("wire" types); React consumers expect
128
+ * the camelCase discriminated union (`FFIDConsentState`, see spec §6.4).
129
+ * Map at the SDK boundary so consumer code never touches snake_case keys.
130
+ */
131
+
132
+ /**
133
+ * Convert `GET /me` wire response to the SDK consumer's discriminated union.
134
+ *
135
+ * When `consent` is null the server hasn't recorded any decision yet — emit
136
+ * the "no decision" branch with `default_state` (or hard-coded default-deny)
137
+ * as the categories.
138
+ *
139
+ * When `consent` is non-null but the server doesn't surface the original
140
+ * source (spec §6.4 wire schema omits `source` on `/me`), we report
141
+ * `persisted_unknown` to signal "decision is on file but its origin label is
142
+ * not available" — distinct from `sdk_default` which means "no decision yet".
143
+ */
144
+ declare function mapMeWireToState(wire: GetConsentMeWire): FFIDConsentState;
145
+ /**
146
+ * Convert a `POST /consent` response into a consumer state. The submission
147
+ * `source` is supplied by the caller because the wire envelope echoes the
148
+ * stored row but not the original `source` field.
149
+ */
150
+ declare function mapConsentWireToState(wire: PostConsentWire, source: 'banner' | 'preference_center'): FFIDConsentState;
151
+ /**
152
+ * Convert a `POST /withdraw` response into a consumer state. Withdrawal sets
153
+ * all optional categories to false (DB CHECK invariant per spec §4.1).
154
+ */
155
+ declare function mapWithdrawWireToState(wire: PostWithdrawWire): FFIDConsentState;
156
+ /**
157
+ * Convert a `POST /sync` response into the structured sync result. SDK
158
+ * consumers should always read `warning` and surface non-null values to the
159
+ * user per spec §5.3 (silent merge forbidden).
160
+ *
161
+ * `wire.merge_strategy` and `wire.warning` are already typed via Zod-derived
162
+ * `PostSyncWire`, so no `as` cast is needed at this boundary.
163
+ */
164
+ declare function mapSyncWireToResult(wire: PostSyncWire): FFIDConsentSyncResult;
165
+
166
+ export { type ConsentClientOptions, DEVICE_ID_LOCAL_STORAGE_KEY, DEVICE_ID_SESSION_STORAGE_KEY, FFIDConsentCategories, FFIDConsentCategoryMetadata, type FFIDConsentClient, FFIDConsentResult, FFIDConsentState, FFIDConsentSyncResult, FFIDConsentUpdate, FFIDCookiePolicy, GetConsentMeWire, PostConsentWire, PostSyncWire, PostWithdrawWire, clearDeviceId, createConsentClient, generateDeviceId, getOrCreateDeviceId, isUuidV7, isValidDeviceId, mapConsentWireToState, mapMeWireToState, mapSyncWireToResult, mapWithdrawWireToState };
@@ -0,0 +1,166 @@
1
+ import { F as FFIDConsentResult, a as FFIDConsentState, b as FFIDConsentUpdate, c as FFIDConsentCategories, d as FFIDConsentSyncResult, e as FFIDConsentCategoryMetadata, f as FFIDCookiePolicy, P as PostConsentWire, G as GetConsentMeWire, g as PostSyncWire, h as PostWithdrawWire } from '../FFIDCookieLink-VYI2cSAB.js';
2
+ export { A as ALL_DENIED_EXCEPT_NECESSARY, C as CONSENT_COOKIE_MAX_AGE_SEC, i as CONSENT_COOKIE_NAME, j as CONSENT_SESSION_STORAGE_KEY, k as COOKIE_VERSION, D as DEFAULT_CONSENT_ERROR_MESSAGES, l as DEFAULT_MERGE_WARNING_MESSAGES, m as DeviceIdSchema, n as FFIDAnalyticsProvider, o as FFIDAnalyticsProviderProps, p as FFIDConsentCategoriesSchema, q as FFIDConsentCategoryCode, r as FFIDConsentCategoryCodeSchema, s as FFIDConsentCategoryMetadataSchema, t as FFIDConsentContext, u as FFIDConsentContextValue, v as FFIDConsentError, w as FFIDConsentErrorCode, x as FFIDConsentMergeStrategy, y as FFIDConsentMergeStrategySchema, z as FFIDConsentMergeWarning, B as FFIDConsentMergeWarningSchema, E as FFIDConsentSource, H as FFIDConsentSourceSchema, I as FFIDConsentStateSchema, J as FFIDConsentUpdateSchema, K as FFIDCookieBanner, L as FFIDCookieBannerClassNames, M as FFIDCookieBannerProps, N as FFIDCookieLink, O as FFIDCookieLinkProps, Q as FFIDCookiePolicySchema, R as FFIDCookieSettings, S as FFIDCookieSettingsClassNames, T as FFIDCookieSettingsProps, U as FFIDInternalConsentSource, V as FFIDInternalConsentSourceSchema, W as FFIDPublicConsentSource, X as FFIDPublicConsentSourceSchema, Y as FFID_CONSENT_ERROR_CODES, Z as FFID_CONSENT_NOT_DECIDED_STATE, _ as GetCategoriesWire, $ as GetCategoriesWireSchema, a0 as GetConsentMeWireSchema, a1 as GetDocumentWire, a2 as GetDocumentWireSchema, a3 as GtagBridge, a4 as GtagBridgeOptions, a5 as PostConsentRequest, a6 as PostConsentRequestSchema, a7 as PostConsentWireSchema, a8 as PostSyncRequest, a9 as PostSyncRequestSchema, aa as PostSyncWireSchema, ab as PostWithdrawWireSchema, ac as UseFFIDConsentPreferencesReturn, ad as UseFFIDConsentReturn, ae as clearConsentSessionMirror, af as createGtagBridge, ag as decodeConsentCookie, ah as deleteConsentCookie, ai as encodeConsentCookie, aj as mapCategoriesToGtagParams, ak as readConsentCookie, al as readConsentSessionMirror, am as useFFIDConsent, an as useFFIDConsentPreferences, ao as writeConsentCookie, ap as writeConsentSessionMirror } from '../FFIDCookieLink-VYI2cSAB.js';
3
+ import 'react';
4
+ import 'zod';
5
+
6
+ /**
7
+ * Cookie Consent — Device ID generation and persistence.
8
+ *
9
+ * Spec §5.3 / §6.5:
10
+ * - 36-char UUIDv7 (time-ordered) stored in `localStorage:ffid_device_id`
11
+ * - sessionStorage ephemeral fallback when localStorage is unavailable
12
+ * (Safari Private Browsing, ITP cookie partition edge cases, etc.)
13
+ * - Server validates against `DeviceIdSchema` (UUIDv4 or UUIDv7 accepted).
14
+ *
15
+ * UUIDv7 layout (RFC 9562):
16
+ * - 48 bits: unix milliseconds (big-endian)
17
+ * - 4 bits: version (0b0111)
18
+ * - 12 bits: random
19
+ * - 2 bits: variant (0b10)
20
+ * - 62 bits: random
21
+ *
22
+ * Refs: docs/02-design/COOKIE_CONSENT.md §5.3, §6.5
23
+ */
24
+ declare const DEVICE_ID_LOCAL_STORAGE_KEY = "ffid_device_id";
25
+ declare const DEVICE_ID_SESSION_STORAGE_KEY = "ffid_device_id_ephemeral";
26
+ /**
27
+ * Generate a UUIDv7 string. Falls back to crypto.randomUUID() (v4) if
28
+ * `crypto.getRandomValues` is unavailable.
29
+ */
30
+ declare function generateDeviceId(): string;
31
+ declare function isValidDeviceId(id: string): boolean;
32
+ declare function isUuidV7(id: string): boolean;
33
+ /**
34
+ * Return existing device ID or create + persist a new one.
35
+ *
36
+ * Persistence order: localStorage (preferred) → sessionStorage (ephemeral
37
+ * fallback). If neither is available the ID is still returned but not
38
+ * persisted; the caller can pass it in headers but each call will get a fresh
39
+ * value (acceptable degradation per spec §5.3).
40
+ *
41
+ * Falling through to ephemeral triggers a one-time `console.warn` so the
42
+ * operator can debug Safari Private Browsing / quota / ITP cases without
43
+ * silently breaking the shared-device merge UX.
44
+ */
45
+ declare function getOrCreateDeviceId(): string;
46
+ /** Clear all stored device IDs (used by full withdrawal flows + tests). */
47
+ declare function clearDeviceId(): void;
48
+
49
+ /**
50
+ * Cookie Consent — FFID API client (6 endpoints, Zod-validated).
51
+ *
52
+ * All responses are safe-parsed against `*WireSchema`. Parse failures or
53
+ * network errors are mapped to `FFIDConsentError` so consumers receive a
54
+ * uniform error surface via `Result<T>` returns.
55
+ *
56
+ * **HTTP 429 auto-retry** (spec §5.6): one transparent retry with
57
+ * `Retry-After + ±20% jitter`. On the second 429 (or any other error) the
58
+ * mapped `FFIDConsentError` surfaces to `Result.error`.
59
+ *
60
+ * Auth:
61
+ * - `X-Service-Api-Key`: required for all endpoints (spec §5.2).
62
+ * - `X-FFID-Device-Id`: required for write paths (`/consent`, `/sync`,
63
+ * `/withdraw`) and recommended for reads.
64
+ * - `Authorization: Bearer <jwt>`: required only for `/sync`; optional for
65
+ * other endpoints. When present, server links the row to the user_id.
66
+ *
67
+ * Refs: docs/02-design/COOKIE_CONSENT.md §5 + §8
68
+ */
69
+
70
+ interface ConsentClientOptions {
71
+ /** FFID API base URL, e.g., `https://id.feelflow.net`. */
72
+ baseUrl: string;
73
+ /**
74
+ * Service API key that scopes this client to a registered FFID service.
75
+ * Surfaced through the `X-Service-Api-Key` header on every request.
76
+ */
77
+ serviceApiKey: string;
78
+ /** Resolves the current Bearer token, or null when the user is logged out. */
79
+ getAccessToken?: () => string | null | Promise<string | null>;
80
+ /**
81
+ * Resolves the device ID (UUIDv7). MUST return a non-empty string; the
82
+ * SDK throws `auth_failure` if this returns empty (state-not-ready guard).
83
+ */
84
+ getDeviceId: () => string;
85
+ /**
86
+ * Optional fetch implementation override. Defaults to global `fetch`.
87
+ * Useful for SSR contexts and tests.
88
+ */
89
+ fetchImpl?: typeof fetch;
90
+ /**
91
+ * Optional language code for `/categories` and `/document` (defaults to 'ja').
92
+ * The server falls back to JA when EN content is missing.
93
+ */
94
+ defaultLang?: 'ja' | 'en';
95
+ /**
96
+ * Maximum number of auto-retries on HTTP 429 (default: 1, per spec §5.6).
97
+ * Set to 0 to disable.
98
+ */
99
+ maxAutoRetry429?: number;
100
+ }
101
+ interface FFIDConsentClient {
102
+ /** `GET /api/v1/ext/consent/me` */
103
+ getMe(signal?: AbortSignal): Promise<FFIDConsentResult<FFIDConsentState>>;
104
+ /** `POST /api/v1/ext/consent` (banner / preference_center submit) */
105
+ submit(categories: Required<FFIDConsentUpdate>, source: 'banner' | 'preference_center', cookiePolicyVersion: string, signal?: AbortSignal): Promise<FFIDConsentResult<FFIDConsentState>>;
106
+ /** `POST /api/v1/ext/consent/sync` */
107
+ sync(localConsent: (FFIDConsentCategories & {
108
+ cookiePolicyVersion: string;
109
+ }) | null, signal?: AbortSignal): Promise<FFIDConsentResult<FFIDConsentSyncResult>>;
110
+ /** `POST /api/v1/ext/consent/withdraw` */
111
+ withdraw(signal?: AbortSignal): Promise<FFIDConsentResult<FFIDConsentState>>;
112
+ /** `GET /api/v1/ext/consent/categories` */
113
+ getCategories(lang?: 'ja' | 'en', signal?: AbortSignal): Promise<FFIDConsentResult<FFIDConsentCategoryMetadata[]>>;
114
+ /** `GET /api/v1/ext/consent/document` */
115
+ getDocument(lang?: 'ja' | 'en', signal?: AbortSignal): Promise<FFIDConsentResult<FFIDCookiePolicy>>;
116
+ }
117
+ /**
118
+ * Factory function returning a configured client. Idiomatic to the rest of
119
+ * the SDK (see `createFFIDClient`, `createKVCacheAdapter` etc.) — avoids
120
+ * exposing a class so the API surface stays narrow.
121
+ */
122
+ declare function createConsentClient(opts: ConsentClientOptions): FFIDConsentClient;
123
+
124
+ /**
125
+ * Cookie Consent — wire ↔ consumer type mappers.
126
+ *
127
+ * Routes return snake_case envelopes ("wire" types); React consumers expect
128
+ * the camelCase discriminated union (`FFIDConsentState`, see spec §6.4).
129
+ * Map at the SDK boundary so consumer code never touches snake_case keys.
130
+ */
131
+
132
+ /**
133
+ * Convert `GET /me` wire response to the SDK consumer's discriminated union.
134
+ *
135
+ * When `consent` is null the server hasn't recorded any decision yet — emit
136
+ * the "no decision" branch with `default_state` (or hard-coded default-deny)
137
+ * as the categories.
138
+ *
139
+ * When `consent` is non-null but the server doesn't surface the original
140
+ * source (spec §6.4 wire schema omits `source` on `/me`), we report
141
+ * `persisted_unknown` to signal "decision is on file but its origin label is
142
+ * not available" — distinct from `sdk_default` which means "no decision yet".
143
+ */
144
+ declare function mapMeWireToState(wire: GetConsentMeWire): FFIDConsentState;
145
+ /**
146
+ * Convert a `POST /consent` response into a consumer state. The submission
147
+ * `source` is supplied by the caller because the wire envelope echoes the
148
+ * stored row but not the original `source` field.
149
+ */
150
+ declare function mapConsentWireToState(wire: PostConsentWire, source: 'banner' | 'preference_center'): FFIDConsentState;
151
+ /**
152
+ * Convert a `POST /withdraw` response into a consumer state. Withdrawal sets
153
+ * all optional categories to false (DB CHECK invariant per spec §4.1).
154
+ */
155
+ declare function mapWithdrawWireToState(wire: PostWithdrawWire): FFIDConsentState;
156
+ /**
157
+ * Convert a `POST /sync` response into the structured sync result. SDK
158
+ * consumers should always read `warning` and surface non-null values to the
159
+ * user per spec §5.3 (silent merge forbidden).
160
+ *
161
+ * `wire.merge_strategy` and `wire.warning` are already typed via Zod-derived
162
+ * `PostSyncWire`, so no `as` cast is needed at this boundary.
163
+ */
164
+ declare function mapSyncWireToResult(wire: PostSyncWire): FFIDConsentSyncResult;
165
+
166
+ export { type ConsentClientOptions, DEVICE_ID_LOCAL_STORAGE_KEY, DEVICE_ID_SESSION_STORAGE_KEY, FFIDConsentCategories, FFIDConsentCategoryMetadata, type FFIDConsentClient, FFIDConsentResult, FFIDConsentState, FFIDConsentSyncResult, FFIDConsentUpdate, FFIDCookiePolicy, GetConsentMeWire, PostConsentWire, PostSyncWire, PostWithdrawWire, clearDeviceId, createConsentClient, generateDeviceId, getOrCreateDeviceId, isUuidV7, isValidDeviceId, mapConsentWireToState, mapMeWireToState, mapSyncWireToResult, mapWithdrawWireToState };
@@ -0,0 +1 @@
1
+ export { ALL_DENIED_EXCEPT_NECESSARY, CONSENT_COOKIE_MAX_AGE_SEC, CONSENT_COOKIE_NAME, CONSENT_SESSION_STORAGE_KEY, COOKIE_VERSION, DEFAULT_CONSENT_ERROR_MESSAGES, DEFAULT_MERGE_WARNING_MESSAGES, DEVICE_ID_LOCAL_STORAGE_KEY, DEVICE_ID_SESSION_STORAGE_KEY, DeviceIdSchema, FFIDAnalyticsProvider, FFIDConsentCategoriesSchema, FFIDConsentCategoryCodeSchema, FFIDConsentCategoryMetadataSchema, FFIDConsentContext, FFIDConsentError, FFIDConsentMergeStrategySchema, FFIDConsentMergeWarningSchema, FFIDConsentSourceSchema, FFIDConsentStateSchema, FFIDConsentUpdateSchema, FFIDCookieBanner, FFIDCookieLink, FFIDCookiePolicySchema, FFIDCookieSettings, FFIDInternalConsentSourceSchema, FFIDPublicConsentSourceSchema, FFID_CONSENT_ERROR_CODES, FFID_CONSENT_NOT_DECIDED_STATE, GetCategoriesWireSchema, GetConsentMeWireSchema, GetDocumentWireSchema, PostConsentRequestSchema, PostConsentWireSchema, PostSyncRequestSchema, PostSyncWireSchema, PostWithdrawWireSchema, clearConsentSessionMirror, clearDeviceId, createConsentClient, createGtagBridge, decodeConsentCookie, deleteConsentCookie, encodeConsentCookie, generateDeviceId, getOrCreateDeviceId, isUuidV7, isValidDeviceId, mapCategoriesToGtagParams, mapConsentWireToState, mapMeWireToState, mapSyncWireToResult, mapWithdrawWireToState, readConsentCookie, readConsentSessionMirror, useFFIDConsent, useFFIDConsentPreferences, writeConsentCookie, writeConsentSessionMirror } from '../chunk-VSHBWZXK.js';