@osano/osano-cmp-react-native 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/lib/commonjs/services/consent.js +91 -28
  2. package/lib/commonjs/services/consent.js.map +1 -1
  3. package/lib/module/services/consent.js +90 -28
  4. package/lib/module/services/consent.js.map +1 -1
  5. package/lib/typescript/lib/commonjs/services/consent.d.ts +1 -0
  6. package/lib/typescript/lib/commonjs/services/consent.d.ts.map +1 -1
  7. package/lib/typescript/lib/module/services/consent.d.ts +1 -0
  8. package/lib/typescript/lib/module/services/consent.d.ts.map +1 -1
  9. package/lib/typescript/src/services/consent.d.ts +10 -4
  10. package/lib/typescript/src/services/consent.d.ts.map +1 -1
  11. package/package.json +17 -9
  12. package/src/services/consent.ts +135 -41
  13. package/lib/typescript/src/iab/gpp/api.d.ts +0 -28
  14. package/lib/typescript/src/iab/gpp/api.d.ts.map +0 -1
  15. package/lib/typescript/src/iab/gpp/consent.d.ts +0 -24
  16. package/lib/typescript/src/iab/gpp/consent.d.ts.map +0 -1
  17. package/lib/typescript/src/iab/gpp/constants.d.ts +0 -37
  18. package/lib/typescript/src/iab/gpp/constants.d.ts.map +0 -1
  19. package/lib/typescript/src/iab/gpp/encoders/AbstractBase64UrlEncoder.d.ts +0 -28
  20. package/lib/typescript/src/iab/gpp/encoders/AbstractBase64UrlEncoder.d.ts.map +0 -1
  21. package/lib/typescript/src/iab/gpp/encoders/BooleanEncoder.d.ts +0 -34
  22. package/lib/typescript/src/iab/gpp/encoders/BooleanEncoder.d.ts.map +0 -1
  23. package/lib/typescript/src/iab/gpp/encoders/CompressedBase64UrlEncoder.d.ts +0 -28
  24. package/lib/typescript/src/iab/gpp/encoders/CompressedBase64UrlEncoder.d.ts.map +0 -1
  25. package/lib/typescript/src/iab/gpp/encoders/DatetimeEncoder.d.ts +0 -28
  26. package/lib/typescript/src/iab/gpp/encoders/DatetimeEncoder.d.ts.map +0 -1
  27. package/lib/typescript/src/iab/gpp/encoders/EncodableOptimizedFixedRange.d.ts +0 -16
  28. package/lib/typescript/src/iab/gpp/encoders/EncodableOptimizedFixedRange.d.ts.map +0 -1
  29. package/lib/typescript/src/iab/gpp/encoders/FibonacciIntegerEncoder.d.ts +0 -28
  30. package/lib/typescript/src/iab/gpp/encoders/FibonacciIntegerEncoder.d.ts.map +0 -1
  31. package/lib/typescript/src/iab/gpp/encoders/FibonacciIntegerRangeEncoder.d.ts +0 -28
  32. package/lib/typescript/src/iab/gpp/encoders/FibonacciIntegerRangeEncoder.d.ts.map +0 -1
  33. package/lib/typescript/src/iab/gpp/encoders/FixedBitfieldEncoder.d.ts +0 -28
  34. package/lib/typescript/src/iab/gpp/encoders/FixedBitfieldEncoder.d.ts.map +0 -1
  35. package/lib/typescript/src/iab/gpp/encoders/FixedIdBitMapEncoder.d.ts +0 -6
  36. package/lib/typescript/src/iab/gpp/encoders/FixedIdBitMapEncoder.d.ts.map +0 -1
  37. package/lib/typescript/src/iab/gpp/encoders/FixedIntegerEncoder.d.ts +0 -28
  38. package/lib/typescript/src/iab/gpp/encoders/FixedIntegerEncoder.d.ts.map +0 -1
  39. package/lib/typescript/src/iab/gpp/encoders/FixedIntegerListEncoder.d.ts +0 -28
  40. package/lib/typescript/src/iab/gpp/encoders/FixedIntegerListEncoder.d.ts.map +0 -1
  41. package/lib/typescript/src/iab/gpp/encoders/FixedIntegerRangeEncoder.d.ts +0 -28
  42. package/lib/typescript/src/iab/gpp/encoders/FixedIntegerRangeEncoder.d.ts.map +0 -1
  43. package/lib/typescript/src/iab/gpp/encoders/FixedStringEncoder.d.ts +0 -26
  44. package/lib/typescript/src/iab/gpp/encoders/FixedStringEncoder.d.ts.map +0 -1
  45. package/lib/typescript/src/iab/gpp/encoders/TraditionalBase64UrlEncoder.d.ts +0 -28
  46. package/lib/typescript/src/iab/gpp/encoders/TraditionalBase64UrlEncoder.d.ts.map +0 -1
  47. package/lib/typescript/src/iab/gpp/encoders/errors.d.ts +0 -19
  48. package/lib/typescript/src/iab/gpp/encoders/errors.d.ts.map +0 -1
  49. package/lib/typescript/src/iab/gpp/encoders/index.d.ts +0 -16
  50. package/lib/typescript/src/iab/gpp/encoders/index.d.ts.map +0 -1
  51. package/lib/typescript/src/iab/gpp/encoders/types.d.ts +0 -5
  52. package/lib/typescript/src/iab/gpp/encoders/types.d.ts.map +0 -1
  53. package/lib/typescript/src/iab/gpp/index.d.ts +0 -10
  54. package/lib/typescript/src/iab/gpp/index.d.ts.map +0 -1
  55. package/lib/typescript/src/iab/gpp/reducer.d.ts +0 -6
  56. package/lib/typescript/src/iab/gpp/reducer.d.ts.map +0 -1
  57. package/lib/typescript/src/iab/gpp/selectors.d.ts +0 -6
  58. package/lib/typescript/src/iab/gpp/selectors.d.ts.map +0 -1
  59. package/lib/typescript/src/iab/gpp/types.d.ts +0 -3
  60. package/lib/typescript/src/iab/gpp/types.d.ts.map +0 -1
  61. package/lib/typescript/src/iab/gpp/v1/constants.d.ts +0 -9
  62. package/lib/typescript/src/iab/gpp/v1/constants.d.ts.map +0 -1
  63. package/lib/typescript/src/iab/gpp/v1/index.d.ts +0 -19
  64. package/lib/typescript/src/iab/gpp/v1/index.d.ts.map +0 -1
  65. package/lib/typescript/src/iab/usp/api.d.ts +0 -4
  66. package/lib/typescript/src/iab/usp/api.d.ts.map +0 -1
  67. package/lib/typescript/src/iab/usp/consent.d.ts +0 -13
  68. package/lib/typescript/src/iab/usp/consent.d.ts.map +0 -1
  69. package/lib/typescript/src/iab/usp/constants.d.ts +0 -77
  70. package/lib/typescript/src/iab/usp/constants.d.ts.map +0 -1
  71. package/lib/typescript/src/iab/usp/index.d.ts +0 -10
  72. package/lib/typescript/src/iab/usp/index.d.ts.map +0 -1
  73. package/lib/typescript/src/iab/usp/reducer.d.ts +0 -13
  74. package/lib/typescript/src/iab/usp/reducer.d.ts.map +0 -1
  75. package/lib/typescript/src/iab/usp/selectors.d.ts +0 -9
  76. package/lib/typescript/src/iab/usp/selectors.d.ts.map +0 -1
  77. package/lib/typescript/src/iab/usp/types.d.ts +0 -5
  78. package/lib/typescript/src/iab/usp/types.d.ts.map +0 -1
  79. package/lib/typescript/src/iab/usp/v1/constants.d.ts +0 -9
  80. package/lib/typescript/src/iab/usp/v1/constants.d.ts.map +0 -1
  81. package/lib/typescript/src/iab/usp/v1/index.d.ts +0 -16
  82. package/lib/typescript/src/iab/usp/v1/index.d.ts.map +0 -1
  83. package/lib/typescript/webdriverio-appium/common/commonCommands.d.ts +0 -21
  84. package/lib/typescript/webdriverio-appium/common/commonCommands.d.ts.map +0 -1
  85. package/lib/typescript/webdriverio-appium/config/wdio.conf.android.d.cts +0 -3
  86. package/lib/typescript/webdriverio-appium/config/wdio.conf.android.d.cts.map +0 -1
  87. package/lib/typescript/webdriverio-appium/config/wdio.conf.d.cts +0 -21
  88. package/lib/typescript/webdriverio-appium/config/wdio.conf.d.cts.map +0 -1
  89. package/lib/typescript/webdriverio-appium/config/wdio.conf.ios.d.cts +0 -3
  90. package/lib/typescript/webdriverio-appium/config/wdio.conf.ios.d.cts.map +0 -1
  91. package/lib/typescript/webdriverio-appium/test/android/six-drawer.d.ts +0 -2
  92. package/lib/typescript/webdriverio-appium/test/android/six-drawer.d.ts.map +0 -1
  93. package/lib/typescript/webdriverio-appium/test/ios/one.d.ts +0 -2
  94. package/lib/typescript/webdriverio-appium/test/ios/one.d.ts.map +0 -1
  95. package/lib/typescript/webdriverio-appium/test/ios/six.d.ts +0 -2
  96. package/lib/typescript/webdriverio-appium/test/ios/six.d.ts.map +0 -1
  97. package/lib/typescript/webdriverio-appium/test/ios/three.d.ts +0 -2
  98. package/lib/typescript/webdriverio-appium/test/ios/three.d.ts.map +0 -1
  99. package/lib/typescript/webdriverio-appium/test/ios/two-iab.d.ts +0 -2
  100. package/lib/typescript/webdriverio-appium/test/ios/two-iab.d.ts.map +0 -1
  101. package/lib/typescript/webdriverio-appium/test/ios/two.d.ts +0 -2
  102. package/lib/typescript/webdriverio-appium/test/ios/two.d.ts.map +0 -1
  103. package/lib/typescript/webdriverio-appium/test/one.d.ts +0 -2
  104. package/lib/typescript/webdriverio-appium/test/one.d.ts.map +0 -1
  105. package/lib/typescript/webdriverio-appium/test/six-iab.d.ts +0 -2
  106. package/lib/typescript/webdriverio-appium/test/six-iab.d.ts.map +0 -1
  107. package/lib/typescript/webdriverio-appium/test/three.d.ts +0 -2
  108. package/lib/typescript/webdriverio-appium/test/three.d.ts.map +0 -1
  109. package/lib/typescript/webdriverio-appium/test/two-iab.d.ts +0 -2
  110. package/lib/typescript/webdriverio-appium/test/two-iab.d.ts.map +0 -1
  111. package/lib/typescript/webdriverio-appium/test/two.d.ts +0 -2
  112. package/lib/typescript/webdriverio-appium/test/two.d.ts.map +0 -1
  113. package/src/iab/gpp/api.js +0 -253
  114. package/src/iab/gpp/consent.js +0 -114
  115. package/src/iab/gpp/constants.js +0 -49
  116. package/src/iab/gpp/encoders/AbstractBase64UrlEncoder.ts +0 -89
  117. package/src/iab/gpp/encoders/BooleanEncoder.ts +0 -39
  118. package/src/iab/gpp/encoders/CompressedBase64UrlEncoder.ts +0 -41
  119. package/src/iab/gpp/encoders/DatetimeEncoder.ts +0 -46
  120. package/src/iab/gpp/encoders/EncodableOptimizedFixedRange.ts +0 -213
  121. package/src/iab/gpp/encoders/FibonacciIntegerEncoder.ts +0 -81
  122. package/src/iab/gpp/encoders/FibonacciIntegerRangeEncoder.ts +0 -122
  123. package/src/iab/gpp/encoders/FixedBitfieldEncoder.ts +0 -59
  124. package/src/iab/gpp/encoders/FixedIdBitMapEncoder.ts +0 -30
  125. package/src/iab/gpp/encoders/FixedIntegerEncoder.ts +0 -61
  126. package/src/iab/gpp/encoders/FixedIntegerListEncoder.ts +0 -87
  127. package/src/iab/gpp/encoders/FixedIntegerRangeEncoder.ts +0 -102
  128. package/src/iab/gpp/encoders/FixedStringEncoder.ts +0 -74
  129. package/src/iab/gpp/encoders/LICENSE-IABTechLab +0 -176
  130. package/src/iab/gpp/encoders/TraditionalBase64UrlEncoder.ts +0 -38
  131. package/src/iab/gpp/encoders/errors.ts +0 -41
  132. package/src/iab/gpp/encoders/index.ts +0 -15
  133. package/src/iab/gpp/encoders/types.ts +0 -5
  134. package/src/iab/gpp/index.js +0 -9
  135. package/src/iab/gpp/reducer.js +0 -7
  136. package/src/iab/gpp/selectors.js +0 -21
  137. package/src/iab/gpp/types.ts +0 -3
  138. package/src/iab/gpp/v1/constants.js +0 -7
  139. package/src/iab/gpp/v1/index.js +0 -73
  140. package/src/iab/usp/api.js +0 -56
  141. package/src/iab/usp/consent.js +0 -150
  142. package/src/iab/usp/constants.js +0 -40
  143. package/src/iab/usp/index.js +0 -9
  144. package/src/iab/usp/reducer.js +0 -107
  145. package/src/iab/usp/selectors.js +0 -31
  146. package/src/iab/usp/types.ts +0 -4
  147. package/src/iab/usp/v1/constants.js +0 -10
  148. package/src/iab/usp/v1/index.js +0 -54
