@lighthouse/common 6.10.0 → 6.10.1-canary.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 (229) hide show
  1. package/.mise.toml +6 -6
  2. package/CHANGELOG.md +758 -758
  3. package/README.md +1 -1
  4. package/dist/errors/FetchImageError.js +3 -3
  5. package/dist/helpers/fetch-image-for-pdf-generator-service/index.js +7 -7
  6. package/dist/helpers/floatify/index.js +6 -6
  7. package/dist/helpers/get-audit-items-data/index.js +47 -36
  8. package/dist/helpers/validate-url/index.js +4 -4
  9. package/dist/pdf/activity-report/index.js +32 -32
  10. package/dist/pdf/audit/index.js +23 -23
  11. package/dist/pdf/helpers/fields/index.js +47 -27
  12. package/dist/pdf/issue/index.js +23 -23
  13. package/dist/pdf/job/index.js +22 -22
  14. package/dist/pdf/shift-report/index.js +28 -28
  15. package/dist/pdf/task/index.js +23 -23
  16. package/dist/scheduling/generators/occurrenceIntervalsGenerator.js +2 -2
  17. package/dist/scheduling/generators/scheduleIntervalsGenerator.js +2 -2
  18. package/dist/scheduling/generators/serviceIntervalsGenerator.js +2 -2
  19. package/dist/scheduling/helpers/convertToTimezone.js +6 -6
  20. package/dist/scheduling/helpers/generateNonRepeatingSchedule.js +2 -2
  21. package/dist/scheduling/helpers/generateRepeatingSchedule.js +2 -2
  22. package/dist/scheduling/helpers/generateScheduleEnd.js +2 -2
  23. package/dist/scheduling/helpers/hasValidStartAndEnd.js +5 -5
  24. package/dist/scheduling/helpers/intervalCovers.js +6 -6
  25. package/dist/scheduling/helpers/intervalIntersectsEnd.js +6 -6
  26. package/dist/scheduling/helpers/intervalIntersectsStart.js +6 -6
  27. package/dist/scheduling/helpers/intervalOnlyIntersectsEnd.js +6 -6
  28. package/dist/scheduling/helpers/intervalOnlyIntersectsStart.js +6 -6
  29. package/dist/scheduling/helpers/intervalOutside.js +6 -6
  30. package/dist/scheduling/helpers/intervalWithin.js +6 -6
  31. package/dist/scheduling/helpers/mergeIntervals.js +6 -6
  32. package/dist/scheduling/helpers/splitIntervals.js +6 -6
  33. package/dist/scheduling/strategies/getNext.js +2 -2
  34. package/dist/scheduling/strategies/getNextExactDateOfMonth.js +2 -2
  35. package/dist/scheduling/strategies/getNextLastDayOfMonth.js +2 -2
  36. package/dist/scheduling/strategies/getNextLastWeekdayOfMonth.js +2 -2
  37. package/dist/scheduling/strategies/getNextNoRepeat.js +2 -2
  38. package/dist/scheduling/strategies/getNextWeekday.js +2 -2
  39. package/dist/scheduling/strategies/getNextXDayOfXWeekOfMonth.js +2 -2
  40. package/dist/service-hours/__helpers__/calculate-hours.js +4 -4
  41. package/dist/service-hours/__helpers__/isOpen.js +2 -2
  42. package/dist/service-hours/schema.js +4 -4
  43. package/lib/constants.js +12 -6
  44. package/lib/constants.js.map +1 -1
  45. package/lib/errors/DomainError.js +14 -21
  46. package/lib/errors/DomainError.js.map +1 -1
  47. package/lib/errors/FetchImageError.js +17 -24
  48. package/lib/errors/FetchImageError.js.map +1 -1
  49. package/lib/errors/ValidationError.js +30 -36
  50. package/lib/errors/ValidationError.js.map +1 -1
  51. package/lib/errors/index.js +23 -5
  52. package/lib/errors/index.js.map +1 -1
  53. package/lib/helpers/build-fetch-url/index.js +43 -47
  54. package/lib/helpers/build-fetch-url/index.js.map +1 -1
  55. package/lib/helpers/fetch-image/index.js +83 -82
  56. package/lib/helpers/fetch-image/index.js.map +1 -1
  57. package/lib/helpers/fetch-image-for-pdf-generator-service/index.js +168 -243
  58. package/lib/helpers/fetch-image-for-pdf-generator-service/index.js.map +1 -1
  59. package/lib/helpers/fetch-image-for-web/index.js +71 -94
  60. package/lib/helpers/fetch-image-for-web/index.js.map +1 -1
  61. package/lib/helpers/fetch-lighthouse-logo/index.js +36 -61
  62. package/lib/helpers/fetch-lighthouse-logo/index.js.map +1 -1
  63. package/lib/helpers/floatify/index.js +13 -7
  64. package/lib/helpers/floatify/index.js.map +1 -1
  65. package/lib/helpers/get-assignees-full-names/index.js +11 -7
  66. package/lib/helpers/get-assignees-full-names/index.js.map +1 -1
  67. package/lib/helpers/get-audit-entry-details/index.js +42 -32
  68. package/lib/helpers/get-audit-entry-details/index.js.map +1 -1
  69. package/lib/helpers/get-audit-items-data/index.js +104 -83
  70. package/lib/helpers/get-audit-items-data/index.js.map +1 -1
  71. package/lib/helpers/get-geometry-geocoded-string/index.js +10 -5
  72. package/lib/helpers/get-geometry-geocoded-string/index.js.map +1 -1
  73. package/lib/helpers/get-issue-details/index.js +53 -43
  74. package/lib/helpers/get-issue-details/index.js.map +1 -1
  75. package/lib/helpers/get-job-details/index.js +49 -41
  76. package/lib/helpers/get-job-details/index.js.map +1 -1
  77. package/lib/helpers/get-location-reference/index.js +32 -34
  78. package/lib/helpers/get-location-reference/index.js.map +1 -1
  79. package/lib/helpers/get-pretty-duration/index.js +16 -10
  80. package/lib/helpers/get-pretty-duration/index.js.map +1 -1
  81. package/lib/helpers/get-reference-details/index.js +20 -10
  82. package/lib/helpers/get-reference-details/index.js.map +1 -1
  83. package/lib/helpers/get-status-details/index.js +8 -2
  84. package/lib/helpers/get-status-details/index.js.map +1 -1
  85. package/lib/helpers/get-task-entry-details/index.js +32 -23
  86. package/lib/helpers/get-task-entry-details/index.js.map +1 -1
  87. package/lib/helpers/get-timezone-abbr/index.js +11 -4
  88. package/lib/helpers/get-timezone-abbr/index.js.map +1 -1
  89. package/lib/helpers/get-timezone-datetime/index.js +20 -13
  90. package/lib/helpers/get-timezone-datetime/index.js.map +1 -1
  91. package/lib/helpers/get-user-full-name/index.js +9 -3
  92. package/lib/helpers/get-user-full-name/index.js.map +1 -1
  93. package/lib/helpers/get-value-as-percentage/index.js +9 -4
  94. package/lib/helpers/get-value-as-percentage/index.js.map +1 -1
  95. package/lib/helpers/image-validators/index.js +18 -12
  96. package/lib/helpers/image-validators/index.js.map +1 -1
  97. package/lib/helpers/index.js +130 -18
  98. package/lib/helpers/index.js.map +1 -1
  99. package/lib/helpers/validate-url/index.js +11 -5
  100. package/lib/helpers/validate-url/index.js.map +1 -1
  101. package/lib/images/index.js +10 -4
  102. package/lib/images/index.js.map +1 -1
  103. package/lib/index.js +66 -10
  104. package/lib/index.js.map +1 -1
  105. package/lib/pdf/activity-report/index.js +407 -537
  106. package/lib/pdf/activity-report/index.js.map +1 -1
  107. package/lib/pdf/audit/index.js +137 -134
  108. package/lib/pdf/audit/index.js.map +1 -1
  109. package/lib/pdf/fonts/index.js +4 -2
  110. package/lib/pdf/fonts/index.js.map +1 -1
  111. package/lib/pdf/helpers/build-audit-content/index.js +57 -51
  112. package/lib/pdf/helpers/build-audit-content/index.js.map +1 -1
  113. package/lib/pdf/helpers/build-audit-follow-ups/index.js +52 -50
  114. package/lib/pdf/helpers/build-audit-follow-ups/index.js.map +1 -1
  115. package/lib/pdf/helpers/build-location-scans-content/index.js +22 -16
  116. package/lib/pdf/helpers/build-location-scans-content/index.js.map +1 -1
  117. package/lib/pdf/helpers/build-template-content/index.js +52 -51
  118. package/lib/pdf/helpers/build-template-content/index.js.map +1 -1
  119. package/lib/pdf/helpers/default-footer/index.js +38 -35
  120. package/lib/pdf/helpers/default-footer/index.js.map +1 -1
  121. package/lib/pdf/helpers/default-header/index.js +40 -35
  122. package/lib/pdf/helpers/default-header/index.js.map +1 -1
  123. package/lib/pdf/helpers/default-styles/index.js +7 -1
  124. package/lib/pdf/helpers/default-styles/index.js.map +1 -1
  125. package/lib/pdf/helpers/fields/index.js +225 -214
  126. package/lib/pdf/helpers/fields/index.js.map +1 -1
  127. package/lib/pdf/helpers/format-location-address/index.js +14 -8
  128. package/lib/pdf/helpers/format-location-address/index.js.map +1 -1
  129. package/lib/pdf/helpers/generate-definition/index.js +60 -65
  130. package/lib/pdf/helpers/generate-definition/index.js.map +1 -1
  131. package/lib/pdf/helpers/horizontal-line/index.js +14 -14
  132. package/lib/pdf/helpers/horizontal-line/index.js.map +1 -1
  133. package/lib/pdf/helpers/html-transformer/index.js +45 -35
  134. package/lib/pdf/helpers/html-transformer/index.js.map +1 -1
  135. package/lib/pdf/helpers/index.js +194 -15
  136. package/lib/pdf/helpers/index.js.map +1 -1
  137. package/lib/pdf/helpers/parse-value/index.js +10 -4
  138. package/lib/pdf/helpers/parse-value/index.js.map +1 -1
  139. package/lib/pdf/helpers/table/index.js +136 -205
  140. package/lib/pdf/helpers/table/index.js.map +1 -1
  141. package/lib/pdf/helpers/text/index.js +11 -8
  142. package/lib/pdf/helpers/text/index.js.map +1 -1
  143. package/lib/pdf/icons/index.js +8 -2
  144. package/lib/pdf/icons/index.js.map +1 -1
  145. package/lib/pdf/index.js +47 -6
  146. package/lib/pdf/index.js.map +1 -1
  147. package/lib/pdf/issue/index.js +141 -135
  148. package/lib/pdf/issue/index.js.map +1 -1
  149. package/lib/pdf/job/index.js +95 -81
  150. package/lib/pdf/job/index.js.map +1 -1
  151. package/lib/pdf/shift-report/emptyFixtures.js +8 -2
  152. package/lib/pdf/shift-report/emptyFixtures.js.map +1 -1
  153. package/lib/pdf/shift-report/index.js +399 -521
  154. package/lib/pdf/shift-report/index.js.map +1 -1
  155. package/lib/pdf/task/index.js +89 -83
  156. package/lib/pdf/task/index.js.map +1 -1
  157. package/lib/scheduling/generators/index.js +38 -3
  158. package/lib/scheduling/generators/index.js.map +1 -1
  159. package/lib/scheduling/generators/occurrenceIntervalsGenerator.js +44 -37
  160. package/lib/scheduling/generators/occurrenceIntervalsGenerator.js.map +1 -1
  161. package/lib/scheduling/generators/scheduleIntervalsGenerator.js +20 -28
  162. package/lib/scheduling/generators/scheduleIntervalsGenerator.js.map +1 -1
  163. package/lib/scheduling/generators/serviceIntervalsGenerator.js +120 -150
  164. package/lib/scheduling/generators/serviceIntervalsGenerator.js.map +1 -1
  165. package/lib/scheduling/helpers/convertToTimezone.js +18 -11
  166. package/lib/scheduling/helpers/convertToTimezone.js.map +1 -1
  167. package/lib/scheduling/helpers/generateNonRepeatingSchedule.js +57 -95
  168. package/lib/scheduling/helpers/generateNonRepeatingSchedule.js.map +1 -1
  169. package/lib/scheduling/helpers/generateRepeatingSchedule.js +80 -119
  170. package/lib/scheduling/helpers/generateRepeatingSchedule.js.map +1 -1
  171. package/lib/scheduling/helpers/generateScheduleEnd.js +24 -14
  172. package/lib/scheduling/helpers/generateScheduleEnd.js.map +1 -1
  173. package/lib/scheduling/helpers/hasValidStartAndEnd.js +19 -11
  174. package/lib/scheduling/helpers/hasValidStartAndEnd.js.map +1 -1
  175. package/lib/scheduling/helpers/index.js +159 -14
  176. package/lib/scheduling/helpers/index.js.map +1 -1
  177. package/lib/scheduling/helpers/intervalCovers.js +13 -7
  178. package/lib/scheduling/helpers/intervalCovers.js.map +1 -1
  179. package/lib/scheduling/helpers/intervalIntersectsEnd.js +13 -7
  180. package/lib/scheduling/helpers/intervalIntersectsEnd.js.map +1 -1
  181. package/lib/scheduling/helpers/intervalIntersectsStart.js +13 -7
  182. package/lib/scheduling/helpers/intervalIntersectsStart.js.map +1 -1
  183. package/lib/scheduling/helpers/intervalOnlyIntersectsEnd.js +15 -10
  184. package/lib/scheduling/helpers/intervalOnlyIntersectsEnd.js.map +1 -1
  185. package/lib/scheduling/helpers/intervalOnlyIntersectsStart.js +15 -10
  186. package/lib/scheduling/helpers/intervalOnlyIntersectsStart.js.map +1 -1
  187. package/lib/scheduling/helpers/intervalOutside.js +15 -9
  188. package/lib/scheduling/helpers/intervalOutside.js.map +1 -1
  189. package/lib/scheduling/helpers/intervalWithin.js +13 -7
  190. package/lib/scheduling/helpers/intervalWithin.js.map +1 -1
  191. package/lib/scheduling/helpers/mergeIntervals.js +21 -17
  192. package/lib/scheduling/helpers/mergeIntervals.js.map +1 -1
  193. package/lib/scheduling/helpers/splitIntervals.js +24 -23
  194. package/lib/scheduling/helpers/splitIntervals.js.map +1 -1
  195. package/lib/scheduling/index.js +38 -3
  196. package/lib/scheduling/index.js.map +1 -1
  197. package/lib/scheduling/scheduling.types.js +9 -3
  198. package/lib/scheduling/scheduling.types.js.map +1 -1
  199. package/lib/scheduling/strategies/getNext.js +57 -63
  200. package/lib/scheduling/strategies/getNext.js.map +1 -1
  201. package/lib/scheduling/strategies/getNextExactDateOfMonth.js +47 -56
  202. package/lib/scheduling/strategies/getNextExactDateOfMonth.js.map +1 -1
  203. package/lib/scheduling/strategies/getNextLastDayOfMonth.js +43 -51
  204. package/lib/scheduling/strategies/getNextLastDayOfMonth.js.map +1 -1
  205. package/lib/scheduling/strategies/getNextLastWeekdayOfMonth.js +49 -56
  206. package/lib/scheduling/strategies/getNextLastWeekdayOfMonth.js.map +1 -1
  207. package/lib/scheduling/strategies/getNextNoRepeat.js +25 -36
  208. package/lib/scheduling/strategies/getNextNoRepeat.js.map +1 -1
  209. package/lib/scheduling/strategies/getNextWeekday.js +47 -79
  210. package/lib/scheduling/strategies/getNextWeekday.js.map +1 -1
  211. package/lib/scheduling/strategies/getNextXDayOfXWeekOfMonth.js +52 -58
  212. package/lib/scheduling/strategies/getNextXDayOfXWeekOfMonth.js.map +1 -1
  213. package/lib/scheduling/strategies/index.js +82 -7
  214. package/lib/scheduling/strategies/index.js.map +1 -1
  215. package/lib/schema/index.js +16 -1
  216. package/lib/schema/index.js.map +1 -1
  217. package/lib/schema/schema.js +28 -34
  218. package/lib/schema/schema.js.map +1 -1
  219. package/lib/service-hours/__helpers__/calculate-hours.js +24 -22
  220. package/lib/service-hours/__helpers__/calculate-hours.js.map +1 -1
  221. package/lib/service-hours/__helpers__/isOpen.js +25 -24
  222. package/lib/service-hours/__helpers__/isOpen.js.map +1 -1
  223. package/lib/service-hours/index.js +27 -2
  224. package/lib/service-hours/index.js.map +1 -1
  225. package/lib/service-hours/schema.js +68 -55
  226. package/lib/service-hours/schema.js.map +1 -1
  227. package/package.json +86 -86
  228. package/vitest.config.ts +23 -23
  229. package/vitest.setup.js +7 -7
