@osano/osano-cmp-react-native 0.18.4 → 0.18.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/lib/commonjs/ConsentManager.js +70 -3
- package/lib/commonjs/ConsentManager.js.map +1 -1
- package/lib/commonjs/constants.js +2 -3
- package/lib/commonjs/constants.js.map +1 -1
- package/lib/commonjs/context.js +1 -0
- package/lib/commonjs/context.js.map +1 -1
- package/lib/commonjs/doNotSell.js +95 -0
- package/lib/commonjs/doNotSell.js.map +1 -0
- package/lib/commonjs/index.js +13 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/reducer.js +41 -41
- package/lib/commonjs/reducer.js.map +1 -1
- package/lib/commonjs/selectors.js +20 -2
- package/lib/commonjs/selectors.js.map +1 -1
- package/lib/commonjs/services/consent.js +163 -34
- package/lib/commonjs/services/consent.js.map +1 -1
- package/lib/commonjs/services/gdprMappings.js +115 -0
- package/lib/commonjs/services/gdprMappings.js.map +1 -0
- package/lib/commonjs/views/Drawer/Drawer.ConsentCategories.js +1 -1
- package/lib/commonjs/views/Drawer/Drawer.ConsentCategories.js.map +1 -1
- package/lib/module/ConsentManager.js +70 -3
- package/lib/module/ConsentManager.js.map +1 -1
- package/lib/module/constants.js +2 -3
- package/lib/module/constants.js.map +1 -1
- package/lib/module/context.js +1 -0
- package/lib/module/context.js.map +1 -1
- package/lib/module/doNotSell.js +87 -0
- package/lib/module/doNotSell.js.map +1 -0
- package/lib/module/index.js +13 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/reducer.js +41 -41
- package/lib/module/reducer.js.map +1 -1
- package/lib/module/selectors.js +16 -1
- package/lib/module/selectors.js.map +1 -1
- package/lib/module/services/consent.js +161 -33
- package/lib/module/services/consent.js.map +1 -1
- package/lib/module/services/gdprMappings.js +109 -0
- package/lib/module/services/gdprMappings.js.map +1 -0
- package/lib/module/views/Drawer/Drawer.ConsentCategories.js +2 -2
- package/lib/module/views/Drawer/Drawer.ConsentCategories.js.map +1 -1
- package/lib/typescript/src/ConsentManager.d.ts +29 -1
- package/lib/typescript/src/ConsentManager.d.ts.map +1 -1
- package/lib/typescript/src/constants.d.ts.map +1 -1
- package/lib/typescript/src/context.d.ts +1 -0
- package/lib/typescript/src/context.d.ts.map +1 -1
- package/lib/typescript/src/doNotSell.d.ts +48 -0
- package/lib/typescript/src/doNotSell.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/reducer.d.ts.map +1 -1
- package/lib/typescript/src/selectors.d.ts +3 -0
- package/lib/typescript/src/selectors.d.ts.map +1 -1
- package/lib/typescript/src/services/consent.d.ts +8 -3
- package/lib/typescript/src/services/consent.d.ts.map +1 -1
- package/lib/typescript/src/services/gdprMappings.d.ts +32 -0
- package/lib/typescript/src/services/gdprMappings.d.ts.map +1 -0
- package/lib/typescript/src/views/Drawer/Drawer.ConsentCategories.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/ConsentManager.ts +88 -7
- package/src/constants.ts +2 -3
- package/src/context.ts +2 -0
- package/src/doNotSell.ts +122 -0
- package/src/index.tsx +20 -1
- package/src/reducer.ts +53 -56
- package/src/selectors.ts +25 -2
- package/src/services/consent.ts +217 -44
- package/src/services/gdprMappings.ts +126 -0
- package/src/types/consent-config.d.ts +6 -0
- package/src/types/index.d.ts +9 -0
- package/src/views/Drawer/Drawer.ConsentCategories.tsx +2 -1
package/lib/commonjs/reducer.js
CHANGED
|
@@ -7,15 +7,19 @@ exports.init = void 0;
|
|
|
7
7
|
exports.reducer = reducer;
|
|
8
8
|
var _actions = require("./actions");
|
|
9
9
|
var _constants = require("./constants");
|
|
10
|
+
var _doNotSell = require("./doNotSell");
|
|
10
11
|
var _selectors = require("./selectors");
|
|
11
12
|
const init = initialArgs => {
|
|
12
13
|
const {
|
|
13
14
|
consent,
|
|
14
15
|
...reloadProps
|
|
15
16
|
} = initialArgs;
|
|
16
|
-
const consentRecord = consent ? Array.isArray(consent) ? (0, _constants.makeConsentFromCategories)(consent) : {
|
|
17
|
+
const consentRecord = (0, _doNotSell.normalizeDoNotSellConsent)(consent ? Array.isArray(consent) ? (0, _constants.makeConsentFromCategories)(consent) : {
|
|
17
18
|
...consent
|
|
18
|
-
} : _constants.initialState.consent
|
|
19
|
+
} : _constants.initialState.consent, {
|
|
20
|
+
enableDoNotSell: reloadProps.config?.enableDoNotSell,
|
|
21
|
+
doNotSellCategories: reloadProps.config?.doNotSellCategories
|
|
22
|
+
});
|
|
19
23
|
return {
|
|
20
24
|
..._constants.initialState,
|
|
21
25
|
...reloadProps,
|
|
@@ -89,7 +93,10 @@ function reducer(state, action) {
|
|
|
89
93
|
case _actions.SAVE_BEGIN:
|
|
90
94
|
{
|
|
91
95
|
const consentedCategories = action.payload;
|
|
92
|
-
const consent = (0, _constants.makeConsentFromCategories)(consentedCategories)
|
|
96
|
+
const consent = (0, _doNotSell.normalizeDoNotSellConsent)((0, _constants.makeConsentFromCategories)(consentedCategories), {
|
|
97
|
+
enableDoNotSell: state.config?.enableDoNotSell,
|
|
98
|
+
doNotSellCategories: state.config?.doNotSellCategories
|
|
99
|
+
});
|
|
93
100
|
return {
|
|
94
101
|
...state,
|
|
95
102
|
consent,
|
|
@@ -123,58 +130,51 @@ function reducer(state, action) {
|
|
|
123
130
|
case _actions.SET_ALL_CONSENT:
|
|
124
131
|
{
|
|
125
132
|
const acceptOrDeny = action.payload;
|
|
126
|
-
|
|
133
|
+
const next = setAllConsent(acceptOrDeny)(state);
|
|
134
|
+
return {
|
|
135
|
+
...next,
|
|
136
|
+
consent: (0, _doNotSell.normalizeDoNotSellConsent)(next.consent, {
|
|
137
|
+
enableDoNotSell: state.config?.enableDoNotSell,
|
|
138
|
+
doNotSellCategories: state.config?.doNotSellCategories
|
|
139
|
+
})
|
|
140
|
+
};
|
|
127
141
|
}
|
|
128
142
|
case _actions.TOGGLE_CATEGORY:
|
|
129
143
|
{
|
|
144
|
+
// The action creator accepts either the shorthand string form
|
|
145
|
+
// (toggleCategory(ConsentCategory.X)) or an explicit { category, value }.
|
|
130
146
|
const {
|
|
131
147
|
category,
|
|
132
148
|
value
|
|
133
|
-
} = action.payload
|
|
149
|
+
} = typeof action.payload === 'string' ? {
|
|
150
|
+
category: action.payload,
|
|
151
|
+
value: undefined
|
|
152
|
+
} : action.payload;
|
|
134
153
|
if (typeof category !== 'string') {
|
|
135
154
|
return state;
|
|
136
155
|
}
|
|
156
|
+
const key = category;
|
|
137
157
|
|
|
138
|
-
//
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
158
|
+
// Resolve the new value: an explicit boolean, otherwise flip the current
|
|
159
|
+
// value (an unset category defaults to on).
|
|
160
|
+
const current = state.consent[key];
|
|
161
|
+
const newValue = typeof value === 'boolean' ? value : current !== undefined ? !current : true;
|
|
142
162
|
|
|
143
|
-
//
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if (typeof value === 'boolean') {
|
|
155
|
-
return {
|
|
156
|
-
...state,
|
|
157
|
-
consent: {
|
|
158
|
-
...state.consent,
|
|
159
|
-
[category]: value
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
if (state.consent[category] !== undefined) {
|
|
164
|
-
return {
|
|
165
|
-
...state,
|
|
166
|
-
consent: {
|
|
167
|
-
...state.consent,
|
|
168
|
-
[category]: !state.consent[category]
|
|
169
|
-
}
|
|
170
|
-
};
|
|
163
|
+
// Keep the opt-out and its governed categories mutually exclusive.
|
|
164
|
+
const forcedOff = (0, _doNotSell.doNotSellSideEffects)(key, newValue, {
|
|
165
|
+
enableDoNotSell: state.config?.enableDoNotSell,
|
|
166
|
+
doNotSellCategories: state.config?.doNotSellCategories
|
|
167
|
+
});
|
|
168
|
+
const consent = {
|
|
169
|
+
...state.consent,
|
|
170
|
+
[key]: newValue
|
|
171
|
+
};
|
|
172
|
+
for (const forced of forcedOff) {
|
|
173
|
+
consent[forced] = false;
|
|
171
174
|
}
|
|
172
175
|
return {
|
|
173
176
|
...state,
|
|
174
|
-
consent
|
|
175
|
-
...state.consent,
|
|
176
|
-
[category]: true
|
|
177
|
-
}
|
|
177
|
+
consent
|
|
178
178
|
};
|
|
179
179
|
}
|
|
180
180
|
case _actions.SHOW_DIALOG:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_actions","require","_constants","_selectors","init","initialArgs","consent","reloadProps","consentRecord","Array","isArray","makeConsentFromCategories","initialState","savedConsent","exports","setAllConsent","acceptOrDeny","state","isAccepted","category","useGPC","shouldUseGPCOptOut","newConsent","OsanoCategories","reducer","action","type","RELOAD","payload","SET_CONFIG","
|
|
1
|
+
{"version":3,"names":["_actions","require","_constants","_doNotSell","_selectors","init","initialArgs","consent","reloadProps","consentRecord","normalizeDoNotSellConsent","Array","isArray","makeConsentFromCategories","initialState","enableDoNotSell","config","doNotSellCategories","savedConsent","exports","setAllConsent","acceptOrDeny","state","isAccepted","category","useGPC","shouldUseGPCOptOut","newConsent","OsanoCategories","reducer","action","type","RELOAD","payload","SET_CONFIG","customerId","configId","consentConfig","SET_LOCALE","locale","SAVE_BEGIN","consentedCategories","CLEAR_CONSENT","optOutStatus","getFinalOptOutValue","ConsentCategory","OPT_OUT","ANALYTICS","isAnalyticsAlwaysAllowed","consentTimestamp","REVERT_CONSENT","previousConsent","getPriorConsent","SET_ALL_CONSENT","next","TOGGLE_CATEGORY","value","undefined","key","current","newValue","forcedOff","doNotSellSideEffects","forced","SHOW_DIALOG","dialogOpen","stack","SHOW_DRAWER","SHOW_IAB_DISCLOSURES","scrollToType","id","scrollToId","SHOW_IAB_VENDORS","GO_BACK","length","slice","CLOSE","FETCH_DISCLOSURES_BEGIN","disclosures","loading","fetched","indexOf","FETCH_DISCLOSURES_FAILURE","filter","cat","FETCH_DISCLOSURES_SUCCESS","results","currentlyFetched","Object","values","disclosuresByCategory","reduce","categories","disclosure","classification","categoryName","categoryDisclosures","push","newResults","entries","validCategories","lookup","name","uuid","sort","a","b","localeCompare","index","list"],"sourceRoot":"../../src","sources":["reducer.ts"],"mappings":";;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAmBA,IAAAC,UAAA,GAAAD,OAAA;AAOA,IAAAE,UAAA,GAAAF,OAAA;AAEA,IAAAG,UAAA,GAAAH,OAAA;AASO,MAAMI,IAAI,GAAIC,WAA6B,IAAiB;EAClE,MAAM;IAAEC,OAAO;IAAE,GAAGC;EAAY,CAAC,GAAGF,WAAW;EAC/C,MAAMG,aAAa,GAAG,IAAAC,oCAAyB,EAC9CH,OAAO,GACJI,KAAK,CAACC,OAAO,CAACL,OAAO,CAAC,GACrB,IAAAM,oCAAyB,EAACN,OAAO,CAAC,GAClC;IAAE,GAAGA;EAAQ,CAAC,GACfO,uBAAY,CAACP,OAAO,EACvB;IACCQ,eAAe,EAAEP,WAAW,CAACQ,MAAM,EAAED,eAAe;IACpDE,mBAAmB,EAAET,WAAW,CAACQ,MAAM,EAAEC;EAC1C,CACD,CAAC;EACD,OAAO;IACN,GAAGH,uBAAY;IACf,GAAGN,WAAW;IACdD,OAAO,EAAEE,aAAa;IACtBS,YAAY,EAAEX,OAAO,GACjB;MAAE,GAAGE;IAAc,CAAC,GACrB;EACJ,CAAC;AACF,CAAC;AAACU,OAAA,CAAAd,IAAA,GAAAA,IAAA;AAEF,MAAMe,aAAa,GAAIC,YAAqB,IAAMC,KAAiB,IAAK;EACvE,SAASC,UAAUA,CAACC,QAA6B,EAAE;IAClD,MAAMC,MAAM,GAAG,IAAAC,6BAAkB,EAACJ,KAAK,EAAE,CAACD,YAAY,CAAC;IACvD,QAAQG,QAAQ;MACf,KAAK,WAAW;QAAE;UACjB,OAAO,IAAI;QACZ;MACA,KAAK,SAAS;QAAE;UACf;UACA,OAAOC,MAAM,IAAI,CAACJ,YAAY;QAC/B;MACA,KAAK,WAAW;QAAE;UACjB;UACA,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,GAAG,EAAEwB,KAAK,EAAEC,IAAI,KAAKA,IAAI,CAAC5B,OAAO,CAACG,GAAG,CAAC,KAAKwB,KAC7C,CAAC;YACD7B,OAAO,EAAE;UACV;QACD,CAAC;MACF;IACA;MACC,OAAOzD,KAAK;EACd;AACD","ignoreList":[]}
|
|
@@ -10,14 +10,32 @@ exports.getFinalOptOutValue = getFinalOptOutValue;
|
|
|
10
10
|
exports.getPriorConsent = getPriorConsent;
|
|
11
11
|
exports.getSavedConsent = getSavedConsent;
|
|
12
12
|
exports.getStack = getStack;
|
|
13
|
-
exports.shouldUseGPCOptOut = exports.isLoadingDisclosures = exports.isGPCSupportEnabled = exports.isDrawerOpen = exports.isDialogOpen = exports.isConsentReady = exports.isCategoryDisabled = exports.isCategoryAccepted = exports.isAnalyticsAlwaysAllowed = exports.hasFetchedDisclosuresForCategory = void 0;
|
|
13
|
+
exports.shouldUseGPCOptOut = exports.shouldRenderOptOut = exports.isLoadingDisclosures = exports.isGPCSupportEnabled = exports.isDrawerOpen = exports.isDoNotSellEnabled = exports.isDialogOpen = exports.isConsentReady = exports.isCategoryDisabled = exports.isCategoryAccepted = exports.isBrowsingFromUS = exports.isAnalyticsAlwaysAllowed = exports.hasFetchedDisclosuresForCategory = void 0;
|
|
14
14
|
var _constants = require("./constants");
|
|
15
|
+
var _doNotSell = require("./doNotSell");
|
|
15
16
|
var _utils = require("./utils");
|
|
16
17
|
const isCategoryAccepted = (state, category) => getConsent(state).includes(category);
|
|
17
18
|
exports.isCategoryAccepted = isCategoryAccepted;
|
|
18
19
|
const isAnalyticsAlwaysAllowed = state => !!state.config?.type.analyticsAlways;
|
|
19
20
|
exports.isAnalyticsAlwaysAllowed = isAnalyticsAlwaysAllowed;
|
|
20
|
-
const
|
|
21
|
+
const isBrowsingFromUS = state => !!state.config?.browsingFromUS;
|
|
22
|
+
exports.isBrowsingFromUS = isBrowsingFromUS;
|
|
23
|
+
const isDoNotSellEnabled = state => !!state.config?.enableDoNotSell;
|
|
24
|
+
|
|
25
|
+
// Whether to render the "Do Not Sell / Share" opt-out toggle. Delegates to the
|
|
26
|
+
// config's visibility rule (tenant flag AND ccpaApplies/US).
|
|
27
|
+
exports.isDoNotSellEnabled = isDoNotSellEnabled;
|
|
28
|
+
const shouldRenderOptOut = state => !!state.config?.isDoNotSellVisible;
|
|
29
|
+
|
|
30
|
+
// The categories the opt-out governs (config's doNotSellCategories, defaulting
|
|
31
|
+
// to Marketing). ESSENTIAL and OPT_OUT are never governed.
|
|
32
|
+
exports.shouldRenderOptOut = shouldRenderOptOut;
|
|
33
|
+
const isGovernedByOptOut = (state, category) => (0, _doNotSell.resolveDoNotSellCategories)(state.config?.doNotSellCategories).includes(category);
|
|
34
|
+
const isCategoryDisabled = (state, category) => category === _constants.ConsentCategory.ESSENTIAL || category === _constants.ConsentCategory.OPT_OUT && isGPCSupportEnabled(state) ||
|
|
35
|
+
// A governed category is locked off while the opt-out is active. Keyed off the
|
|
36
|
+
// configured governed categories, so a non-governed category (e.g. Marketing
|
|
37
|
+
// when the tenant governs Analytics) stays enabled.
|
|
38
|
+
isGovernedByOptOut(state, category) && (shouldRenderOptOut(state) || isGPCSupportEnabled(state)) && isCategoryAccepted(state, _constants.ConsentCategory.OPT_OUT);
|
|
21
39
|
exports.isCategoryDisabled = isCategoryDisabled;
|
|
22
40
|
const isDrawerOpen = state => state.stack.length > 0;
|
|
23
41
|
exports.isDrawerOpen = isDrawerOpen;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_constants","require","_utils","isCategoryAccepted","state","category","getConsent","includes","exports","isAnalyticsAlwaysAllowed","config","type","analyticsAlways","
|
|
1
|
+
{"version":3,"names":["_constants","require","_doNotSell","_utils","isCategoryAccepted","state","category","getConsent","includes","exports","isAnalyticsAlwaysAllowed","config","type","analyticsAlways","isBrowsingFromUS","browsingFromUS","isDoNotSellEnabled","enableDoNotSell","shouldRenderOptOut","isDoNotSellVisible","isGovernedByOptOut","resolveDoNotSellCategories","doNotSellCategories","isCategoryDisabled","ConsentCategory","ESSENTIAL","OPT_OUT","isGPCSupportEnabled","isDrawerOpen","stack","length","isDialogOpen","dialogOpen","gpcSupport","navigator","Object","hasOwnProperty","call","window","shouldUseGPCOptOut","acceptOrDeny","hasOwn","consent","entries","filter","_key","value","map","key","getFinalOptOutValue","pendingNewValue","undefined","existingOptOut","get","initialState","getSavedConsent","getPriorConsent","previousConsent","ANALYTICS","getConsentTimestamp","loadingDisclosures","noDisclosures","name","isConsentReady","isLoadingDisclosures","disclosures","loading","hasFetchedDisclosuresForCategory","fetched","indexOf","getCategoryDisclosures","getStack","index"],"sourceRoot":"../../src","sources":["selectors.ts"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAOA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEO,MAAMG,kBAAkB,GAAGA,CACjCC,KAAiB,EACjBC,QAA6B,KACzBC,UAAU,CAACF,KAAK,CAAC,CAACG,QAAQ,CAACF,QAAQ,CAAC;AAACG,OAAA,CAAAL,kBAAA,GAAAA,kBAAA;AAEnC,MAAMM,wBAAwB,GAAIL,KAAiB,IACzD,CAAC,CAACA,KAAK,CAACM,MAAM,EAAEC,IAAI,CAACC,eAAe;AAACJ,OAAA,CAAAC,wBAAA,GAAAA,wBAAA;AAE/B,MAAMI,gBAAgB,GAAIT,KAAiB,IACjD,CAAC,CAACA,KAAK,CAACM,MAAM,EAAEI,cAAc;AAACN,OAAA,CAAAK,gBAAA,GAAAA,gBAAA;AAEzB,MAAME,kBAAkB,GAAIX,KAAiB,IACnD,CAAC,CAACA,KAAK,CAACM,MAAM,EAAEM,eAAe;;AAEhC;AACA;AAAAR,OAAA,CAAAO,kBAAA,GAAAA,kBAAA;AACO,MAAME,kBAAkB,GAAIb,KAAiB,IACnD,CAAC,CAACA,KAAK,CAACM,MAAM,EAAEQ,kBAAkB;;AAEnC;AACA;AAAAV,OAAA,CAAAS,kBAAA,GA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AsB,GAAGA,CACrCjE,KAAiB,EACjBC,QAA6B,KACX;EAClB,MAAM2D,WAAyB,GAC9B,IAAAZ,UAAG,EAAChD,KAAK,EAAE,uBAAuBC,QAAQ,EAAE,CAAC,IAAI,EAAE;EACpD,IAAI2D,WAAW,CAACnC,MAAM,EAAE;IACvB,OAAOmC,WAAW;EACnB;EACA,MAAMC,OAAO,GACZF,oBAAoB,CAAC3D,KAAK,CAAC,IAC3B,CAAC8D,gCAAgC,CAAC9D,KAAK,EAAEC,QAAQ,CAAC;EACnD,OAAO4D,OAAO,GAAGN,kBAAkB,GAAGC,aAAa;AACpD,CAAC;AAACpD,OAAA,CAAA6D,sBAAA,GAAAA,sBAAA;AAIK,SAASC,QAAQA,CAAClE,KAAiB,EAAEmE,KAAc,EAAE;EAC3D,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC9B,IAAIA,KAAK,GAAG,CAAC,EAAE;MACd,IAAIA,KAAK,IAAI,CAACnE,KAAK,CAACwB,KAAK,CAACC,MAAM,EAAE;QACjC,OAAOzB,KAAK,CAACwB,KAAK,CAACxB,KAAK,CAACwB,KAAK,CAACC,MAAM,GAAG0C,KAAK,CAAC;MAC/C;MACA,OAAOrB,SAAS;IACjB;IACA,OAAO9C,KAAK,CAACwB,KAAK,CAAC2C,KAAK,CAAC;EAC1B;EACA,OAAOnE,KAAK,CAACwB,KAAK;AACnB","ignoreList":[]}
|
|
@@ -5,12 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.hasStaleConfig = exports.getStoredLastModified = exports.getStoredEtag = exports.getStoredConfig = exports.getConfigLastStoredAt = exports.fetchConsent = exports.fetchConfig = exports.clearConsent = void 0;
|
|
7
7
|
exports.hashExtUsrData = hashExtUsrData;
|
|
8
|
-
exports.storeConsent = exports.storeConfig = exports.recordConsent = exports.migrateConsentStorage = void 0;
|
|
8
|
+
exports.storeConsent = exports.storeConfig = exports.recordConsent = exports.migrateConsentStorage = exports.isConsentExpired = void 0;
|
|
9
9
|
var _jsSha = require("js-sha512");
|
|
10
10
|
var _reactNative = require("react-native");
|
|
11
11
|
var _textEncoding = require("text-encoding");
|
|
12
12
|
var _constants = require("../constants");
|
|
13
|
+
var _doNotSell = require("../doNotSell");
|
|
13
14
|
var _OsanoCmp = require("../native/OsanoCmp");
|
|
15
|
+
var _gdprMappings = require("./gdprMappings");
|
|
14
16
|
var _utils = require("../utils");
|
|
15
17
|
var _API = _interopRequireDefault(require("../utils/API"));
|
|
16
18
|
var _OsanoLogger = require("../utils/OsanoLogger");
|
|
@@ -42,6 +44,13 @@ function createConsentRecordPayload(cmp, consent) {
|
|
|
42
44
|
}).filter(([, value]) => value !== undefined));
|
|
43
45
|
}
|
|
44
46
|
const STORAGE_KEY = 'osano_consentmanager';
|
|
47
|
+
|
|
48
|
+
// The consent timestamp is scoped by configId so it tracks the consent record
|
|
49
|
+
// for that config (both also carry the userSuffix). Older builds wrote a single
|
|
50
|
+
// un-scoped key shared across configs; retrieveLastConsentTimestamp falls back
|
|
51
|
+
// to it so existing installs keep their recorded date until the next write.
|
|
52
|
+
const lastConsentDateKey = (configId, userSuffix) => `${STORAGE_KEY}_last_recorded_consent_date_${configId}${userSuffix}`;
|
|
53
|
+
const legacyLastConsentDateKey = userSuffix => `${STORAGE_KEY}_last_recorded_consent_date${userSuffix}`;
|
|
45
54
|
function consentRecordedRemotely(configId, success, hashedExtUsrData) {
|
|
46
55
|
const userSuffix = hashedExtUsrData ? `_${hashedExtUsrData}` : '';
|
|
47
56
|
if (success) {
|
|
@@ -50,7 +59,7 @@ function consentRecordedRemotely(configId, success, hashedExtUsrData) {
|
|
|
50
59
|
(0, _OsanoCmp.setStorage)(`${STORAGE_KEY}_${configId}${userSuffix}_last_failed_remote_record`, JSON.stringify(new Date()));
|
|
51
60
|
}
|
|
52
61
|
}
|
|
53
|
-
const storeConsent = async (cmp, consent, recordedRemotely) => {
|
|
62
|
+
const storeConsent = async (cmp, consent, recordedRemotely, consentDate) => {
|
|
54
63
|
cmp.consent = consent ?? cmp.consent;
|
|
55
64
|
return new Promise((resolve, reject) => {
|
|
56
65
|
const resConsent = () => {
|
|
@@ -59,12 +68,14 @@ const storeConsent = async (cmp, consent, recordedRemotely) => {
|
|
|
59
68
|
};
|
|
60
69
|
const hashedExtUsrData = hashExtUsrData(cmp.customerId, cmp.configId, cmp.extUsrData);
|
|
61
70
|
const userSuffix = hashedExtUsrData ? `_${hashedExtUsrData}` : '';
|
|
71
|
+
const parsedDate = consentDate ? new Date(consentDate) : new Date();
|
|
72
|
+
const recordedDate = Number.isNaN(parsedDate.getTime()) ? new Date() : parsedDate;
|
|
62
73
|
switch (_reactNative.Platform.OS) {
|
|
63
74
|
case 'ios':
|
|
64
75
|
case 'android':
|
|
65
76
|
default:
|
|
66
77
|
{
|
|
67
|
-
(0, _OsanoCmp.setStorage)(
|
|
78
|
+
(0, _OsanoCmp.setStorage)(lastConsentDateKey(cmp.configId, userSuffix), JSON.stringify(recordedDate)).then(() => {
|
|
68
79
|
(0, _OsanoCmp.setStorage)(`${STORAGE_KEY}_${cmp.configId}${userSuffix}`, JSON.stringify(cmp.consent)).then(resConsent).catch(reject);
|
|
69
80
|
}).catch(reject);
|
|
70
81
|
if (recordedRemotely !== undefined) {
|
|
@@ -116,7 +127,10 @@ const migrateConsentStorage = async cmp => {
|
|
|
116
127
|
if (oldConsent) {
|
|
117
128
|
let consent = JSON.parse(oldConsent);
|
|
118
129
|
if (consent.length > 0) {
|
|
119
|
-
consent = (0, _constants.formatConsentArray)((0, _constants.makeConsentFromCategories)(consent)
|
|
130
|
+
consent = (0, _constants.formatConsentArray)((0, _doNotSell.normalizeDoNotSellConsent)((0, _constants.makeConsentFromCategories)(consent), {
|
|
131
|
+
enableDoNotSell: cmp.config.enableDoNotSell,
|
|
132
|
+
doNotSellCategories: cmp.config.doNotSellCategories
|
|
133
|
+
}));
|
|
120
134
|
// Store with new user-specific key
|
|
121
135
|
storeConsent(cmp, consent).then(() => {
|
|
122
136
|
// Clean up old storage
|
|
@@ -141,8 +155,24 @@ const migrateConsentStorage = async cmp => {
|
|
|
141
155
|
|
|
142
156
|
// The consent to fall back to when a visitor has no stored consent yet. Flavor 7
|
|
143
157
|
// shows analytics enabled on first load; every other flavor stays essential-only.
|
|
158
|
+
// The Do-Not-Sell default is then applied, but only when the opt-out would
|
|
159
|
+
// actually be visible (tenant flag + CCPA/US), so we never seed an OPT_OUT the
|
|
160
|
+
// user cannot see or control.
|
|
144
161
|
exports.migrateConsentStorage = migrateConsentStorage;
|
|
145
|
-
const firstLoadConsent = cmp =>
|
|
162
|
+
const firstLoadConsent = cmp => {
|
|
163
|
+
let categories = [_constants.ConsentCategory.ESSENTIAL];
|
|
164
|
+
if (cmp.config?.analyticsDefaultsOnAtFirstLoad) {
|
|
165
|
+
categories.push(_constants.ConsentCategory.ANALYTICS);
|
|
166
|
+
}
|
|
167
|
+
if (cmp.config?.isDoNotSellVisible) {
|
|
168
|
+
categories = (0, _doNotSell.applyDoNotSellDefault)(categories, {
|
|
169
|
+
enableDoNotSell: cmp.config.enableDoNotSell,
|
|
170
|
+
enableDoNotSellDefault: cmp.config.enableDoNotSellDefault,
|
|
171
|
+
doNotSellCategories: cmp.config.doNotSellCategories
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
return categories;
|
|
175
|
+
};
|
|
146
176
|
|
|
147
177
|
// Clear any stale storage, then seed the first-load default. Because this only
|
|
148
178
|
// runs when there is no stored consent, a returning visitor's saved opt-out is
|
|
@@ -153,7 +183,24 @@ const clearToFirstLoadDefault = async cmp => {
|
|
|
153
183
|
cmp.consent = seed;
|
|
154
184
|
return seed;
|
|
155
185
|
};
|
|
186
|
+
|
|
187
|
+
// After an expired/invalid record, settle on a persisted essential-only state.
|
|
188
|
+
// Persisting (rather than only clearing the payload with clearConsent) keeps a
|
|
189
|
+
// subsequent load in this safe state instead of falling back to the first-load
|
|
190
|
+
// default — which, for Flavor 7, would re-enable analytics. This matters
|
|
191
|
+
// because a later load may resolve no expiration window (testing off, offline
|
|
192
|
+
// with no mappings cache, or a country with no interval), in which case empty
|
|
193
|
+
// storage would otherwise re-seed the first-load default.
|
|
194
|
+
const settleEssentialOnly = cmp => storeConsent(cmp, [_constants.ConsentCategory.ESSENTIAL]);
|
|
156
195
|
const retrieveConsent = async cmp => {
|
|
196
|
+
// If stored consent has aged past its expiration window (production
|
|
197
|
+
// per-country interval, or the debug testing override), settle on a persisted
|
|
198
|
+
// essential-only state so callers see essential-only and a later load stays
|
|
199
|
+
// here (mirrors Android's clearExpiredConsent() + essential-only
|
|
200
|
+
// getConsentedCategories()).
|
|
201
|
+
if (await isConsentExpired(cmp)) {
|
|
202
|
+
return settleEssentialOnly(cmp);
|
|
203
|
+
}
|
|
157
204
|
return new Promise(resolve => {
|
|
158
205
|
const resConsent = consentJson => {
|
|
159
206
|
if (consentJson) {
|
|
@@ -195,34 +242,91 @@ const retrieveConsent = async cmp => {
|
|
|
195
242
|
});
|
|
196
243
|
};
|
|
197
244
|
const retrieveLastConsentTimestamp = async cmp => {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
return timestamp;
|
|
204
|
-
} else {
|
|
205
|
-
resolve('');
|
|
206
|
-
return '';
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
const hashedExtUsrData = hashExtUsrData(cmp.customerId, cmp.configId, cmp.extUsrData);
|
|
210
|
-
const userSuffix = hashedExtUsrData ? `_${hashedExtUsrData}` : '';
|
|
211
|
-
switch (_reactNative.Platform.OS) {
|
|
212
|
-
case 'ios':
|
|
213
|
-
case 'android':
|
|
214
|
-
default:
|
|
215
|
-
(0, _OsanoCmp.getStorage)(`${STORAGE_KEY}_last_recorded_consent_date${userSuffix}`).then(resValue);
|
|
216
|
-
break;
|
|
245
|
+
const hashedExtUsrData = hashExtUsrData(cmp.customerId, cmp.configId, cmp.extUsrData);
|
|
246
|
+
const userSuffix = hashedExtUsrData ? `_${hashedExtUsrData}` : '';
|
|
247
|
+
const parse = json => {
|
|
248
|
+
if (!json) {
|
|
249
|
+
return '';
|
|
217
250
|
}
|
|
218
|
-
|
|
251
|
+
try {
|
|
252
|
+
return JSON.parse(json);
|
|
253
|
+
} catch {
|
|
254
|
+
return '';
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
try {
|
|
258
|
+
const scoped = parse(await (0, _OsanoCmp.getStorage)(lastConsentDateKey(cmp.configId, userSuffix)));
|
|
259
|
+
if (scoped) {
|
|
260
|
+
return scoped;
|
|
261
|
+
}
|
|
262
|
+
// Fall back to the legacy un-scoped key for installs written before the
|
|
263
|
+
// timestamp was scoped by configId.
|
|
264
|
+
return parse(await (0, _OsanoCmp.getStorage)(legacyLastConsentDateKey(userSuffix)));
|
|
265
|
+
} catch {
|
|
266
|
+
// Fail closed: a storage rejection resolves to no timestamp instead of
|
|
267
|
+
// hanging the consent load.
|
|
268
|
+
return '';
|
|
269
|
+
}
|
|
219
270
|
};
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Resolves the effective expiration window in seconds, mirroring the Android
|
|
274
|
+
* SDK's single path:
|
|
275
|
+
*
|
|
276
|
+
* debug testing override ?? production interval (per-country, from the GDPR
|
|
277
|
+
* mappings served at /mappings.json)
|
|
278
|
+
*
|
|
279
|
+
* Testing mode does not create a separate expiration path — it overrides the
|
|
280
|
+
* production interval. Returns null when neither is configured, in which case
|
|
281
|
+
* consent has no expiration.
|
|
282
|
+
*/
|
|
283
|
+
const effectiveExpirationSeconds = async cmp => {
|
|
284
|
+
const testingSeconds = cmp.consentExpirationTestingSeconds;
|
|
285
|
+
// Testing override short-circuits the production lookup entirely, so debug
|
|
286
|
+
// runs never depend on the mappings fetch.
|
|
287
|
+
const seconds = testingSeconds ?? (await (0, _gdprMappings.getConsentExpirationSeconds)(cmp.config?.country));
|
|
288
|
+
return seconds && seconds > 0 ? seconds : null;
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* True when `timestamp` is older than the `seconds` window. Fails closed
|
|
293
|
+
* (returns false) for a missing or unparseable timestamp, or when no window is
|
|
294
|
+
* configured, so a storage hiccup or a null window never wrongly expires
|
|
295
|
+
* consent.
|
|
296
|
+
*/
|
|
297
|
+
const isTimestampExpired = (timestamp, seconds) => {
|
|
298
|
+
if (!seconds || !timestamp) {
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
const consentedAtMs = new Date(timestamp).getTime();
|
|
302
|
+
if (Number.isNaN(consentedAtMs)) {
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
return Date.now() - consentedAtMs > seconds * 1000;
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Returns true when the locally stored consent has aged past its expiration
|
|
310
|
+
* window (see {@link effectiveExpirationSeconds}).
|
|
311
|
+
*/
|
|
312
|
+
const isConsentExpired = async cmp => {
|
|
313
|
+
const seconds = await effectiveExpirationSeconds(cmp);
|
|
314
|
+
if (!seconds) {
|
|
315
|
+
return false;
|
|
316
|
+
}
|
|
317
|
+
const timestamp = await retrieveLastConsentTimestamp(cmp);
|
|
318
|
+
return isTimestampExpired(timestamp, seconds);
|
|
319
|
+
};
|
|
320
|
+
exports.isConsentExpired = isConsentExpired;
|
|
220
321
|
const recordConsent = (cmp, consent) => {
|
|
221
322
|
const payload = createConsentRecordPayload(cmp, consent);
|
|
222
323
|
return _API.default.post(`${CONSENT_URI}/record`, payload, {
|
|
223
324
|
referrer: cmp.consentingDomain
|
|
224
325
|
}).then(() => consent ?? cmp.consent ?? [_constants.ConsentCategory.ESSENTIAL]).then(consentCategories => {
|
|
225
|
-
consentCategories = (0, _constants.formatConsentArray)((0, _constants.makeConsentFromCategories)(consentCategories)
|
|
326
|
+
consentCategories = (0, _constants.formatConsentArray)((0, _doNotSell.normalizeDoNotSellConsent)((0, _constants.makeConsentFromCategories)(consentCategories), {
|
|
327
|
+
enableDoNotSell: cmp.config.enableDoNotSell,
|
|
328
|
+
doNotSellCategories: cmp.config.doNotSellCategories
|
|
329
|
+
}));
|
|
226
330
|
storeConsent(cmp, consentCategories, true);
|
|
227
331
|
return consentCategories;
|
|
228
332
|
}).catch(error => {
|
|
@@ -269,25 +373,50 @@ const fetchConsent = async cmp => {
|
|
|
269
373
|
lastConsentTimestamp
|
|
270
374
|
} = response;
|
|
271
375
|
if (!consented || !lastConsentTimestamp) {
|
|
272
|
-
// No remote
|
|
273
|
-
|
|
376
|
+
// No remote record — keep the local consent as-is. Re-storing it here
|
|
377
|
+
// would reset the recorded-consent timestamp to "now" on every load, so
|
|
378
|
+
// expiration would never fire for remote + extUsrData users, and it
|
|
379
|
+
// could re-persist an essential-only clear. The local consent is already
|
|
380
|
+
// stored with its real timestamp (or is a first-load default that stays
|
|
381
|
+
// re-seeded).
|
|
274
382
|
return consent;
|
|
275
383
|
}
|
|
276
384
|
|
|
385
|
+
// Evaluate the remote record against the server's own timestamp (when the
|
|
386
|
+
// visitor actually consented), not "now", so an already-expired remote
|
|
387
|
+
// record is never restored and re-dated as fresh.
|
|
388
|
+
const seconds = await effectiveExpirationSeconds(cmp);
|
|
389
|
+
const remoteExpired = isTimestampExpired(lastConsentTimestamp, seconds);
|
|
390
|
+
|
|
277
391
|
// If extUsrData is not null and not empty, always use remote consent (cross-device consent enabled)
|
|
278
392
|
if (extUsrData && extUsrData.trim() !== '') {
|
|
279
|
-
|
|
280
|
-
|
|
393
|
+
if (remoteExpired) {
|
|
394
|
+
// The authoritative remote record has expired; settle on a persisted
|
|
395
|
+
// essential-only state rather than restoring stale consent, so a
|
|
396
|
+
// subsequent load stays here instead of falling back to the
|
|
397
|
+
// first-load default.
|
|
398
|
+
return settleEssentialOnly(cmp);
|
|
399
|
+
}
|
|
400
|
+
const remoteConsentCategories = (0, _constants.formatConsentArray)((0, _doNotSell.normalizeDoNotSellConsent)((0, _constants.makeConsentFromCategories)(consented.map(category => _constants.ConsentCategory[category])), {
|
|
401
|
+
enableDoNotSell: cmp.config.enableDoNotSell,
|
|
402
|
+
doNotSellCategories: cmp.config.doNotSellCategories
|
|
403
|
+
}));
|
|
404
|
+
// Preserve the server timestamp so restoring can't re-date the record.
|
|
405
|
+
await storeConsent(cmp, remoteConsentCategories, true, lastConsentTimestamp);
|
|
281
406
|
return remoteConsentCategories;
|
|
282
407
|
}
|
|
283
408
|
|
|
284
409
|
// Otherwise, validate timestamps (cross-device consent not enabled)
|
|
285
410
|
const internalTimestamp = await retrieveLastConsentTimestamp(cmp);
|
|
286
411
|
try {
|
|
287
|
-
if (new Date(lastConsentTimestamp) > new Date(internalTimestamp) || internalTimestamp === '') {
|
|
288
|
-
// Remote consent is newer or we haven't recorded any
|
|
289
|
-
|
|
290
|
-
|
|
412
|
+
if (!remoteExpired && (new Date(lastConsentTimestamp) > new Date(internalTimestamp) || internalTimestamp === '')) {
|
|
413
|
+
// Remote consent is newer, unexpired, or we haven't recorded any
|
|
414
|
+
// consent yet. Store it, preserving the server timestamp.
|
|
415
|
+
const remoteConsentCategories = (0, _constants.formatConsentArray)((0, _doNotSell.normalizeDoNotSellConsent)((0, _constants.makeConsentFromCategories)(consented), {
|
|
416
|
+
enableDoNotSell: cmp.config.enableDoNotSell,
|
|
417
|
+
doNotSellCategories: cmp.config.doNotSellCategories
|
|
418
|
+
}));
|
|
419
|
+
await storeConsent(cmp, remoteConsentCategories, true, lastConsentTimestamp);
|
|
291
420
|
return remoteConsentCategories;
|
|
292
421
|
}
|
|
293
422
|
} catch {
|