@osano/osano-cmp-react-native 0.9.0 → 0.11.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 (317) hide show
  1. package/lib/commonjs/components/Button.js +27 -12
  2. package/lib/commonjs/components/Button.js.map +1 -1
  3. package/lib/commonjs/locale/af.json +324 -321
  4. package/lib/commonjs/locale/ar.json +324 -321
  5. package/lib/commonjs/locale/bg.json +324 -321
  6. package/lib/commonjs/locale/ca.json +324 -321
  7. package/lib/commonjs/locale/cs.json +324 -321
  8. package/lib/commonjs/locale/da.json +324 -321
  9. package/lib/commonjs/locale/de-at.json +324 -321
  10. package/lib/commonjs/locale/de.json +324 -321
  11. package/lib/commonjs/locale/el.json +324 -321
  12. package/lib/commonjs/locale/en-au.json +324 -321
  13. package/lib/commonjs/locale/en-ca.json +324 -321
  14. package/lib/commonjs/locale/en-gb.json +324 -321
  15. package/lib/commonjs/locale/en.json +324 -321
  16. package/lib/commonjs/locale/es-mx.json +324 -321
  17. package/lib/commonjs/locale/es.json +324 -321
  18. package/lib/commonjs/locale/et.json +324 -321
  19. package/lib/commonjs/locale/fa.json +324 -321
  20. package/lib/commonjs/locale/fi.json +324 -321
  21. package/lib/commonjs/locale/fr-ca.json +324 -321
  22. package/lib/commonjs/locale/fr.json +324 -321
  23. package/lib/commonjs/locale/gd.json +324 -321
  24. package/lib/commonjs/locale/he.json +324 -321
  25. package/lib/commonjs/locale/hi.json +324 -321
  26. package/lib/commonjs/locale/hr.json +324 -321
  27. package/lib/commonjs/locale/hu.json +324 -321
  28. package/lib/commonjs/locale/hy.json +324 -321
  29. package/lib/commonjs/locale/id.json +324 -321
  30. package/lib/commonjs/locale/is.json +324 -321
  31. package/lib/commonjs/locale/it.json +324 -321
  32. package/lib/commonjs/locale/ja.json +324 -321
  33. package/lib/commonjs/locale/kk.json +324 -321
  34. package/lib/commonjs/locale/ko.json +324 -321
  35. package/lib/commonjs/locale/lt.json +324 -321
  36. package/lib/commonjs/locale/lv.json +324 -321
  37. package/lib/commonjs/locale/mi.json +324 -321
  38. package/lib/commonjs/locale/ms.json +324 -321
  39. package/lib/commonjs/locale/nb.json +324 -321
  40. package/lib/commonjs/locale/nl-be.json +324 -321
  41. package/lib/commonjs/locale/nl.json +324 -321
  42. package/lib/commonjs/locale/nn.json +324 -321
  43. package/lib/commonjs/locale/no.json +324 -321
  44. package/lib/commonjs/locale/pl.json +324 -321
  45. package/lib/commonjs/locale/pt-br.json +324 -321
  46. package/lib/commonjs/locale/pt.json +324 -321
  47. package/lib/commonjs/locale/ro.json +324 -321
  48. package/lib/commonjs/locale/ru.json +324 -321
  49. package/lib/commonjs/locale/sk.json +324 -321
  50. package/lib/commonjs/locale/sl.json +324 -321
  51. package/lib/commonjs/locale/sq.json +324 -321
  52. package/lib/commonjs/locale/sr.json +324 -321
  53. package/lib/commonjs/locale/sv.json +324 -321
  54. package/lib/commonjs/locale/th.json +324 -321
  55. package/lib/commonjs/locale/tl.json +324 -321
  56. package/lib/commonjs/locale/tr.json +324 -321
  57. package/lib/commonjs/locale/uk.json +324 -321
  58. package/lib/commonjs/locale/vi.json +324 -321
  59. package/lib/commonjs/locale/zh-hk.json +324 -321
  60. package/lib/commonjs/locale/zh-tw.json +324 -321
  61. package/lib/commonjs/locale/zh.json +324 -321
  62. package/lib/commonjs/locale/zu.json +324 -321
  63. package/lib/commonjs/views/Dialog/Message.js +2 -2
  64. package/lib/commonjs/views/Dialog/Message.js.map +1 -1
  65. package/lib/commonjs/views/Dialog/index.js +1 -0
  66. package/lib/commonjs/views/Dialog/index.js.map +1 -1
  67. package/lib/commonjs/views/Drawer/index.js +1 -0
  68. package/lib/commonjs/views/Drawer/index.js.map +1 -1
  69. package/lib/module/components/Button.js +27 -12
  70. package/lib/module/components/Button.js.map +1 -1
  71. package/lib/module/locale/af.json +324 -321
  72. package/lib/module/locale/ar.json +324 -321
  73. package/lib/module/locale/bg.json +324 -321
  74. package/lib/module/locale/ca.json +324 -321
  75. package/lib/module/locale/cs.json +324 -321
  76. package/lib/module/locale/da.json +324 -321
  77. package/lib/module/locale/de-at.json +324 -321
  78. package/lib/module/locale/de.json +324 -321
  79. package/lib/module/locale/el.json +324 -321
  80. package/lib/module/locale/en-au.json +324 -321
  81. package/lib/module/locale/en-ca.json +324 -321
  82. package/lib/module/locale/en-gb.json +324 -321
  83. package/lib/module/locale/en.json +324 -321
  84. package/lib/module/locale/es-mx.json +324 -321
  85. package/lib/module/locale/es.json +324 -321
  86. package/lib/module/locale/et.json +324 -321
  87. package/lib/module/locale/fa.json +324 -321
  88. package/lib/module/locale/fi.json +324 -321
  89. package/lib/module/locale/fr-ca.json +324 -321
  90. package/lib/module/locale/fr.json +324 -321
  91. package/lib/module/locale/gd.json +324 -321
  92. package/lib/module/locale/he.json +324 -321
  93. package/lib/module/locale/hi.json +324 -321
  94. package/lib/module/locale/hr.json +324 -321
  95. package/lib/module/locale/hu.json +324 -321
  96. package/lib/module/locale/hy.json +324 -321
  97. package/lib/module/locale/id.json +324 -321
  98. package/lib/module/locale/is.json +324 -321
  99. package/lib/module/locale/it.json +324 -321
  100. package/lib/module/locale/ja.json +324 -321
  101. package/lib/module/locale/kk.json +324 -321
  102. package/lib/module/locale/ko.json +324 -321
  103. package/lib/module/locale/lt.json +324 -321
  104. package/lib/module/locale/lv.json +324 -321
  105. package/lib/module/locale/mi.json +324 -321
  106. package/lib/module/locale/ms.json +324 -321
  107. package/lib/module/locale/nb.json +324 -321
  108. package/lib/module/locale/nl-be.json +324 -321
  109. package/lib/module/locale/nl.json +324 -321
  110. package/lib/module/locale/nn.json +324 -321
  111. package/lib/module/locale/no.json +324 -321
  112. package/lib/module/locale/pl.json +324 -321
  113. package/lib/module/locale/pt-br.json +324 -321
  114. package/lib/module/locale/pt.json +324 -321
  115. package/lib/module/locale/ro.json +324 -321
  116. package/lib/module/locale/ru.json +324 -321
  117. package/lib/module/locale/sk.json +324 -321
  118. package/lib/module/locale/sl.json +324 -321
  119. package/lib/module/locale/sq.json +324 -321
  120. package/lib/module/locale/sr.json +324 -321
  121. package/lib/module/locale/sv.json +324 -321
  122. package/lib/module/locale/th.json +324 -321
  123. package/lib/module/locale/tl.json +324 -321
  124. package/lib/module/locale/tr.json +324 -321
  125. package/lib/module/locale/uk.json +324 -321
  126. package/lib/module/locale/vi.json +324 -321
  127. package/lib/module/locale/zh-hk.json +324 -321
  128. package/lib/module/locale/zh-tw.json +324 -321
  129. package/lib/module/locale/zh.json +324 -321
  130. package/lib/module/locale/zu.json +324 -321
  131. package/lib/module/views/Dialog/Message.js +2 -2
  132. package/lib/module/views/Dialog/Message.js.map +1 -1
  133. package/lib/module/views/Dialog/index.js +1 -0
  134. package/lib/module/views/Dialog/index.js.map +1 -1
  135. package/lib/module/views/Drawer/index.js +1 -0
  136. package/lib/module/views/Drawer/index.js.map +1 -1
  137. package/lib/typescript/lib/commonjs/components/Button.d.ts.map +1 -1
  138. package/lib/typescript/lib/commonjs/views/Dialog/index.d.ts.map +1 -1
  139. package/lib/typescript/lib/commonjs/views/Drawer/index.d.ts.map +1 -1
  140. package/lib/typescript/lib/module/components/Button.d.ts.map +1 -1
  141. package/lib/typescript/lib/module/views/Dialog/index.d.ts.map +1 -1
  142. package/lib/typescript/lib/module/views/Drawer/index.d.ts.map +1 -1
  143. package/lib/typescript/src/components/Button.d.ts.map +1 -1
  144. package/lib/typescript/src/iab/gpp/api.d.ts +28 -0
  145. package/lib/typescript/src/iab/gpp/api.d.ts.map +1 -0
  146. package/lib/typescript/src/iab/gpp/consent.d.ts +24 -0
  147. package/lib/typescript/src/iab/gpp/consent.d.ts.map +1 -0
  148. package/lib/typescript/src/iab/gpp/constants.d.ts +37 -0
  149. package/lib/typescript/src/iab/gpp/constants.d.ts.map +1 -0
  150. package/lib/typescript/src/iab/gpp/encoders/AbstractBase64UrlEncoder.d.ts +28 -0
  151. package/lib/typescript/src/iab/gpp/encoders/AbstractBase64UrlEncoder.d.ts.map +1 -0
  152. package/lib/typescript/src/iab/gpp/encoders/BooleanEncoder.d.ts +34 -0
  153. package/lib/typescript/src/iab/gpp/encoders/BooleanEncoder.d.ts.map +1 -0
  154. package/lib/typescript/src/iab/gpp/encoders/CompressedBase64UrlEncoder.d.ts +28 -0
  155. package/lib/typescript/src/iab/gpp/encoders/CompressedBase64UrlEncoder.d.ts.map +1 -0
  156. package/lib/typescript/src/iab/gpp/encoders/DatetimeEncoder.d.ts +28 -0
  157. package/lib/typescript/src/iab/gpp/encoders/DatetimeEncoder.d.ts.map +1 -0
  158. package/lib/typescript/src/iab/gpp/encoders/EncodableOptimizedFixedRange.d.ts +16 -0
  159. package/lib/typescript/src/iab/gpp/encoders/EncodableOptimizedFixedRange.d.ts.map +1 -0
  160. package/lib/typescript/src/iab/gpp/encoders/FibonacciIntegerEncoder.d.ts +28 -0
  161. package/lib/typescript/src/iab/gpp/encoders/FibonacciIntegerEncoder.d.ts.map +1 -0
  162. package/lib/typescript/src/iab/gpp/encoders/FibonacciIntegerRangeEncoder.d.ts +28 -0
  163. package/lib/typescript/src/iab/gpp/encoders/FibonacciIntegerRangeEncoder.d.ts.map +1 -0
  164. package/lib/typescript/src/iab/gpp/encoders/FixedBitfieldEncoder.d.ts +28 -0
  165. package/lib/typescript/src/iab/gpp/encoders/FixedBitfieldEncoder.d.ts.map +1 -0
  166. package/lib/typescript/src/iab/gpp/encoders/FixedIdBitMapEncoder.d.ts +6 -0
  167. package/lib/typescript/src/iab/gpp/encoders/FixedIdBitMapEncoder.d.ts.map +1 -0
  168. package/lib/typescript/src/iab/gpp/encoders/FixedIntegerEncoder.d.ts +28 -0
  169. package/lib/typescript/src/iab/gpp/encoders/FixedIntegerEncoder.d.ts.map +1 -0
  170. package/lib/typescript/src/iab/gpp/encoders/FixedIntegerListEncoder.d.ts +28 -0
  171. package/lib/typescript/src/iab/gpp/encoders/FixedIntegerListEncoder.d.ts.map +1 -0
  172. package/lib/typescript/src/iab/gpp/encoders/FixedIntegerRangeEncoder.d.ts +28 -0
  173. package/lib/typescript/src/iab/gpp/encoders/FixedIntegerRangeEncoder.d.ts.map +1 -0
  174. package/lib/typescript/src/iab/gpp/encoders/FixedStringEncoder.d.ts +26 -0
  175. package/lib/typescript/src/iab/gpp/encoders/FixedStringEncoder.d.ts.map +1 -0
  176. package/lib/typescript/src/iab/gpp/encoders/TraditionalBase64UrlEncoder.d.ts +28 -0
  177. package/lib/typescript/src/iab/gpp/encoders/TraditionalBase64UrlEncoder.d.ts.map +1 -0
  178. package/lib/typescript/src/iab/gpp/encoders/errors.d.ts +19 -0
  179. package/lib/typescript/src/iab/gpp/encoders/errors.d.ts.map +1 -0
  180. package/lib/typescript/src/iab/gpp/encoders/index.d.ts +16 -0
  181. package/lib/typescript/src/iab/gpp/encoders/index.d.ts.map +1 -0
  182. package/lib/typescript/src/iab/gpp/encoders/types.d.ts +5 -0
  183. package/lib/typescript/src/iab/gpp/encoders/types.d.ts.map +1 -0
  184. package/lib/typescript/src/iab/gpp/index.d.ts +10 -0
  185. package/lib/typescript/src/iab/gpp/index.d.ts.map +1 -0
  186. package/lib/typescript/src/iab/gpp/reducer.d.ts +6 -0
  187. package/lib/typescript/src/iab/gpp/reducer.d.ts.map +1 -0
  188. package/lib/typescript/src/iab/gpp/selectors.d.ts +6 -0
  189. package/lib/typescript/src/iab/gpp/selectors.d.ts.map +1 -0
  190. package/lib/typescript/src/iab/gpp/types.d.ts +3 -0
  191. package/lib/typescript/src/iab/gpp/types.d.ts.map +1 -0
  192. package/lib/typescript/src/iab/gpp/v1/constants.d.ts +9 -0
  193. package/lib/typescript/src/iab/gpp/v1/constants.d.ts.map +1 -0
  194. package/lib/typescript/src/iab/gpp/v1/index.d.ts +19 -0
  195. package/lib/typescript/src/iab/gpp/v1/index.d.ts.map +1 -0
  196. package/lib/typescript/src/iab/usp/api.d.ts +4 -0
  197. package/lib/typescript/src/iab/usp/api.d.ts.map +1 -0
  198. package/lib/typescript/src/iab/usp/consent.d.ts +13 -0
  199. package/lib/typescript/src/iab/usp/consent.d.ts.map +1 -0
  200. package/lib/typescript/src/iab/usp/constants.d.ts +77 -0
  201. package/lib/typescript/src/iab/usp/constants.d.ts.map +1 -0
  202. package/lib/typescript/src/iab/usp/index.d.ts +10 -0
  203. package/lib/typescript/src/iab/usp/index.d.ts.map +1 -0
  204. package/lib/typescript/src/iab/usp/reducer.d.ts +13 -0
  205. package/lib/typescript/src/iab/usp/reducer.d.ts.map +1 -0
  206. package/lib/typescript/src/iab/usp/selectors.d.ts +9 -0
  207. package/lib/typescript/src/iab/usp/selectors.d.ts.map +1 -0
  208. package/lib/typescript/src/iab/usp/types.d.ts +5 -0
  209. package/lib/typescript/src/iab/usp/types.d.ts.map +1 -0
  210. package/lib/typescript/src/iab/usp/v1/constants.d.ts +9 -0
  211. package/lib/typescript/src/iab/usp/v1/constants.d.ts.map +1 -0
  212. package/lib/typescript/src/iab/usp/v1/index.d.ts +16 -0
  213. package/lib/typescript/src/iab/usp/v1/index.d.ts.map +1 -0
  214. package/lib/typescript/src/views/Dialog/Message.d.ts.map +1 -1
  215. package/lib/typescript/src/views/Dialog/index.d.ts.map +1 -1
  216. package/lib/typescript/src/views/Drawer/index.d.ts.map +1 -1
  217. package/package.json +2 -6
  218. package/src/components/Button.tsx +22 -12
  219. package/src/iab/gpp/api.js +253 -0
  220. package/src/iab/gpp/consent.js +114 -0
  221. package/src/iab/gpp/constants.js +49 -0
  222. package/src/iab/gpp/encoders/AbstractBase64UrlEncoder.ts +89 -0
  223. package/src/iab/gpp/encoders/BooleanEncoder.ts +39 -0
  224. package/src/iab/gpp/encoders/CompressedBase64UrlEncoder.ts +41 -0
  225. package/src/iab/gpp/encoders/DatetimeEncoder.ts +46 -0
  226. package/src/iab/gpp/encoders/EncodableOptimizedFixedRange.ts +213 -0
  227. package/src/iab/gpp/encoders/FibonacciIntegerEncoder.ts +81 -0
  228. package/src/iab/gpp/encoders/FibonacciIntegerRangeEncoder.ts +122 -0
  229. package/src/iab/gpp/encoders/FixedBitfieldEncoder.ts +59 -0
  230. package/src/iab/gpp/encoders/FixedIdBitMapEncoder.ts +30 -0
  231. package/src/iab/gpp/encoders/FixedIntegerEncoder.ts +61 -0
  232. package/src/iab/gpp/encoders/FixedIntegerListEncoder.ts +87 -0
  233. package/src/iab/gpp/encoders/FixedIntegerRangeEncoder.ts +102 -0
  234. package/src/iab/gpp/encoders/FixedStringEncoder.ts +74 -0
  235. package/src/iab/gpp/encoders/LICENSE-IABTechLab +176 -0
  236. package/src/iab/gpp/encoders/TraditionalBase64UrlEncoder.ts +38 -0
  237. package/src/iab/gpp/encoders/errors.ts +41 -0
  238. package/src/iab/gpp/encoders/index.ts +15 -0
  239. package/src/iab/gpp/encoders/types.ts +5 -0
  240. package/src/iab/gpp/index.js +9 -0
  241. package/src/iab/gpp/reducer.js +7 -0
  242. package/src/iab/gpp/selectors.js +21 -0
  243. package/src/iab/gpp/types.ts +3 -0
  244. package/src/iab/gpp/v1/constants.js +7 -0
  245. package/src/iab/gpp/v1/index.js +73 -0
  246. package/src/iab/usp/api.js +56 -0
  247. package/src/iab/usp/consent.js +150 -0
  248. package/src/iab/usp/constants.js +40 -0
  249. package/src/iab/usp/index.js +9 -0
  250. package/src/iab/usp/reducer.js +107 -0
  251. package/src/iab/usp/selectors.js +31 -0
  252. package/src/iab/usp/types.ts +4 -0
  253. package/src/iab/usp/v1/constants.js +10 -0
  254. package/src/iab/usp/v1/index.js +54 -0
  255. package/src/locale/af.json +324 -321
  256. package/src/locale/ar.json +324 -321
  257. package/src/locale/bg.json +324 -321
  258. package/src/locale/ca.json +324 -321
  259. package/src/locale/cs.json +324 -321
  260. package/src/locale/da.json +324 -321
  261. package/src/locale/de-at.json +324 -321
  262. package/src/locale/de.json +324 -321
  263. package/src/locale/el.json +324 -321
  264. package/src/locale/en-au.json +324 -321
  265. package/src/locale/en-ca.json +324 -321
  266. package/src/locale/en-gb.json +324 -321
  267. package/src/locale/en.json +324 -321
  268. package/src/locale/es-mx.json +324 -321
  269. package/src/locale/es.json +324 -321
  270. package/src/locale/et.json +324 -321
  271. package/src/locale/fa.json +324 -321
  272. package/src/locale/fi.json +324 -321
  273. package/src/locale/fr-ca.json +324 -321
  274. package/src/locale/fr.json +324 -321
  275. package/src/locale/gd.json +324 -321
  276. package/src/locale/he.json +324 -321
  277. package/src/locale/hi.json +324 -321
  278. package/src/locale/hr.json +324 -321
  279. package/src/locale/hu.json +324 -321
  280. package/src/locale/hy.json +324 -321
  281. package/src/locale/id.json +324 -321
  282. package/src/locale/is.json +324 -321
  283. package/src/locale/it.json +324 -321
  284. package/src/locale/ja.json +324 -321
  285. package/src/locale/kk.json +324 -321
  286. package/src/locale/ko.json +324 -321
  287. package/src/locale/lt.json +324 -321
  288. package/src/locale/lv.json +324 -321
  289. package/src/locale/mi.json +324 -321
  290. package/src/locale/ms.json +324 -321
  291. package/src/locale/nb.json +324 -321
  292. package/src/locale/nl-be.json +324 -321
  293. package/src/locale/nl.json +324 -321
  294. package/src/locale/nn.json +324 -321
  295. package/src/locale/no.json +324 -321
  296. package/src/locale/pl.json +324 -321
  297. package/src/locale/pt-br.json +324 -321
  298. package/src/locale/pt.json +324 -321
  299. package/src/locale/ro.json +324 -321
  300. package/src/locale/ru.json +324 -321
  301. package/src/locale/sk.json +324 -321
  302. package/src/locale/sl.json +324 -321
  303. package/src/locale/sq.json +324 -321
  304. package/src/locale/sr.json +324 -321
  305. package/src/locale/sv.json +324 -321
  306. package/src/locale/th.json +324 -321
  307. package/src/locale/tl.json +324 -321
  308. package/src/locale/tr.json +324 -321
  309. package/src/locale/uk.json +324 -321
  310. package/src/locale/vi.json +324 -321
  311. package/src/locale/zh-hk.json +324 -321
  312. package/src/locale/zh-tw.json +324 -321
  313. package/src/locale/zh.json +324 -321
  314. package/src/locale/zu.json +324 -321
  315. package/src/views/Dialog/Message.tsx +2 -1
  316. package/src/views/Dialog/index.tsx +1 -0
  317. package/src/views/Drawer/index.tsx +1 -0
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Adapted from IABTechLab's GPP JavaScript Reference Implementation
3
+ *
4
+ * https://github.com/IABTechLab/iabgpp-es/blob/42060d7ac2b6d0ee70fc1b5bcd33fc447bf5123c/modules/cmpapi/src/encoder/datatype/encoder/FixedIntegerRangeEncoder.ts
5
+ *
6
+ * @license
7
+ * Copyright 2023 IABTechLab
8
+ *
9
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
10
+ * use this file except in compliance with the License. You may obtain a copy of
11
+ * the License at
12
+ *
13
+ * http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18
+ * License for the specific language governing permissions and limitations under
19
+ * the License.
20
+ */
21
+
22
+ import {
23
+ decode as intDecode,
24
+ encode as intEncode,
25
+ } from './FixedIntegerEncoder';
26
+
27
+ import { InvalidBitStringError } from './errors';
28
+ import { decode as boolDecode } from './BooleanEncoder';
29
+
30
+ export const encode = (value: number[]) => {
31
+ value.sort((n1, n2) => n1 - n2);
32
+
33
+ const groups = [];
34
+
35
+ let groupStartIndex = 0;
36
+ while (groupStartIndex < value.length) {
37
+ let groupEndIndex = groupStartIndex;
38
+ while (
39
+ groupEndIndex < value.length - 1 &&
40
+ value[groupEndIndex]! + 1 === value[groupEndIndex + 1]
41
+ ) {
42
+ groupEndIndex++;
43
+ }
44
+
45
+ groups.push(value.slice(groupStartIndex, groupEndIndex + 1));
46
+
47
+ groupStartIndex = groupEndIndex + 1;
48
+ }
49
+
50
+ let bitString = intEncode(groups.length, 12);
51
+ for (let i = 0; i < groups.length; i++) {
52
+ const group = groups[i]!;
53
+ if (group.length > 0) {
54
+ if (group.length === 1) {
55
+ bitString += '0' + intEncode(group[0]!, 16);
56
+ } else {
57
+ bitString +=
58
+ '1' +
59
+ intEncode(group[0]!, 16) +
60
+ intEncode(group[group.length - 1]!, 16);
61
+ }
62
+ }
63
+ }
64
+ return bitString;
65
+ };
66
+
67
+ export const decode = (bitString: string) => {
68
+ if (!/^[01]{12,}$/.test(bitString)) {
69
+ throw new InvalidBitStringError(bitString);
70
+ }
71
+
72
+ const value = [];
73
+ const count = intDecode(bitString.substring(0, 12));
74
+ let startIndex = 12;
75
+ for (let i = 0; i < count; i++) {
76
+ const group = boolDecode(bitString.substring(startIndex, startIndex + 1));
77
+ startIndex++;
78
+
79
+ if (group === true) {
80
+ const start = intDecode(bitString.substring(startIndex, startIndex + 16));
81
+ startIndex += 16;
82
+
83
+ const end = intDecode(bitString.substring(startIndex, startIndex + 16));
84
+ startIndex += 16;
85
+
86
+ for (let j = start; j <= end; j++) {
87
+ value.push(j);
88
+ }
89
+ } else {
90
+ const val = intDecode(bitString.substring(startIndex, startIndex + 16));
91
+ value.push(val);
92
+ startIndex += 16;
93
+ }
94
+ }
95
+
96
+ return value;
97
+ };
98
+
99
+ export default {
100
+ decode,
101
+ encode,
102
+ };
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Adapted from IABTechLab's GPP JavaScript Reference Implementation
3
+ *
4
+ * https://github.com/IABTechLab/iabgpp-es/blob/42060d7ac2b6d0ee70fc1b5bcd33fc447bf5123c/modules/cmpapi/src/encoder/datatype/encoder/FixedStringEncoder.ts
5
+ *
6
+ * @license
7
+ * Copyright 2023 IABTechLab
8
+ *
9
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
10
+ * use this file except in compliance with the License. You may obtain a copy of
11
+ * the License at
12
+ *
13
+ * http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18
+ * License for the specific language governing permissions and limitations under
19
+ * the License.
20
+ */
21
+
22
+ import { InvalidBitStringError, InvalidStringCharacterError } from './errors';
23
+ import {
24
+ decode as intDecode,
25
+ encode as intEncode,
26
+ } from './FixedIntegerEncoder';
27
+ import type { Codable } from './types';
28
+
29
+ export const encode = (value: string, stringLength: number) => {
30
+ // String.prototype.padEnd causes CoreJS to include a polyfill for it.
31
+ value =
32
+ value.length >= stringLength
33
+ ? value
34
+ : value + ' '.repeat(stringLength - value.length);
35
+
36
+ let bitString = '';
37
+ for (let i = 0; i < value.length; i++) {
38
+ const code = value.charCodeAt(i);
39
+ if (code === 32) {
40
+ // space
41
+ bitString += intEncode(63, 6);
42
+ } else if (code >= 65) {
43
+ bitString += intEncode(value.charCodeAt(i) - 65, 6);
44
+ } else {
45
+ throw new InvalidStringCharacterError(value);
46
+ }
47
+ }
48
+
49
+ return bitString;
50
+ };
51
+
52
+ export const decode = (bitString: string) => {
53
+ if (!/^[01]*$/.test(bitString) || bitString.length % 6 !== 0) {
54
+ throw new InvalidBitStringError(bitString);
55
+ }
56
+
57
+ let value = '';
58
+
59
+ for (let i = 0; i < bitString.length; i += 6) {
60
+ const code = intDecode(bitString.substring(i, i + 6));
61
+ if (code === 63) {
62
+ value += ' ';
63
+ } else {
64
+ value += String.fromCharCode(code + 65);
65
+ }
66
+ }
67
+
68
+ return value.trim();
69
+ };
70
+
71
+ export default {
72
+ decode,
73
+ encode,
74
+ } as Codable;
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Adapted from IABTechLab's GPP JavaScript Reference Implementation
3
+ *
4
+ * https://github.com/IABTechLab/iabgpp-es/blob/42060d7ac2b6d0ee70fc1b5bcd33fc447bf5123c/modules/cmpapi/src/encoder/datatype/encoder/TraditionalBase64UrlEncoder.ts
5
+ *
6
+ * @license
7
+ * Copyright 2023 IABTechLab
8
+ *
9
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
10
+ * use this file except in compliance with the License. You may obtain a copy of
11
+ * the License at
12
+ *
13
+ * http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18
+ * License for the specific language governing permissions and limitations under
19
+ * the License.
20
+ */
21
+
22
+ import { decode, makeEncode } from './AbstractBase64UrlEncoder';
23
+
24
+ const pad = (bitString: string) => {
25
+ while (bitString.length % 24 > 0) {
26
+ bitString += '0';
27
+ }
28
+ return bitString;
29
+ };
30
+
31
+ export const encode = makeEncode(pad);
32
+
33
+ export { decode } from './AbstractBase64UrlEncoder';
34
+
35
+ export default {
36
+ decode,
37
+ encode,
38
+ };
@@ -0,0 +1,41 @@
1
+ export class InvalidBitStringError extends Error {
2
+ constructor(value: string | undefined) {
3
+ super(value);
4
+ this.name = 'InvalidBitStringError';
5
+ }
6
+ }
7
+
8
+ export class InvalidBase64UrlError extends Error {
9
+ constructor(value: string | undefined) {
10
+ super(value);
11
+ this.name = 'InvalidBase64UrlError';
12
+ }
13
+ }
14
+
15
+ export class InvalidSizeError extends Error {
16
+ constructor(value: number, bits: number) {
17
+ super(`Value ${value} does not fit in ${bits} bits`);
18
+ this.name = 'InvalidSizeError';
19
+ }
20
+ }
21
+
22
+ export class BitStringParametersMatchError extends Error {
23
+ constructor(
24
+ bitString: string,
25
+ parameters: { elementBitStringLength: number; numElements: number },
26
+ ) {
27
+ super(
28
+ `'${bitString}' does not match given parameters ${JSON.stringify(
29
+ parameters,
30
+ )}`,
31
+ );
32
+ this.name = 'BitStringParameterMatchError';
33
+ }
34
+ }
35
+
36
+ export class InvalidStringCharacterError extends Error {
37
+ constructor(value: string | undefined) {
38
+ super(value);
39
+ this.name = 'InvalidStringCharacterError';
40
+ }
41
+ }
@@ -0,0 +1,15 @@
1
+ export type { Codable } from './types';
2
+ export { default as AbstractBase64UrlEncoder } from './AbstractBase64UrlEncoder';
3
+ export { default as BooleanEncoder } from './BooleanEncoder';
4
+ export { default as CompressedBase64UrlEncoder } from './CompressedBase64UrlEncoder';
5
+ export { default as DatetimeEncoder } from './DatetimeEncoder';
6
+ export { default as EncodableOptimizedFixedRange } from './EncodableOptimizedFixedRange';
7
+ export { default as FibonacciIntegerEncoder } from './FibonacciIntegerEncoder';
8
+ export { default as FibonacciIntegerRangeEncoder } from './FibonacciIntegerRangeEncoder';
9
+ export { default as FixedBitfieldEncoder } from './FixedBitfieldEncoder';
10
+ export { default as FixedIdBitMapEncoder } from './FixedIdBitMapEncoder';
11
+ export { default as FixedIntegerEncoder } from './FixedIntegerEncoder';
12
+ export { default as FixedIntegerListEncoder } from './FixedIntegerListEncoder';
13
+ export { default as FixedIntegerRangeEncoder } from './FixedIntegerRangeEncoder';
14
+ export { default as FixedStringEncoder } from './FixedStringEncoder';
15
+ export { default as TraditionalBase64UrlEncoder } from './TraditionalBase64UrlEncoder';
@@ -0,0 +1,5 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ export interface Codable {
3
+ encode: (...args: any[]) => string;
4
+ decode: (...args: any[]) => unknown;
5
+ }
@@ -0,0 +1,9 @@
1
+ import reducer from './reducer';
2
+ import v1_0 from './v1';
3
+
4
+ export default {
5
+ reducer,
6
+ versions: {
7
+ v1_0,
8
+ },
9
+ };
@@ -0,0 +1,7 @@
1
+ import { genericReducer } from '../../redux/helpers';
2
+
3
+ export const initialState = {
4
+ iab: {},
5
+ };
6
+
7
+ export default genericReducer(initialState, {});
@@ -0,0 +1,21 @@
1
+ import { SECTIONS } from './constants';
2
+ import { ScreenIds } from '../../constants';
3
+ import { get } from '../../utils';
4
+
5
+ export const isUiVisible = state =>
6
+ get(state, 'ui.currentScreen', ScreenIds.None) !== ScreenIds.None;
7
+ export const getSupportedApis = state =>
8
+ // We check state to filter out any unloaded section (e.g. if this is the
9
+ // non-IAB build then 'tcfeuv2' should not be returned because it's not
10
+ // available) and then use the SECTIONS constant to filter out any
11
+ // consentStrings that aren't in the spec.
12
+ Object.keys(get(state, 'iab.consentStrings', {})).filter(
13
+ section => !!SECTIONS[`${section}`],
14
+ );
15
+ export const doesGDPRApply = state =>
16
+ get(state, 'config.gdprApplies', false).toString() === 'true';
17
+ export const isBrowsingFrom = (state, jurisdiction) =>
18
+ get(state, 'config.jurisdiction', '').substring(0, jurisdiction.length) ===
19
+ jurisdiction;
20
+ export const getConsentString = (state, section) =>
21
+ get(state, `iab.consentStrings.${section}`, undefined);
@@ -0,0 +1,3 @@
1
+ export type Gpp = unknown;
2
+
3
+ export type Gpp_v2 = Gpp;
@@ -0,0 +1,7 @@
1
+ export const apiName = '__gpp';
2
+ // gppSection is the key in redux state that stores the consent string.
3
+ export const gppSection = 'gpp';
4
+ export const iframeName = '__gppLocator';
5
+ export const version = '1.0';
6
+
7
+ export const initOptions = { gppSection, version };
@@ -0,0 +1,73 @@
1
+ import { apiName, gppSection, iframeName, initOptions } from './constants';
2
+ import { getConsentString, getSupportedApis, isUiVisible } from '../selectors';
3
+
4
+ import { types as ActionTypes } from '../../../redux/actions';
5
+ import { EventNames } from '../constants';
6
+ import makeApi from '../api';
7
+ import { makeFormatPingData } from '../consent';
8
+ import postMessageEventHandler from '../../iframe';
9
+ import { setConsentData } from '../../actions';
10
+
11
+ const formatPingData = makeFormatPingData(initOptions);
12
+
13
+ export function createMiddleware({ dispatchEvent } = {}) {
14
+ return store => next => action => {
15
+ const previousState = store.getState();
16
+ const result = next(action);
17
+ const { payload, type } = action;
18
+ const newState = store.getState();
19
+ const pingData = formatPingData(newState);
20
+
21
+ switch (type) {
22
+ case setConsentData.type: {
23
+ const sectionIsSupported = getSupportedApis(newState).includes(
24
+ payload.gppSection,
25
+ );
26
+
27
+ if (
28
+ dispatchEvent &&
29
+ sectionIsSupported &&
30
+ getConsentString(previousState, payload.gppSection) !== payload.value
31
+ ) {
32
+ dispatchEvent({
33
+ eventName: EventNames.SECTION_CHANGED,
34
+ data: payload.gppSection,
35
+ pingData,
36
+ });
37
+ }
38
+ break;
39
+ }
40
+ case ActionTypes.showDialog:
41
+ case ActionTypes.showDrawer:
42
+ case ActionTypes.showDoNotSell:
43
+ case ActionTypes.hideDialog:
44
+ case ActionTypes.hideDrawer:
45
+ case ActionTypes.hideDoNotSell:
46
+ case ActionTypes.hideAll: {
47
+ if (
48
+ dispatchEvent &&
49
+ isUiVisible(previousState) !== isUiVisible(newState)
50
+ ) {
51
+ dispatchEvent({
52
+ eventName: EventNames.CMP_DISPLAY_STATUS_CHANGED,
53
+ data: pingData.cmpDisplayStatus,
54
+ pingData,
55
+ });
56
+ }
57
+ break;
58
+ }
59
+ }
60
+ return result;
61
+ };
62
+ }
63
+
64
+ const v1 = {
65
+ api: makeApi(initOptions),
66
+ apiName,
67
+ createMiddleware,
68
+ gppSection,
69
+ iframeName,
70
+ postMessageEventHandler: postMessageEventHandler(apiName),
71
+ };
72
+
73
+ export default v1;
@@ -0,0 +1,56 @@
1
+ import { getConsentDataObject, makeGetField } from './consent';
2
+
3
+ export default function makeApi(initOptions) {
4
+ function bind(store) {
5
+ /**
6
+ * USPAPI implementation
7
+ * @function
8
+ * @name __uspapi
9
+ * @param {string} command - The command to be executed by the API
10
+ * @param {number} version - The version number that the response should adhere to
11
+ * @param {requestCallback} callback - The callback method that should be called with the command result
12
+ * @param {string} [parameter] - Optional parameter to be passed to the `command`
13
+ */
14
+ return function uspApi(command, version, callback, parameter) {
15
+ const state = store.getState();
16
+ const getField = makeGetField(initOptions);
17
+
18
+ const getUSPData = (
19
+ providedState,
20
+ apiVersion = initOptions.apiVersion,
21
+ ) => {
22
+ try {
23
+ const consentData = getConsentDataObject({
24
+ ...initOptions,
25
+ version: apiVersion,
26
+ })(providedState);
27
+ return consentData;
28
+ } catch (error) {
29
+ // Could not retrieve data
30
+ return undefined;
31
+ }
32
+ };
33
+
34
+ switch (command) {
35
+ case 'getUSPData': {
36
+ if (typeof callback === 'function') {
37
+ const uspData = getUSPData(state, version);
38
+ callback(uspData, !!uspData);
39
+ }
40
+ break;
41
+ }
42
+
43
+ case 'getField': {
44
+ const field = parameter;
45
+ return getField(state, field);
46
+ }
47
+
48
+ case 'getSection': {
49
+ return getUSPData(state, version);
50
+ }
51
+ }
52
+ };
53
+ }
54
+
55
+ return { bind };
56
+ }