@@ -1 +1 @@
1
- {"version":3,"file":"ValidationError.js","names":["ValidationError","SchemaValidationError","DomainError","DEFAULT_MESSAGE","_DomainError","_ref","_this","data","_ref$message","message","_classCallCheck","validationMessage","name","other","_objectWithoutProperties","_excluded","_callSuper","status","_possibleConstructorReturn","_assertThisInitialized","_inherits","_createClass","default"],"sources":["../../src/errors/ValidationError.ts"],"sourcesContent":["import { ValidationError as SchemaValidationError } from 'yup'\nimport DomainError from './DomainError'\n\ninterface Options {\n data?: any\n message?: string\n}\n\nconst DEFAULT_MESSAGE =\n 'The data you submitted was invalid. Please try again with valid data.'\n\nexport default class ValidationError extends DomainError {\n public data: object\n public message: string\n public status: number\n constructor({ data, message = DEFAULT_MESSAGE }: Options) {\n // When the data object is a schema validation error, take its data\n // attributes and apply to our wrapped error\n if (data instanceof SchemaValidationError) {\n const { message: validationMessage, name, ...other } = data\n\n super(validationMessage)\n this.data = other\n this.status = 400\n return\n }\n\n super(message)\n this.data = data\n this.status = 400\n }\n}\n"],"mappings":";;;;;;;;;;AAAA,SAASA,eAAe,IAAIC,qBAAqB,QAAQ,KAAK;AAC9D,OAAOC,WAAW,MAAM,eAAe;AAOvC,IAAMC,eAAe,GACnB,uEAAuE;AAAA,IAEpDH,eAAe,0BAAAI,YAAA;EAIlC,SAAAJ,gBAAAK,IAAA,EAA0D;IAAA,IAAAC,KAAA;IAAA,IAA5CC,IAAI,GAAAF,IAAA,CAAJE,IAAI;MAAAC,YAAA,GAAAH,IAAA,CAAEI,OAAO;MAAPA,OAAO,GAAAD,YAAA,cAAGL,eAAe,GAAAK,YAAA;IAAAE,eAAA,OAAAV,eAAA;IAC3C;IACA;IACA,IAAIO,IAAI,YAAYN,qBAAqB,EAAE;MACzC,IAAiBU,iBAAiB,GAAqBJ,IAAI,CAAnDE,OAAO;QAAqBG,IAAI,GAAeL,IAAI,CAAvBK,IAAI;QAAKC,KAAK,GAAAC,wBAAA,CAAKP,IAAI,EAAAQ,SAAA;MAE3DT,KAAA,GAAAU,UAAA,OAAAhB,eAAA,GAAMW,iBAAiB;MACvBL,KAAA,CAAKC,IAAI,GAAGM,KAAK;MACjBP,KAAA,CAAKW,MAAM,GAAG,GAAG;MACjB,OAAAC,0BAAA,CAAAZ,KAAA;IACF;IAEAA,KAAA,GAAAU,UAAA,OAAAhB,eAAA,GAAMS,OAAO;IACbH,KAAA,CAAKC,IAAI,GAAGA,IAAI;IAChBD,KAAA,CAAKW,MAAM,GAAG,GAAG;IAAA,OAAAE,sBAAA,CAAAb,KAAA;EACnB;EAACc,SAAA,CAAApB,eAAA,EAAAI,YAAA;EAAA,OAAAiB,YAAA,CAAArB,eAAA;AAAA,EAnB0CE,WAAW;AAAA,SAAnCF,eAAe,IAAAsB,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"ValidationError.js","names":["_yup","require","_DomainError","_interopRequireDefault","DEFAULT_MESSAGE","ValidationError","DomainError","constructor","data","message","SchemaValidationError","validationMessage","name","other","status","exports","default"],"sources":["../../src/errors/ValidationError.ts"],"sourcesContent":["import { ValidationError as SchemaValidationError } from 'yup'\r\nimport DomainError from './DomainError'\r\n\r\ninterface Options {\r\n data?: any\r\n message?: string\r\n}\r\n\r\nconst DEFAULT_MESSAGE =\r\n 'The data you submitted was invalid. Please try again with valid data.'\r\n\r\nexport default class ValidationError extends DomainError {\r\n public data: object\r\n public message: string\r\n public status: number\r\n constructor({ data, message = DEFAULT_MESSAGE }: Options) {\r\n // When the data object is a schema validation error, take its data\r\n // attributes and apply to our wrapped error\r\n if (data instanceof SchemaValidationError) {\r\n const { message: validationMessage, name, ...other } = data\r\n\r\n super(validationMessage)\r\n this.data = other\r\n this.status = 400\r\n return\r\n }\r\n\r\n super(message)\r\n this.data = data\r\n this.status = 400\r\n }\r\n}\r\n"],"mappings":";;;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AAOA,MAAMG,eAAe,GACnB,uEAAuE;AAE1D,MAAMC,eAAe,SAASC,oBAAW,CAAC;EAIvDC,WAAWA,CAAC;IAAEC,IAAI;IAAEC,OAAO,GAAGL;EAAyB,CAAC,EAAE;IACxD;IACA;IACA,IAAII,IAAI,YAAYE,oBAAqB,EAAE;MACzC,MAAM;QAAED,OAAO,EAAEE,iBAAiB;QAAEC,IAAI;QAAE,GAAGC;MAAM,CAAC,GAAGL,IAAI;MAE3D,KAAK,CAACG,iBAAiB,CAAC;MACxB,IAAI,CAACH,IAAI,GAAGK,KAAK;MACjB,IAAI,CAACC,MAAM,GAAG,GAAG;MACjB;IACF;IAEA,KAAK,CAACL,OAAO,CAAC;IACd,IAAI,CAACD,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACM,MAAM,GAAG,GAAG;EACnB;AACF;AAACC,OAAA,CAAAC,OAAA,GAAAX,eAAA","ignoreList":[]}
@@ -1,7 +1,25 @@
1
- import DomainError from './DomainError';
2
- export { DomainError };
3
- export { default as ValidationError } from './ValidationError';
4
- export function isKnownError(err) {
5
- return err instanceof DomainError;
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ Object.defineProperty(exports, "DomainError", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _DomainError.default;
11
+ }
12
+ });
13
+ Object.defineProperty(exports, "ValidationError", {
14
+ enumerable: true,
15
+ get: function () {
16
+ return _ValidationError.default;
17
+ }
18
+ });
19
+ exports.isKnownError = isKnownError;
20
+ var _DomainError = _interopRequireDefault(require("./DomainError"));
21
+ var _ValidationError = _interopRequireDefault(require("./ValidationError"));
22
+ function isKnownError(err) {
23
+ return err instanceof _DomainError.default;
6
24
  }
7
25
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["DomainError","default","ValidationError","isKnownError","err"],"sources":["../../src/errors/index.ts"],"sourcesContent":["import DomainError from './DomainError'\n\nexport { DomainError }\nexport { default as ValidationError } from './ValidationError'\n\nexport function isKnownError(err: Error): boolean {\n return err instanceof DomainError\n}\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AAEvC,SAASA,WAAW;AACpB,SAASC,OAAO,IAAIC,eAAe,QAAQ,mBAAmB;AAE9D,OAAO,SAASC,YAAYA,CAACC,GAAU,EAAW;EAChD,OAAOA,GAAG,YAAYJ,WAAW;AACnC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_DomainError","_interopRequireDefault","require","_ValidationError","isKnownError","err","DomainError"],"sources":["../../src/errors/index.ts"],"sourcesContent":["import DomainError from './DomainError'\r\n\r\nexport { DomainError }\r\nexport { default as ValidationError } from './ValidationError'\r\n\r\nexport function isKnownError(err: Error): boolean {\r\n return err instanceof DomainError\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,gBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEO,SAASE,YAAYA,CAACC,GAAU,EAAW;EAChD,OAAOA,GAAG,YAAYC,oBAAW;AACnC","ignoreList":[]}
@@ -1,33 +1,38 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import _typeof from "@babel/runtime/helpers/typeof";
3
- import { isAbsoluteUrl } from '../validate-url/index.js';
4
- export function buildFetchUrl(url, options) {
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.buildFetchUrl = buildFetchUrl;
7
+ var _index = require("../validate-url/index.js");
8
+ function buildFetchUrl(url, options) {
5
9
  // Validate url parameter
6
10
  if (!url || typeof url !== 'string') {
7
- throw new Error("buildFetchUrl: Invalid url parameter. url=".concat(JSON.stringify(url)));
11
+ throw new Error(`buildFetchUrl: Invalid url parameter. url=${JSON.stringify(url)}`);
8
12
  }
9
- var awsS3BaseUrl = options.awsS3BaseUrl,
10
- _options$cloudfrontBa = options.cloudfrontBaseUrl,
11
- cloudfrontBaseUrl = _options$cloudfrontBa === void 0 ? '' : _options$cloudfrontBa,
12
- cloudinaryBaseUrl = options.cloudinaryBaseUrl,
13
- fit = options.fit,
14
- height = options.height,
15
- width = options.width,
16
- quality = options.quality,
17
- shouldUseCloudfront = options.shouldUseCloudfront,
18
- Policy = options.Policy,
19
- KeyPairId = options.KeyPairId,
20
- Signature = options.Signature;
13
+ const {
14
+ awsS3BaseUrl,
15
+ cloudfrontBaseUrl = '',
16
+ cloudinaryBaseUrl,
17
+ fit,
18
+ height,
19
+ width,
20
+ quality,
21
+ shouldUseCloudfront,
22
+ Policy,
23
+ KeyPairId,
24
+ Signature
25
+ } = options;
21
26
  if (shouldUseCloudfront) {
22
27
  // Validate cloudfrontBaseUrl when using CloudFront
23
28
  if (!cloudfrontBaseUrl) {
24
- throw new Error("buildFetchUrl: cloudfrontBaseUrl is required when shouldUseCloudfront=true. cloudfrontBaseUrl=".concat(JSON.stringify(cloudfrontBaseUrl)));
29
+ throw new Error(`buildFetchUrl: cloudfrontBaseUrl is required when shouldUseCloudfront=true. cloudfrontBaseUrl=${JSON.stringify(cloudfrontBaseUrl)}`);
25
30
  }
26
- var isWebContext = shouldUseCloudfront && (typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object';
27
- var paramMap = {
28
- width: width,
29
- height: height,
30
- quality: quality,
31
+ const isWebContext = shouldUseCloudfront && typeof window === 'object';
32
+ const paramMap = {
33
+ width,
34
+ height,
35
+ quality,
31
36
  fit: 'contain'
32
37
  };
33
38
  if (isWebContext) {
@@ -35,42 +40,33 @@ export function buildFetchUrl(url, options) {
35
40
  paramMap['Key-Pair-Id'] = KeyPairId;
36
41
  paramMap.Signature = Signature;
37
42
  }
38
- var params = Object.entries(paramMap).filter(function (_ref) {
39
- var _ref2 = _slicedToArray(_ref, 2),
40
- value = _ref2[1];
41
- return value != null;
42
- }).map(function (_ref3) {
43
- var _ref4 = _slicedToArray(_ref3, 2),
44
- key = _ref4[0],
45
- value = _ref4[1];
46
- return "".concat(key, "=").concat(String(value));
47
- });
48
- var paramsString = params.join('&');
49
- var result = "".concat(cloudfrontBaseUrl, "/").concat(url, "?").concat(paramsString);
43
+ const params = Object.entries(paramMap).filter(([, value]) => value != null).map(([key, value]) => `${key}=${String(value)}`);
44
+ const paramsString = params.join('&');
45
+ const result = `${cloudfrontBaseUrl}/${url}?${paramsString}`;
50
46
 
51
47
  // Validate output is absolute URL
52
- if (!isAbsoluteUrl(result)) {
53
- throw new Error("buildFetchUrl: Constructed URL is not absolute. cloudfrontBaseUrl=".concat(JSON.stringify(cloudfrontBaseUrl), ", url=").concat(JSON.stringify(url), ", result=").concat(JSON.stringify(result)));
48
+ if (!(0, _index.isAbsoluteUrl)(result)) {
49
+ throw new Error(`buildFetchUrl: Constructed URL is not absolute. cloudfrontBaseUrl=${JSON.stringify(cloudfrontBaseUrl)}, url=${JSON.stringify(url)}, result=${JSON.stringify(result)}`);
54
50
  }
55
51
  return result;
56
52
  }
57
53
 
58
54
  // Validate required base URLs for Cloudinary path
59
55
  if (!cloudinaryBaseUrl || !awsS3BaseUrl) {
60
- throw new Error("buildFetchUrl: cloudinaryBaseUrl and awsS3BaseUrl are required. cloudinaryBaseUrl=".concat(JSON.stringify(cloudinaryBaseUrl), ", awsS3BaseUrl=").concat(JSON.stringify(awsS3BaseUrl)));
56
+ throw new Error(`buildFetchUrl: cloudinaryBaseUrl and awsS3BaseUrl are required. cloudinaryBaseUrl=${JSON.stringify(cloudinaryBaseUrl)}, awsS3BaseUrl=${JSON.stringify(awsS3BaseUrl)}`);
61
57
  }
62
- var transformations = [];
63
- var transformationsString = '';
64
- if (width) transformations.push("w_".concat(width.toString()));
65
- if (height) transformations.push("h_".concat(height.toString()));
66
- if (quality) transformations.push("q_".concat(quality.toString()));
58
+ const transformations = [];
59
+ let transformationsString = '';
60
+ if (width) transformations.push(`w_${width.toString()}`);
61
+ if (height) transformations.push(`h_${height.toString()}`);
62
+ if (quality) transformations.push(`q_${quality.toString()}`);
67
63
  if (fit) transformations.push('c_fit');
68
- transformationsString = "".concat(transformations.join(','), "/");
69
- var fetchUrl = "".concat(cloudinaryBaseUrl, "/").concat(transformationsString).concat(awsS3BaseUrl, "/").concat(url);
64
+ transformationsString = `${transformations.join(',')}/`;
65
+ const fetchUrl = `${cloudinaryBaseUrl}/${transformationsString}${awsS3BaseUrl}/${url}`;
70
66
 
71
67
  // Validate output is absolute URL
72
- if (!isAbsoluteUrl(fetchUrl)) {
73
- throw new Error("buildFetchUrl: Constructed URL is not absolute. cloudinaryBaseUrl=".concat(JSON.stringify(cloudinaryBaseUrl), ", awsS3BaseUrl=").concat(JSON.stringify(awsS3BaseUrl), ", url=").concat(JSON.stringify(url), ", result=").concat(JSON.stringify(fetchUrl)));
68
+ if (!(0, _index.isAbsoluteUrl)(fetchUrl)) {
69
+ throw new Error(`buildFetchUrl: Constructed URL is not absolute. cloudinaryBaseUrl=${JSON.stringify(cloudinaryBaseUrl)}, awsS3BaseUrl=${JSON.stringify(awsS3BaseUrl)}, url=${JSON.stringify(url)}, result=${JSON.stringify(fetchUrl)}`);
74
70
  }
75
71
  return fetchUrl;
76
72
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["isAbsoluteUrl","buildFetchUrl","url","options","Error","concat","JSON","stringify","awsS3BaseUrl","_options$cloudfrontBa","cloudfrontBaseUrl","cloudinaryBaseUrl","fit","height","width","quality","shouldUseCloudfront","Policy","KeyPairId","Signature","isWebContext","window","_typeof","paramMap","params","Object","entries","filter","_ref","_ref2","_slicedToArray","value","map","_ref3","_ref4","key","String","paramsString","join","result","transformations","transformationsString","push","toString","fetchUrl"],"sources":["../../../src/helpers/build-fetch-url/index.js"],"sourcesContent":["import { isAbsoluteUrl } from '../validate-url/index.js'\n\nexport function buildFetchUrl(url, options) {\n // Validate url parameter\n if (!url || typeof url !== 'string') {\n throw new Error(\n `buildFetchUrl: Invalid url parameter. url=${JSON.stringify(url)}`\n )\n }\n\n const {\n awsS3BaseUrl,\n cloudfrontBaseUrl = '',\n cloudinaryBaseUrl,\n fit,\n height,\n width,\n quality,\n shouldUseCloudfront,\n Policy,\n KeyPairId,\n Signature,\n } = options\n\n if (shouldUseCloudfront) {\n // Validate cloudfrontBaseUrl when using CloudFront\n if (!cloudfrontBaseUrl) {\n throw new Error(\n `buildFetchUrl: cloudfrontBaseUrl is required when shouldUseCloudfront=true. cloudfrontBaseUrl=${JSON.stringify(cloudfrontBaseUrl)}`\n )\n }\n const isWebContext = shouldUseCloudfront && typeof window === 'object'\n\n const paramMap = {\n width,\n height,\n quality,\n fit: 'contain',\n }\n\n if (isWebContext) {\n paramMap.Policy = Policy\n paramMap['Key-Pair-Id'] = KeyPairId\n paramMap.Signature = Signature\n }\n const params = Object.entries(paramMap)\n .filter(([, value]) => value != null)\n .map(([key, value]) => `${key}=${String(value)}`)\n\n const paramsString = params.join('&')\n const result = `${cloudfrontBaseUrl}/${url}?${paramsString}`\n\n // Validate output is absolute URL\n if (!isAbsoluteUrl(result)) {\n throw new Error(\n `buildFetchUrl: Constructed URL is not absolute. cloudfrontBaseUrl=${JSON.stringify(cloudfrontBaseUrl)}, url=${JSON.stringify(url)}, result=${JSON.stringify(result)}`\n )\n }\n\n return result\n }\n\n // Validate required base URLs for Cloudinary path\n if (!cloudinaryBaseUrl || !awsS3BaseUrl) {\n throw new Error(\n `buildFetchUrl: cloudinaryBaseUrl and awsS3BaseUrl are required. cloudinaryBaseUrl=${JSON.stringify(cloudinaryBaseUrl)}, awsS3BaseUrl=${JSON.stringify(awsS3BaseUrl)}`\n )\n }\n\n const transformations = []\n let transformationsString = ''\n\n if (width) transformations.push(`w_${width.toString()}`)\n if (height) transformations.push(`h_${height.toString()}`)\n if (quality) transformations.push(`q_${quality.toString()}`)\n if (fit) transformations.push('c_fit')\n\n transformationsString = `${transformations.join(',')}/`\n\n const fetchUrl = `${cloudinaryBaseUrl}/${transformationsString}${awsS3BaseUrl}/${url}`\n\n // Validate output is absolute URL\n if (!isAbsoluteUrl(fetchUrl)) {\n throw new Error(\n `buildFetchUrl: Constructed URL is not absolute. cloudinaryBaseUrl=${JSON.stringify(cloudinaryBaseUrl)}, awsS3BaseUrl=${JSON.stringify(awsS3BaseUrl)}, url=${JSON.stringify(url)},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SAAS,CAACC,YAAY,CAAC,CACtK,CAAC;EACH;EAEA,IAAMgC,eAAe,GAAG,EAAE;EAC1B,IAAIC,qBAAqB,GAAG,EAAE;EAE9B,IAAI3B,KAAK,EAAE0B,eAAe,CAACE,IAAI,MAAArC,MAAA,CAAMS,KAAK,CAAC6B,QAAQ,CAAC,CAAC,CAAE,CAAC;EACxD,IAAI9B,MAAM,EAAE2B,eAAe,CAACE,IAAI,MAAArC,MAAA,CAAMQ,MAAM,CAAC8B,QAAQ,CAAC,CAAC,CAAE,CAAC;EAC1D,IAAI5B,OAAO,EAAEyB,eAAe,CAACE,IAAI,MAAArC,MAAA,CAAMU,OAAO,CAAC4B,QAAQ,CAAC,CAAC,CAAE,CAAC;EAC5D,IAAI/B,GAAG,EAAE4B,eAAe,CAACE,IAAI,CAAC,OAAO,CAAC;EAEtCD,qBAAqB,MAAApC,MAAA,CAAMmC,eAAe,CAACF,IAAI,CAAC,GAAG,CAAC,MAAG;EAEvD,IAAMM,QAAQ,MAAAvC,MAAA,CAAMM,iBAAiB,OAAAN,MAAA,CAAIoC,qBAAqB,EAAApC,MAAA,CAAGG,YAAY,OAAAH,MAAA,CAAIH,GAAG,CAAE;;EAEtF;EACA,IAAI,CAACF,aAAa,CAAC4C,QAAQ,CAAC,EAAE;IAC5B,MAAM,IAAIxC,KAAK,sEAAAC,MAAA,CACwDC,IAAI,CAACC,SAAS,CAACI,iBAAiB,CAAC,qBAAAN,MAAA,CAAkBC,IAAI,CAACC,SAAS,CAACC,YAAY,CAAC,YAAAH,MAAA,CAASC,IAAI,CAACC,SAAS,CAACL,GAAG,CAAC,eAAAG,MAAA,CAAYC,IAAI,CAACC,SAAS,CAACqC,QAAQ,CAAC,CACtN,CAAC;EACH;EAEA,OAAOA,QAAQ;AACjB","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_index","require","buildFetchUrl","url","options","Error","JSON","stringify","awsS3BaseUrl","cloudfrontBaseUrl","cloudinaryBaseUrl","fit","height","width","quality","shouldUseCloudfront","Policy","KeyPairId","Signature","isWebContext","window","paramMap","params","Object","entries","filter","value","map","key","String","paramsString","join","result","isAbsoluteUrl","transformations","transformationsString","push","toString","fetchUrl"],"sources":["../../../src/helpers/build-fetch-url/index.js"],"sourcesContent":["import { isAbsoluteUrl } from '../validate-url/index.js'\r\n\r\nexport function buildFetchUrl(url, options) {\r\n // Validate url parameter\r\n if (!url || typeof url !== 'string') {\r\n throw new Error(\r\n `buildFetchUrl: Invalid url parameter. url=${JSON.stringify(url)}`\r\n )\r\n }\r\n\r\n const {\r\n awsS3BaseUrl,\r\n cloudfrontBaseUrl = '',\r\n cloudinaryBaseUrl,\r\n fit,\r\n height,\r\n width,\r\n quality,\r\n shouldUseCloudfront,\r\n Policy,\r\n KeyPairId,\r\n Signature,\r\n } = options\r\n\r\n if (shouldUseCloudfront) {\r\n // Validate cloudfrontBaseUrl when using CloudFront\r\n if (!cloudfrontBaseUrl) {\r\n throw new Error(\r\n `buildFetchUrl: cloudfrontBaseUrl is required when shouldUseCloudfront=true. cloudfrontBaseUrl=${JSON.stringify(cloudfrontBaseUrl)}`\r\n )\r\n }\r\n const isWebContext = shouldUseCloudfront && typeof window === 'object'\r\n\r\n const paramMap = {\r\n width,\r\n height,\r\n quality,\r\n fit: 'contain',\r\n }\r\n\r\n if (isWebContext) {\r\n paramMap.Policy = Policy\r\n paramMap['Key-Pair-Id'] = KeyPairId\r\n paramMap.Signature = Signature\r\n }\r\n const params = Object.entries(paramMap)\r\n .filter(([, value]) => value != null)\r\n .map(([key, value]) => `${key}=${String(value)}`)\r\n\r\n const paramsString = params.join('&')\r\n const result = `${cloudfrontBaseUrl}/${url}?${paramsString}`\r\n\r\n // Validate output is absolute URL\r\n if (!isAbsoluteUrl(result)) {\r\n throw new Error(\r\n `buildFetchUrl: Constructed URL is not absolute. cloudfrontBaseUrl=${JSON.stringify(cloudfrontBaseUrl)}, url=${JSON.stringify(url)}, result=${JSON.stringify(result)}`\r\n )\r\n }\r\n\r\n return result\r\n }\r\n\r\n // Validate required base URLs for Cloudinary path\r\n if (!cloudinaryBaseUrl || !awsS3BaseUrl) {\r\n throw new Error(\r\n `buildFetchUrl: cloudinaryBaseUrl and awsS3BaseUrl are required. cloudinaryBaseUrl=${JSON.stringify(cloudinaryBaseUrl)}, awsS3BaseUrl=${JSON.stringify(awsS3BaseUrl)}`\r\n )\r\n }\r\n\r\n const transformations = []\r\n let transformationsString = ''\r\n\r\n if (width) transformations.push(`w_${width.toString()}`)\r\n if (height) transformations.push(`h_${height.toString()}`)\r\n if (quality) transformations.push(`q_${quality.toString()}`)\r\n if (fit) transformations.push('c_fit')\r\n\r\n transformationsString = `${transformations.join(',')}/`\r\n\r\n const fetchUrl = `${cloudinaryBaseUrl}/${transformationsString}${awsS3BaseUrl}/${url}`\r\n\r\n // Validate output is absolute URL\r\n if (!isAbsoluteUrl(fetchUrl)) {\r\n throw new Error(\r\n `buildFetchUrl: Constructed URL is not absolute. cloudinaryBaseUrl=${JSON.stringify(cloudinaryBaseUrl)}, awsS3BaseUrl=${JSON.stringify(awsS3BaseUrl)}, url=${JSON.stringify(url)}, result=${JSON.stringify(fetchUrl)}`\r\n )\r\n }\r\n\r\n return fetchUrl\r\n}\r\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEO,SAASC,aAAaA,CAACC,GAAG,EAAEC,OAAO,EAAE;EAC1C;EACA,IAAI,CAACD,GAAG,IAAI,OAAOA,GAAG,KAAK,QAAQ,EAAE;IACnC,MAAM,IAAIE,KAAK,CACb,6CAA6CC,IAAI,CAACC,SAAS,CAACJ,GAAG,CAAC,EAClE,CAAC;EACH;EAEA,MAAM;IACJK,YAAY;IACZC,iBAAiB,GAAG,EAAE;IACtBC,iBAAiB;IACjBC,GAAG;IACHC,MAAM;IACNC,KAAK;IACLC,OAAO;IACPC,mBAAmB;IACnBC,MAAM;IACNC,SAAS;IACTC;EACF,CAAC,GAAGd,OAAO;EAEX,IAAIW,mBAAmB,EAAE;I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AS,CAACG,iBAAiB,CAAC,kBAAkBJ,IAAI,CAACC,SAAS,CAACC,YAAY,CAAC,EACtK,CAAC;EACH;EAEA,MAAM0B,eAAe,GAAG,EAAE;EAC1B,IAAIC,qBAAqB,GAAG,EAAE;EAE9B,IAAItB,KAAK,EAAEqB,eAAe,CAACE,IAAI,CAAC,KAAKvB,KAAK,CAACwB,QAAQ,CAAC,CAAC,EAAE,CAAC;EACxD,IAAIzB,MAAM,EAAEsB,eAAe,CAACE,IAAI,CAAC,KAAKxB,MAAM,CAACyB,QAAQ,CAAC,CAAC,EAAE,CAAC;EAC1D,IAAIvB,OAAO,EAAEoB,eAAe,CAACE,IAAI,CAAC,KAAKtB,OAAO,CAACuB,QAAQ,CAAC,CAAC,EAAE,CAAC;EAC5D,IAAI1B,GAAG,EAAEuB,eAAe,CAACE,IAAI,CAAC,OAAO,CAAC;EAEtCD,qBAAqB,GAAG,GAAGD,eAAe,CAACH,IAAI,CAAC,GAAG,CAAC,GAAG;EAEvD,MAAMO,QAAQ,GAAG,GAAG5B,iBAAiB,IAAIyB,qBAAqB,GAAG3B,YAAY,IAAIL,GAAG,EAAE;;EAEtF;EACA,IAAI,CAAC,IAAA8B,oBAAa,EAACK,QAAQ,CAAC,EAAE;IAC5B,MAAM,IAAIjC,KAAK,CACb,qEAAqEC,IAAI,CAACC,SAAS,CAACG,iBAAiB,CAAC,kBAAkBJ,IAAI,CAACC,SAAS,CAACC,YAAY,CAAC,SAASF,IAAI,CAACC,SAAS,CAACJ,GAAG,CAAC,YAAYG,IAAI,CAACC,SAAS,CAAC+B,QAAQ,CAAC,EACtN,CAAC;EACH;EAEA,OAAOA,QAAQ;AACjB","ignoreList":[]}
@@ -1,26 +1,32 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _typeof from "@babel/runtime/helpers/typeof";
3
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
- import fetchPonyfill from 'fetch-ponyfill';
6
- import Promise from 'bluebird';
7
- import { LIGHTHOUSE_LOGO_URL } from '../../constants';
8
- import { imageNotFound } from '../../images';
9
- import { fetchImageForPdfGeneratorService } from '../fetch-image-for-pdf-generator-service';
10
- import { fetchImageForWeb } from '../fetch-image-for-web';
11
- import { isAbsoluteUrl } from '../validate-url/index.js';
1
+ "use strict";
12
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.arrayBufferToBase64 = arrayBufferToBase64;
8
+ exports.fetchImage = fetchImage;
9
+ exports.validateBase64Image = validateBase64Image;
10
+ exports.validateJpegImage = validateJpegImage;
11
+ exports.validatePngImage = validatePngImage;
12
+ var _fetchPonyfill = _interopRequireDefault(require("fetch-ponyfill"));
13
+ var _bluebird = _interopRequireDefault(require("bluebird"));
14
+ var _constants = require("../../constants");
15
+ var _images = require("../../images");
16
+ var _fetchImageForPdfGeneratorService = require("../fetch-image-for-pdf-generator-service");
17
+ var _fetchImageForWeb = require("../fetch-image-for-web");
18
+ var _index = require("../validate-url/index.js");
13
19
  // NOTE use the native fetch if it's available in the browser, because the
14
20
  // ponyfill (which actually uses the github polyfill) does not support all the
15
21
  // same options as native fetch
16
- var fetch = (typeof self === "undefined" ? "undefined" : _typeof(self)) === 'object' && self.fetch || fetchPonyfill({
17
- Promise: Promise
22
+ const fetch = typeof self === 'object' && self.fetch || (0, _fetchPonyfill.default)({
23
+ Promise: _bluebird.default
18
24
  }).fetch;
19
- var contentTypes = {
25
+ const contentTypes = {
20
26
  'image/png': 'png',
21
27
  'image/jpeg': 'jpeg'
22
28
  };
23
- var defaultOptions = {
29
+ const defaultOptions = {
24
30
  // NOTE The cache: no-cache option is important to avoid an issue with CORS
25
31
  // and caching on Chrome. Here's a good explanation of the issue:
26
32
  // https://stackoverflow.com/a/37455118
@@ -30,128 +36,123 @@ var defaultOptions = {
30
36
  // sent from the fetch request, causing an error
31
37
  cache: 'no-cache'
32
38
  };
33
- export function fetchImage(url) {
34
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
35
- var shouldUseCloudfront = options.shouldUseCloudfront,
36
- _options$isHeader = options.isHeader,
37
- isHeader = _options$isHeader === void 0 ? false : _options$isHeader,
38
- _options$context = options.context,
39
- context = _options$context === void 0 ? {} : _options$context;
39
+ function fetchImage(url, options = {}) {
40
+ const {
41
+ shouldUseCloudfront,
42
+ isHeader = false,
43
+ context = {}
44
+ } = options;
40
45
 
41
46
  // Validate url parameter
42
47
  if (!url || typeof url !== 'string') {
43
- var error = new Error("fetchImage: Invalid url parameter. url=".concat(JSON.stringify(url)));
48
+ const error = new Error(`fetchImage: Invalid url parameter. url=${JSON.stringify(url)}`);
44
49
  if (isHeader) {
45
50
  console.error('FetchImageHeaderError', {
46
51
  message: error.message,
47
- url: url,
48
- context: context
52
+ url,
53
+ context
49
54
  });
50
- return fetchImage(LIGHTHOUSE_LOGO_URL, defaultOptions);
55
+ return fetchImage(_constants.LIGHTHOUSE_LOGO_URL, defaultOptions);
51
56
  }
52
57
  console.error('FetchImageError', {
53
58
  message: error.message,
54
- url: url,
55
- context: context
59
+ url,
60
+ context
56
61
  });
57
- return Promise.resolve(imageNotFound);
62
+ return _bluebird.default.resolve(_images.imageNotFound);
58
63
  }
59
64
  if (shouldUseCloudfront) {
60
- var isWebContext = (typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object';
65
+ const isWebContext = typeof window === 'object';
61
66
  return isWebContext ?
62
67
  // Values used from options: isHeader, Signature, Policy, KeyPairId
63
- fetchImageForWeb(url, options) : fetchImageForPdfGeneratorService(url);
68
+ (0, _fetchImageForWeb.fetchImageForWeb)(url, options) : (0, _fetchImageForPdfGeneratorService.fetchImageForPdfGeneratorService)(url);
64
69
  }
65
- var encodedUrl = encodeURI(url);
66
- var fetchOptions = _objectSpread(_objectSpread({}, defaultOptions), options);
67
- return fetch(encodedUrl, fetchOptions).then(function (response) {
68
- var contentHeader = response.headers.get('content-length');
69
- var contentType = response.headers.get('content-type');
70
+ const encodedUrl = encodeURI(url);
71
+ const fetchOptions = {
72
+ ...defaultOptions,
73
+ ...options
74
+ };
75
+ return fetch(encodedUrl, fetchOptions).then(response => {
76
+ const contentHeader = response.headers.get('content-length');
77
+ const contentType = response.headers.get('content-type');
70
78
 
71
79
  // NOTE: the response will be ok but we won't be able to render any
72
80
  // image meaning pdfmake will error. Raise error here and return early.
73
81
  if (contentHeader === '0') {
74
- return Promise.reject(new Error("Failed to fetch image as no content length: ".concat(url)));
82
+ return _bluebird.default.reject(new Error(`Failed to fetch image as no content length: ${url}`));
75
83
  }
76
84
  if (!response.ok) {
77
- return Promise.reject(new Error("Failed to fetch image: ".concat(url)));
85
+ return _bluebird.default.reject(new Error(`Failed to fetch image: ${url}`));
78
86
  }
79
- var imageType = contentTypes[contentType];
80
- return response.arrayBuffer().then(function (buffer) {
81
- return {
82
- buffer: buffer,
83
- imageType: imageType
84
- };
85
- });
86
- }).then(function (_ref) {
87
- var buffer = _ref.buffer,
88
- imageType = _ref.imageType;
89
- var base64Flag = "data:image/".concat(imageType, ";base64,");
90
- var imageStr = arrayBufferToBase64(buffer);
91
- var base64 = "".concat(base64Flag).concat(imageStr);
92
- var isValid = validateBase64Image(base64);
87
+ const imageType = contentTypes[contentType];
88
+ return response.arrayBuffer().then(buffer => ({
89
+ buffer,
90
+ imageType
91
+ }));
92
+ }).then(({
93
+ buffer,
94
+ imageType
95
+ }) => {
96
+ const base64Flag = `data:image/${imageType};base64,`;
97
+ const imageStr = arrayBufferToBase64(buffer);
98
+ const base64 = `${base64Flag}${imageStr}`;
99
+ const isValid = validateBase64Image(base64);
93
100
  if (!isValid) {
94
- return Promise.reject(new Error('InvalidImageError'));
101
+ return _bluebird.default.reject(new Error('InvalidImageError'));
95
102
  }
96
103
  return base64;
97
- }).catch(function (error) {
104
+ }).catch(error => {
98
105
  if (isHeader) {
99
106
  // NOTE: Replace failed headers with LH logo
100
107
  console.error('FetchImageHeaderError', {
101
- url: url,
108
+ url,
102
109
  message: error.message,
103
- context: context,
110
+ context,
104
111
  stack: error.stack
105
112
  });
106
- return fetchImage(LIGHTHOUSE_LOGO_URL, defaultOptions);
113
+ return fetchImage(_constants.LIGHTHOUSE_LOGO_URL, defaultOptions);
107
114
  }
108
115
  console.error('FetchImageError', {
109
- url: url,
116
+ url,
110
117
  message: error.message,
111
- context: context,
118
+ context,
112
119
  stack: error.stack
113
120
  });
114
- return imageNotFound;
121
+ return _images.imageNotFound;
115
122
  });
116
123
  }
117
- export function arrayBufferToBase64(buffer) {
118
- var binary = '';
119
- var bytes = [].slice.call(new Uint8Array(buffer));
120
- bytes.forEach(function (b) {
121
- return binary += String.fromCharCode(b);
122
- });
124
+ function arrayBufferToBase64(buffer) {
125
+ let binary = '';
126
+ const bytes = [].slice.call(new Uint8Array(buffer));
127
+ bytes.forEach(b => binary += String.fromCharCode(b));
123
128
  return btoa(binary);
124
129
  }
125
- export function validateBase64Image(base64String) {
126
- var isJpeg = base64String.startsWith('data:image/jpeg;base64,');
130
+ function validateBase64Image(base64String) {
131
+ const isJpeg = base64String.startsWith('data:image/jpeg;base64,');
127
132
  if (isJpeg) return validateJpegImage(base64String);
128
- var isPng = base64String.startsWith('data:image/png;base64,');
133
+ const isPng = base64String.startsWith('data:image/png;base64,');
129
134
  if (isPng) return validatePngImage(base64String);
130
135
  return false;
131
136
  }
132
137
 
133
138
  // See SO for more info: https://stackoverflow.com/a/41635312
134
139
  // Fiddle: https://jsfiddle.net/Lnyxuchw/
135
- export function validateJpegImage(base64string) {
136
- var src = base64string;
137
- var imageData = Uint8Array.from(atob(src.replace('data:image/jpeg;base64,', '')), function (c) {
138
- return c.charCodeAt(0);
139
- });
140
- var imageCorrupted = imageData[imageData.length - 1] === 217 && imageData[imageData.length - 2] === 255;
140
+ function validateJpegImage(base64string) {
141
+ const src = base64string;
142
+ const imageData = Uint8Array.from(atob(src.replace('data:image/jpeg;base64,', '')), c => c.charCodeAt(0));
143
+ const imageCorrupted = imageData[imageData.length - 1] === 217 && imageData[imageData.length - 2] === 255;
141
144
  return imageCorrupted;
142
145
  }
143
146
 
144
147
  // See SO for more info: https://stackoverflow.com/a/41635312
145
148
  // Fiddle: https://jsfiddle.net/Lnyxuchw/
146
- export function validatePngImage(base64string) {
147
- var src = base64string;
148
- var imageData = Uint8Array.from(atob(src.replace('data:image/png;base64,', '')), function (c) {
149
- return c.charCodeAt(0);
150
- });
151
- var sequence = [0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130];
149
+ function validatePngImage(base64string) {
150
+ const src = base64string;
151
+ const imageData = Uint8Array.from(atob(src.replace('data:image/png;base64,', '')), c => c.charCodeAt(0));
152
+ const sequence = [0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130];
152
153
 
153
154
  //check last 12 elements of array so they contains needed values
154
- for (var i = 12; i > 0; i--) {
155
+ for (let i = 12; i > 0; i--) {
155
156
  if (imageData[imageData.length - i] !== sequence[12 - i]) {
156
157
  return false;
157
158
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["fetchPonyfill","Promise","LIGHTHOUSE_LOGO_URL","imageNotFound","fetchImageForPdfGeneratorService","fetchImageForWeb","isAbsoluteUrl","fetch","self","_typeof","contentTypes","defaultOptions","cache","fetchImage","url","options","arguments","length","undefined","shouldUseCloudfront","_options$isHeader","isHeader","_options$context","context","error","Error","concat","JSON","stringify","console","message","resolve","isWebContext","window","encodedUrl","encodeURI","fetchOptions","_objectSpread","then","response","contentHeader","headers","get","contentType","reject","ok","imageType","arrayBuffer","buffer","_ref","base64Flag","imageStr","arrayBufferToBase64","base64","isValid","validateBase64Image","catch","stack","binary","bytes","slice","call","Uint8Array","forEach","b","String","fromCharCode","btoa","base64String","isJpeg","startsWith","validateJpegImage","isPng","validatePngImage","base64string","src","imageData","from","atob","replace","c","charCodeAt","imageCorrupted","sequence","i"],"sources":["../../../src/helpers/fetch-image/index.js"],"sourcesContent":["import fetchPonyfill from 'fetch-ponyfill'\nimport Promise from 'bluebird'\nimport { LIGHTHOUSE_LOGO_URL } from '../../constants'\nimport { imageNotFound } from '../../images'\nimport { fetchImageForPdfGeneratorService } from '../fetch-image-for-pdf-generator-service'\nimport { fetchImageForWeb } from '../fetch-image-for-web'\nimport { isAbsoluteUrl } from '../validate-url/index.js'\n\n// NOTE use the native fetch if it's available in the browser, because the\n// ponyfill (which actually uses the github polyfill) does not support all the\n// same options as native fetch\nconst fetch =\n (typeof self === 'object' && self.fetch) || fetchPonyfill({ Promise }).fetch\n\nconst contentTypes = {\n 'image/png': 'png',\n 'image/jpeg': 'jpeg',\n}\n\nconst defaultOptions = {\n // NOTE The cache: no-cache option is important to avoid an issue with CORS\n // and caching on Chrome. Here's a good explanation of the issue:\n // https://stackoverflow.com/a/37455118\n // In our case, when loading the web version of a form, the signature image is\n // cached without the correct CORS headers. If the pdf is then generated,\n // there's a mismatch between the cached image headers and the CORS headers\n // sent from the fetch request, causing an error\n cache: 'no-cache',\n}\n\nexport function fetchImage(url, options = {}) {\n const { shouldUseCloudfront, isHeader = false, context = {} } = options\n\n // Validate url parameter\n if (!url || typeof url !== 'string') {\n const error = new Error(\n `fetchImage: Invalid url parameter. url=${JSON.stringify(url)}`\n )\n if (isHeader) {\n console.error('FetchImageHeaderError', {\n message: error.message,\n url,\n context,\n })\n return fetchImage(LIGHTHOUSE_LOGO_URL, defaultOptions)\n }\n console.error('FetchImageError', {\n message: error.message,\n url,\n context,\n })\n return Promise.resolve(imageNotFound)\n }\n\n if (shouldUseCloudfront) {\n const isWebContext = typeof window === 'object'\n\n return isWebContext\n ? // Values used from options: isHeader, Signature, Policy, KeyPairId\n fetchImageForWeb(url, options)\n : fetchImageForPdfGeneratorService(url)\n }\n\n const encodedUrl = encodeURI(url)\n\n const fetchOptions = {\n ...defaultOptions,\n ...options,\n }\n\n return fetch(encodedUrl, fetchOptions)\n .then((response) => {\n const contentHeader = response.headers.get('content-length')\n const contentType = response.headers.get('content-type')\n\n // NOTE: the response will be ok but we won't be able to render any\n // image meaning pdfmake will error. Raise error here and return early.\n if (contentHeader === '0') {\n return Promise.reject(\n new Error(`Failed to fetch image as no content length: ${url}`)\n )\n }\n\n if (!response.ok) {\n return Promise.reject(new Error(`Failed to fetch image: ${url}`))\n }\n\n const imageType = contentTypes[contentType]\n\n return response.arrayBuffer().then((buffer) => ({\n buffer,\n imageType,\n }))\n })\n .then(({ buffer, imageType }) => {\n const base64Flag = `data:image/${imageType};base64,`\n const imageStr = arrayBufferToBase64(buffer)\n\n const base64 = `${base64Flag}${imageStr}`\n const isValid = validateBase64Image(base64)\n\n if (!isValid) {\n return Promise.reject(new Error('InvalidImageError'))\n }\n\n return base64\n })\n .catch((error) => {\n if (isHeader) {\n // NOTE: Replace failed headers with LH logo\n console.error('FetchImageHeaderError', {\n url,\n message: error.message,\n context,\n stack: error.stack,\n })\n return fetchImage(LIGHTHOUSE_LOGO_URL, defaultOptions)\n }\n\n console.error('FetchImageError', {\n url,\n message: error.message,\n context,\n stack: error.stack,\n })\n return imageNotFound\n })\n}\n\nexport function arrayBufferToBase64(buffer) {\n let binary = ''\n const bytes = [].slice.call(new Uint8Array(buffer))\n\n bytes.forEach((b) => (binary += String.fromCharCode(b)))\n\n return btoa(binary)\n}\n\nexport function validateBase64Image(base64String) {\n const isJpeg = base64String.startsWith('data:image/jpeg;base64,')\n\n if (isJpeg) return validateJpegImage(base64String)\n\n const isPng = base64String.startsWith('data:image/png;base64,')\n\n if (isPng) return validatePngImage(base64String)\n\n return false\n}\n\n// See SO for more info: https://stackoverflow.com/a/41635312\n// Fiddle: https://jsfiddle.net/Lnyxuchw/\nexport function validateJpegImage(base64string) {\n const src = base64string\n const imageData = Uint8Array.from(\n atob(src.replace('data:image/jpeg;base64,', '')),\n (c) => c.charCodeAt(0)\n )\n const imageCorrupted =\n imageData[imageData.length - 1] === 217 &&\n imageData[imageData.length - 2] === 255\n\n return imageCorrupted\n}\n\n// See SO for more info: https://stackoverflow.com/a/41635312\n// Fiddle: https://jsfiddle.net/Lnyxuchw/\nexport function validatePngImage(base64string) {\n const src = base64string\n const imageData = Uint8Array.from(\n atob(src.replace('data:image/png;base64,', '')),\n (c) => c.charCodeAt(0)\n )\n const sequence = [0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130]\n\n //check last 12 elements of array so they contains needed values\n for (let i = 12; i > 0; i--) {\n if (imageData[imageData.length - i] !== sequence[12 - i]) {\n return false\n }\n }\n\n return true\n}\n"],"mappings":";;;;AAAA,OAAOA,aAAa,MAAM,gBAAgB;AAC1C,OAAOC,OAAO,MAAM,UAAU;AAC9B,SAASC,mBAAmB,QAAQ,iBAAiB;AACrD,SAASC,aAAa,QAAQ,cAAc;AAC5C,SAASC,gCAAgC,QAAQ,0CAA0C;AAC3F,SAASC,gBAAgB,QAAQ,wBAAwB;AACzD,SAASC,aAAa,QAAQ,0BAA0B;;AAExD;AACA;AACA;AACA,IAAMC,KAAK,GACR,QAAOC,IAAI,iCAAAC,OAAA,CAAJD,IAAI,OAAK,QAAQ,IAAIA,IAAI,CAACD,KAAK,IAAKP,aAAa,CAAC;EAAEC,OAAO,EAAPA;AAAQ,CAAC,CAAC,CAACM,KAAK;AAE9E,IAAMG,YAAY,GAAG;EACnB,WAAW,EAAE,KAAK;EAClB,YAAY,EAAE;AAChB,CAAC;AAED,IAAMC,cAAc,GAAG;EACrB;EACA;EACA;EACA;EACA;EACA;EACA;EACAC,KAAK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,EAAEA,CAAC,GAAG,CAAC,EAAEA,CAAC,EAAE,EAAE;IAC3B,IAAIR,SAAS,CAACA,SAAS,CAAC3D,MAAM,GAAGmE,CAAC,CAAC,KAAKD,QAAQ,CAAC,EAAE,GAAGC,CAAC,CAAC,EAAE;MACxD,OAAO,KAAK;IACd;EACF;EAEA,OAAO,IAAI;AACb","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_fetchPonyfill","_interopRequireDefault","require","_bluebird","_constants","_images","_fetchImageForPdfGeneratorService","_fetchImageForWeb","_index","fetch","self","fetchPonyfill","Promise","contentTypes","defaultOptions","cache","fetchImage","url","options","shouldUseCloudfront","isHeader","context","error","Error","JSON","stringify","console","message","LIGHTHOUSE_LOGO_URL","resolve","imageNotFound","isWebContext","window","fetchImageForWeb","fetchImageForPdfGeneratorService","encodedUrl","encodeURI","fetchOptions","then","response","contentHeader","headers","get","contentType","reject","ok","imageType","arrayBuffer","buffer","base64Flag","imageStr","arrayBufferToBase64","base64","isValid","validateBase64Image","catch","stack","binary","bytes","slice","call","Uint8Array","forEach","b","String","fromCharCode","btoa","base64String","isJpeg","startsWith","validateJpegImage","isPng","validatePngImage","base64string","src","imageData","from","atob","replace","c","charCodeAt","imageCorrupted","length","sequence","i"],"sources":["../../../src/helpers/fetch-image/index.js"],"sourcesContent":["import fetchPonyfill from 'fetch-ponyfill'\r\nimport Promise from 'bluebird'\r\nimport { LIGHTHOUSE_LOGO_URL } from '../../constants'\r\nimport { imageNotFound } from '../../images'\r\nimport { fetchImageForPdfGeneratorService } from '../fetch-image-for-pdf-generator-service'\r\nimport { fetchImageForWeb } from '../fetch-image-for-web'\r\nimport { isAbsoluteUrl } from '../validate-url/index.js'\r\n\r\n// NOTE use the native fetch if it's available in the browser, because the\r\n// ponyfill (which actually uses the github polyfill) does not support all the\r\n// same options as native fetch\r\nconst fetch =\r\n (typeof self === 'object' && self.fetch) || fetchPonyfill({ Promise }).fetch\r\n\r\nconst contentTypes = {\r\n 'image/png': 'png',\r\n 'image/jpeg': 'jpeg',\r\n}\r\n\r\nconst defaultOptions = {\r\n // NOTE The cache: no-cache option is important to avoid an issue with CORS\r\n // and caching on Chrome. Here's a good explanation of the issue:\r\n // https://stackoverflow.com/a/37455118\r\n // In our case, when loading the web version of a form, the signature image is\r\n // cached without the correct CORS headers. If the pdf is then generated,\r\n // there's a mismatch between the cached image headers and the CORS headers\r\n // sent from the fetch request, causing an error\r\n cache: 'no-cache',\r\n}\r\n\r\nexport function fetchImage(url, options = {}) {\r\n const { shouldUseCloudfront, isHeader = false, context = {} } = options\r\n\r\n // Validate url parameter\r\n if (!url || typeof url !== 'string') {\r\n const error = new Error(\r\n `fetchImage: Invalid url parameter. url=${JSON.stringify(url)}`\r\n )\r\n if (isHeader) {\r\n console.error('FetchImageHeaderError', {\r\n message: error.message,\r\n url,\r\n context,\r\n })\r\n return fetchImage(LIGHTHOUSE_LOGO_URL, defaultOptions)\r\n }\r\n console.error('FetchImageError', {\r\n message: error.message,\r\n url,\r\n context,\r\n })\r\n return Promise.resolve(imageNotFound)\r\n }\r\n\r\n if (shouldUseCloudfront) {\r\n const isWebContext = typeof window === 'object'\r\n\r\n return isWebContext\r\n ? // Values used from options: isHeader, Signature, Policy, KeyPairId\r\n fetchImageForWeb(url, options)\r\n : fetchImageForPdfGeneratorService(url)\r\n }\r\n\r\n const encodedUrl = encodeURI(url)\r\n\r\n const fetchOptions = {\r\n ...defaultOptions,\r\n ...options,\r\n }\r\n\r\n return fetch(encodedUrl, fetchOptions)\r\n .then((response) => {\r\n const contentHeader = response.headers.get('content-length')\r\n const contentType = response.headers.get('content-type')\r\n\r\n // NOTE: the response will be ok but we won't be able to render any\r\n // image meaning pdfmake will error. Raise error here and return early.\r\n if (contentHeader === '0') {\r\n return Promise.reject(\r\n new Error(`Failed to fetch image as no content length: ${url}`)\r\n )\r\n }\r\n\r\n if (!response.ok) {\r\n return Promise.reject(new Error(`Failed to fetch image: ${url}`))\r\n }\r\n\r\n const imageType = contentTypes[contentType]\r\n\r\n return response.arrayBuffer().then((buffer) => ({\r\n buffer,\r\n imageType,\r\n }))\r\n })\r\n .then(({ buffer, imageType }) => {\r\n const base64Flag = `data:image/${imageType};base64,`\r\n const imageStr = arrayBufferToBase64(buffer)\r\n\r\n const base64 = `${base64Flag}${imageStr}`\r\n const isValid = validateBase64Image(base64)\r\n\r\n if (!isValid) {\r\n return Promise.reject(new Error('InvalidImageError'))\r\n }\r\n\r\n return base64\r\n })\r\n .catch((error) => {\r\n if (isHeader) {\r\n // NOTE: Replace failed headers with LH logo\r\n console.error('FetchImageHeaderError', {\r\n url,\r\n message: error.message,\r\n context,\r\n stack: error.stack,\r\n })\r\n return fetchImage(LIGHTHOUSE_LOGO_URL, defaultOptions)\r\n }\r\n\r\n console.error('FetchImageError', {\r\n url,\r\n message: error.message,\r\n context,\r\n stack: error.stack,\r\n })\r\n return imageNotFound\r\n })\r\n}\r\n\r\nexport function arrayBufferToBase64(buffer) {\r\n let binary = ''\r\n const bytes = [].slice.call(new Uint8Array(buffer))\r\n\r\n bytes.forEach((b) => (binary += String.fromCharCode(b)))\r\n\r\n return btoa(binary)\r\n}\r\n\r\nexport function validateBase64Image(base64String) {\r\n const isJpeg = base64String.startsWith('data:image/jpeg;base64,')\r\n\r\n if (isJpeg) return validateJpegImage(base64String)\r\n\r\n const isPng = base64String.startsWith('data:image/png;base64,')\r\n\r\n if (isPng) return validatePngImage(base64String)\r\n\r\n return false\r\n}\r\n\r\n// See SO for more info: https://stackoverflow.com/a/41635312\r\n// Fiddle: https://jsfiddle.net/Lnyxuchw/\r\nexport function validateJpegImage(base64string) {\r\n const src = base64string\r\n const imageData = Uint8Array.from(\r\n atob(src.replace('data:image/jpeg;base64,', '')),\r\n (c) => c.charCodeAt(0)\r\n )\r\n const imageCorrupted =\r\n imageData[imageData.length - 1] === 217 &&\r\n imageData[imageData.length - 2] === 255\r\n\r\n return imageCorrupted\r\n}\r\n\r\n// See SO for more info: https://stackoverflow.com/a/41635312\r\n// Fiddle: https://jsfiddle.net/Lnyxuchw/\r\nexport function validatePngImage(base64string) {\r\n const src = base64string\r\n const imageData = Uint8Array.from(\r\n atob(src.replace('data:image/png;base64,', '')),\r\n (c) => c.charCodeAt(0)\r\n )\r\n const sequence = [0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130]\r\n\r\n //check last 12 elements of array so they contains needed values\r\n for (let i = 12; i > 0; i--) {\r\n if (imageData[imageData.length - i] !== sequence[12 - i]) {\r\n return false\r\n }\r\n }\r\n\r\n return true\r\n}\r\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,iCAAA,GAAAJ,OAAA;AACA,IAAAK,iBAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAEA;AACA;AACA;AACA,MAAMO,KAAK,GACR,OAAOC,IAAI,KAAK,QAAQ,IAAIA,IAAI,CAACD,KAAK,IAAK,IAAAE,sBAAa,EAAC;EAAEC,OAAO,EAAPA;AAAQ,CAAC,CAAC,CAACH,KAAK;AAE9E,MAAMI,YAAY,GAAG;EACnB,WAAW,EAAE,KAAK;EAClB,YAAY,EAAE;AAChB,CAAC;AAED,MAAMC,cAAc,GAAG;EACrB;EACA;EACA;EACA;EACA;EACA;EACA;EACAC,KAAK,EAAE;AACT,CAAC;AAEM,SAASC,UAAUA,CAACC,GAAG,EAAEC,OAAO,GAAG,CAAC,CAAC,EAAE;EAC5C,MAAM;IAAEC,mBAAmB;IAAEC,QAAQ,GAAG,KAAK;IAAEC,OAAO,GAAG,CAAC;EAAE,CAAC,GAAGH,OAAO;;EAEvE;EACA,IAAI,CAACD,GAAG,IAAI,OAAOA,GAAG,KAAK,QAAQ,EAAE;IACnC,MAAMK,KAAK,GAAG,IAAIC,KAAK,CACr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