@@ -1,150 +0,0 @@
1
- import { doesCCPAApply, getConsentString, getStore } from './selectors';
2
- import { toBoolFromYesNoUn, toYesNoUnFromBool } from './constants';
3
-
4
- import { merge } from '../../utils';
5
-
6
- export const makeParseConsentString =
7
- ({ version: providedVersion = 1 } = {}) =>
8
- uspString => {
9
- const [version = providedVersion, notified, optOut, signatory] = (
10
- uspString || ''
11
- )
12
- .split('')
13
- .map((value, index) => {
14
- if (index === 0) {
15
- return isNaN(parseInt(value, 10))
16
- ? providedVersion
17
- : parseInt(value, 10);
18
- }
19
- return toBoolFromYesNoUn(value);
20
- });
21
- return {
22
- version,
23
- notified,
24
- signatory,
25
- optOut,
26
- };
27
- };
28
-
29
- export const makeGetField =
30
- (initOptions = {}) =>
31
- (state, field) => {
32
- const [, notified, optOut, signatory] = getConsentString(
33
- state,
34
- initOptions,
35
- ).split('');
36
- // These field names were found in the IAB GPP reference implementation
37
- // README at
38
- // https://github.com/IABTechLab/iabgpp-es/tree/42060d7ac2b6d0ee70fc1b5bcd33fc447bf5123c/modules/cmpapi
39
- switch (field) {
40
- case 'Version':
41
- // This is always going to be 1 until the day this framework is
42
- // removed so it's hardcoded
43
- return 1;
44
- case 'Notice':
45
- return notified;
46
- case 'OptOutSale':
47
- return optOut;
48
- case 'LspaCovered':
49
- return signatory;
50
- }
51
- };
52
-
53
- /**
54
- * USPAPI formatConsentString implementation
55
- * @function
56
- * @param {Object} data
57
- * @returns {string} Properly formatted USPData string
58
- */
59
- export const makeFormatConsentString =
60
- (initOptions = {}) =>
61
- (data, state) => {
62
- const {
63
- version: storeVersion,
64
- notified: storeNotified,
65
- optOut: storeOptOut,
66
- signatory: storeSignatory,
67
- } = makeParseConsentString(initOptions)(
68
- getConsentString(state, initOptions),
69
- );
70
- const {
71
- version = storeVersion,
72
- notified = storeNotified,
73
- optOut = storeOptOut,
74
- signatory = storeSignatory,
75
- } = merge(getStore(state), data);
76
- const consents = [notified, optOut, signatory];
77
- /*
78
- if (version !== storeVersion) {
79
- // TODO: apply logic for future versions
80
- }
81
- */
82
- return doesCCPAApply(state)
83
- ? `${parseInt(version.toString(), 10)}${consents
84
- .map(toYesNoUnFromBool)
85
- .join('')}`
86
- : `${parseInt(version.toString(), 10)}---`;
87
- };
88
-
89
- /**
90
- * USPAPI consentFromOptions implementation
91
- * @function
92
- * @param {Object} data
93
- * @returns {import('./constants').USPConsent} Properly formatted USPConsent object
94
- */
95
- export const makeConsentFromOptions = initOptions => (data, state) => {
96
- const {
97
- version: storeVersion,
98
- notified: storeNotified,
99
- optOut: storeOptOut,
100
- signatory: storeSignatory,
101
- } = makeParseConsentString(initOptions)(getConsentString(state, initOptions));
102
- /*
103
- if (version !== storeVersion) {
104
- // TODO: apply logic for future versions
105
- }
106
- */
107
- // We are going to set defaults if CCPA applies
108
- const {
109
- version = storeVersion,
110
- notified = storeNotified,
111
- optOut = storeOptOut,
112
- signatory = storeSignatory,
113
- } = merge(getStore(state), data);
114
- return doesCCPAApply(state)
115
- ? {
116
- version,
117
- notified,
118
- signatory,
119
- optOut,
120
- }
121
- : { version };
122
- };
123
-
124
- /**
125
- * USPAPI getConsentDataObject implementation
126
- * @function
127
- * @param {number} version
128
- * @returns {import('./constants').USPData} Properly formatted USPData object
129
- */
130
- export const getConsentDataObject = initOptions => state => {
131
- const { version } = initOptions;
132
- switch (version) {
133
- // Supported versions
134
- case 1: {
135
- break;
136
- }
137
-
138
- default: {
139
- throw new Error('Unsupported version');
140
- }
141
- }
142
- const consentString = makeFormatConsentString(initOptions)(
143
- makeConsentFromOptions(initOptions)(undefined, state),
144
- state,
145
- );
146
- return {
147
- version,
148
- uspString: consentString,
149
- };
150
- };
@@ -1,40 +0,0 @@
1
- /**
2
- * USPData object supplied to the __uspapi callback method
3
- * @typedef {Object} USPData
4
- * @property {number} version - indicates the U.S. Privacy spec version
5
- * @property {(number|string)} uspString - Indicates the privacy application and agreement
6
- * - String; agreement: “1YNN”, not applicable: “1---”
7
- * - Number; 1 applies, 0 doesn’t apply, -1 not set
8
- */
9
-
10
- /**
11
- * USPConsent object used for creating the USPData `uspString`
12
- * @typedef {Object} USPConsent
13
- * @property {number} version - indicates the U.S. Privacy spec version
14
- * @property {(Boolean|undefined)} notified - Indicates that the end user has been notified of consent agreement
15
- * @property {Boolean} optOut - Indicates that the end user has opted out of data resale
16
- * @property {(Boolean|undefined)} signatory - Indicates that the provider has opted into the LSPA from IAB
17
- */
18
-
19
- /**
20
- * USPAPIPostMessageData object
21
- * @typedef {Object} USPAPIPostMessageData
22
- * @property {string} command - The command to be executed by the API
23
- * @property {string} parameter - Optional parameter to be passed to the `command`
24
- * @property {number} version - The version number that the response should adhere to
25
- * @property {string} callId - The callback method that should be called with the command result
26
- */
27
-
28
- /**
29
- * USPAPIPostMessageEvent object supplied to the __uspapiLocator iframe postMessage handler
30
- * @typedef {Object} USPAPIPostMessageEvent
31
- * @property {(string|USPAPIPostMessageData)} data - The post message data as object or JSON string
32
- * @property {string} origin - Indicates the origin of the window making the post
33
- * @property {Window} source - The window which posted the message
34
- */
35
-
36
- export const toYesNoUnFromBool = b => (b === undefined ? '-' : b ? 'Y' : 'N');
37
- export const toBoolFromYesNoUn = yn =>
38
- yn === '-' || yn === undefined
39
- ? undefined
40
- : !!((yn || 'N').toUpperCase() === 'Y');
@@ -1,9 +0,0 @@
1
- import reducer from './reducer';
2
- import v1_0 from './v1';
3
-
4
- export default {
5
- reducer,
6
- versions: {
7
- v1_0,
8
- },
9
- };
@@ -1,107 +0,0 @@
1
- import { ACCEPT, OPT_OUT, originalWindow } from '../../constants';
2
- import { getSavedConsent, isGPCSupportEnabled } from '../../redux/selectors';
3
-
4
- import { types as ActionTypes } from '../../redux/actions';
5
- import { genericReducer } from '../../redux/helpers';
6
- import { merge } from '../../utils';
7
-
8
- export const initialState = {
9
- iab: {
10
- usp: {
11
- ccpaApplies: false,
12
- notified: undefined,
13
- signatory: undefined,
14
- optOut: false,
15
- },
16
- },
17
- };
18
-
19
- const updateOptions = (state, options) => {
20
- const { config } = options || {};
21
- // Country code is getting string replaced, so we pull it from the original state
22
- const { config: { jurisdiction: oldJurisdiction } = {} } = state;
23
- // Use a provided jurisdiction and default to the original
24
- const { jurisdiction = oldJurisdiction } = config || {};
25
- const {
26
- ccpaApplies: providedCCPA = `${jurisdiction || ''}`
27
- .toLowerCase()
28
- .substring(0, 2) === 'us',
29
- } = config || {};
30
-
31
- const newState = merge(
32
- { ...state },
33
- {
34
- iab: {
35
- usp: {
36
- ccpaApplies: providedCCPA,
37
- },
38
- },
39
- },
40
- );
41
-
42
- return newState;
43
- };
44
-
45
- const formatOptOut = (state, acceptOrDeny) => {
46
- return isGPCSupportEnabled(state)
47
- ? !!originalWindow.navigator.globalPrivacyControl
48
- : acceptOrDeny === ACCEPT || acceptOrDeny === true;
49
- };
50
-
51
- export default genericReducer(initialState, {
52
- [ActionTypes.init]: updateOptions,
53
- [ActionTypes.updateConfig]: (state, config) =>
54
- updateOptions(state, { config }),
55
- [ActionTypes.setConsent]: (state, { category, acceptOrDeny }) => {
56
- if (typeof category === 'object' && category[`${OPT_OUT}`]) {
57
- // Only populate the consent items we are using
58
- return merge(
59
- { ...state },
60
- {
61
- iab: { usp: { optOut: formatOptOut(state, category[`${OPT_OUT}`]) } },
62
- },
63
- );
64
- } else if (typeof category === 'string' && category === OPT_OUT) {
65
- return merge(
66
- {
67
- ...state,
68
- },
69
- {
70
- iab: { usp: { optOut: formatOptOut(state, acceptOrDeny) } },
71
- },
72
- );
73
- }
74
- return state;
75
- },
76
- [ActionTypes.revertConsent]: state => {
77
- const { [OPT_OUT]: optOut } = getSavedConsent(state) || {};
78
- return merge(
79
- {
80
- ...state,
81
- },
82
- {
83
- iab: { usp: { optOut: formatOptOut(state, optOut) } },
84
- },
85
- );
86
- },
87
- [ActionTypes.acceptAllConsent]: state =>
88
- merge(
89
- {
90
- ...state,
91
- },
92
- {
93
- // Must be opposite because accepting is denying optOut
94
- iab: { usp: { optOut: formatOptOut(state, false) } },
95
- },
96
- ),
97
- [ActionTypes.denyAllConsent]: state =>
98
- merge(
99
- {
100
- ...state,
101
- },
102
- {
103
- // Must be opposite because denying is accepting optOut
104
- iab: { usp: { optOut: formatOptOut(state, true) } },
105
- },
106
- ),
107
- });
@@ -1,31 +0,0 @@
1
- import { get } from '../../utils';
2
- import { isBrowsingFromUS } from '../../redux/selectors';
3
- import { toYesNoUnFromBool } from './constants';
4
-
5
- export const DOMAIN = 'iab.usp';
6
-
7
- export const getStore = state => get(state, DOMAIN, {});
8
- export const doesCCPAApply = state =>
9
- !!get(state, 'iab.usp.ccpaApplies', isBrowsingFromUS(state));
10
-
11
- export const getConsentString = (
12
- state,
13
- { gppSection, version: providedVersion } = {},
14
- ) => {
15
- const savedString = get(state, ['iab', 'consentStrings', gppSection]);
16
- if (savedString) {
17
- return savedString;
18
- }
19
- const { notified, signatory, optOut } = getStore(state);
20
- const consents = [notified, optOut, signatory];
21
- const version = isNaN(parseInt(providedVersion, 10))
22
- ? 1
23
- : parseInt(providedVersion, 10);
24
-
25
- return doesCCPAApply(state)
26
- ? `${parseInt(version.toString(), 10)}${consents
27
- .map(toYesNoUnFromBool)
28
- .join('')}`
29
- : `${parseInt(version.toString(), 10)}---`;
30
- };
31
- export const getOptOut = state => getStore(state).optOut;
@@ -1,4 +0,0 @@
1
- export type Usp = {
2
- enabled: boolean;
3
- ccpaApplies: boolean;
4
- };
@@ -1,10 +0,0 @@
1
- export const apiName = '__uspapi';
2
- // gppSection is the key in redux state that stores the consent string.
3
- export const gppSection = 'uspv1';
4
- export const iframeName = '__uspapiLocator';
5
- export const version = 1;
6
-
7
- export const initOptions = {
8
- gppSection,
9
- version,
10
- };
@@ -1,54 +0,0 @@
1
- import { ACCEPT, DENY, OPT_OUT } from '../../../constants';
2
- import { apiName, gppSection, iframeName, initOptions } from './constants';
3
- import { makeConsentFromOptions, makeFormatConsentString } from '../consent';
4
-
5
- import { types as ActionTypes } from '../../../redux/actions';
6
- import { getConsent } from '../../../redux/selectors';
7
- import makeApi from '../api';
8
- import postMessageEventHandler from '../../iframe';
9
- import { setConsentData } from '../../actions';
10
-
11
- const consentFromOptions = makeConsentFromOptions(initOptions);
12
- const formatConsentString = makeFormatConsentString(initOptions);
13
-
14
- function createMiddleware() {
15
- return store => next => action => {
16
- const result = next(action);
17
- const { type } = action;
18
- const state = store.getState();
19
- switch (type) {
20
- case ActionTypes.saveConsent: {
21
- const { [OPT_OUT]: optOut } = getConsent(state);
22
- const consentString = formatConsentString(
23
- consentFromOptions(
24
- { optOut: optOut === ACCEPT ? true : false },
25
- state,
26
- ),
27
- state,
28
- );
29
- store.dispatch(setConsentData(gppSection, consentString));
30
- break;
31
- }
32
- case ActionTypes.clearConsent: {
33
- const consentString = formatConsentString(
34
- consentFromOptions({ optOut: DENY }, state),
35
- state,
36
- );
37
- store.dispatch(setConsentData(gppSection, consentString));
38
- break;
39
- }
40
- }
41
- return result;
42
- };
43
- }
44
-
45
- const v1 = {
46
- api: makeApi(initOptions),
47
- apiName,
48
- createMiddleware,
49
- gppSection,
50
- iframeName,
51
- postMessageEventHandler: postMessageEventHandler(apiName, true),
52
- };
53
-
54
- export default v1;