@agnostack/next-shopify 1.15.0-beta.2 → 1.15.0-beta.21

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 (273) hide show
  1. package/CHANGELOG.md +136 -0
  2. package/dist/lib/handlers/api/auth.js +15 -11
  3. package/dist/lib/handlers/api/auth.js.map +1 -1
  4. package/dist/lib/handlers/api/billing.js +13 -9
  5. package/dist/lib/handlers/api/billing.js.map +1 -1
  6. package/dist/lib/handlers/api/callback.js +37 -33
  7. package/dist/lib/handlers/api/callback.js.map +1 -1
  8. package/dist/lib/handlers/api/index.js +25 -7
  9. package/dist/lib/handlers/api/index.js.map +1 -1
  10. package/dist/lib/handlers/api/uninstall.js +12 -8
  11. package/dist/lib/handlers/api/uninstall.js.map +1 -1
  12. package/dist/lib/handlers/api/verifiable/appInstallation.js +11 -7
  13. package/dist/lib/handlers/api/verifiable/appInstallation.js.map +1 -1
  14. package/dist/lib/handlers/api/verifiable/graph.js +26 -22
  15. package/dist/lib/handlers/api/verifiable/graph.js.map +1 -1
  16. package/dist/lib/handlers/api/verifiable/index.js +21 -5
  17. package/dist/lib/handlers/api/verifiable/index.js.map +1 -1
  18. package/dist/lib/handlers/api/verifiable/proxy.js +39 -32
  19. package/dist/lib/handlers/api/verifiable/proxy.js.map +1 -1
  20. package/dist/lib/handlers/api/verifiable/rest.js +23 -19
  21. package/dist/lib/handlers/api/verifiable/rest.js.map +1 -1
  22. package/dist/lib/handlers/api/verifiable/token.js +27 -23
  23. package/dist/lib/handlers/api/verifiable/token.js.map +1 -1
  24. package/dist/lib/handlers/api/webhook.js +13 -9
  25. package/dist/lib/handlers/api/webhook.js.map +1 -1
  26. package/dist/lib/handlers/index.js +18 -2
  27. package/dist/lib/handlers/index.js.map +1 -1
  28. package/dist/lib/handlers/ssr/index.js +18 -2
  29. package/dist/lib/handlers/ssr/index.js.map +1 -1
  30. package/dist/lib/handlers/ssr/protect.js +24 -17
  31. package/dist/lib/handlers/ssr/protect.js.map +1 -1
  32. package/dist/lib/handlers/ssr/wrap.js +10 -6
  33. package/dist/lib/handlers/ssr/wrap.js.map +1 -1
  34. package/dist/lib/index.d.ts +1 -1
  35. package/dist/lib/index.d.ts.map +1 -1
  36. package/dist/lib/index.js +24 -5
  37. package/dist/lib/index.js.map +1 -1
  38. package/dist/lib/utils/billing.js +23 -18
  39. package/dist/lib/utils/billing.js.map +1 -1
  40. package/dist/lib/utils/crypto.d.ts +1 -1
  41. package/dist/lib/utils/crypto.d.ts.map +1 -1
  42. package/dist/lib/utils/crypto.js +25 -15
  43. package/dist/lib/utils/crypto.js.map +1 -1
  44. package/dist/lib/utils/firebase.js +29 -17
  45. package/dist/lib/utils/firebase.js.map +1 -1
  46. package/dist/lib/utils/headers.js +13 -6
  47. package/dist/lib/utils/headers.js.map +1 -1
  48. package/dist/lib/utils/index.js +24 -8
  49. package/dist/lib/utils/index.js.map +1 -1
  50. package/dist/lib/utils/session.js +64 -59
  51. package/dist/lib/utils/session.js.map +1 -1
  52. package/dist/lib/utils/shopify-api-js/oauth.js +23 -16
  53. package/dist/lib/utils/shopify-api-js/oauth.js.map +1 -1
  54. package/dist/lib/utils/shopify.js +37 -25
  55. package/dist/lib/utils/shopify.js.map +1 -1
  56. package/dist/lib/utils/token.js +15 -11
  57. package/dist/lib/utils/token.js.map +1 -1
  58. package/dist/plugins/index.d.ts +3 -0
  59. package/dist/plugins/index.d.ts.map +1 -0
  60. package/dist/plugins/index.js +19 -0
  61. package/dist/plugins/index.js.map +1 -0
  62. package/dist/plugins/types.d.ts +1 -0
  63. package/dist/plugins/types.d.ts.map +1 -0
  64. package/dist/plugins/types.js +1 -0
  65. package/dist/plugins/types.js.map +1 -0
  66. package/dist/plugins/withShopify.d.ts.map +1 -0
  67. package/dist/{lib → plugins}/withShopify.js +83 -77
  68. package/dist/plugins/withShopify.js.map +1 -0
  69. package/dist/react/hooks/index.js +17 -1
  70. package/dist/react/hooks/index.js.map +1 -1
  71. package/dist/react/hooks/useVerification.d.ts +1 -1
  72. package/dist/react/hooks/useVerification.js +23 -7
  73. package/dist/react/hooks/useVerification.js.map +1 -1
  74. package/dist/react/index.d.ts +1 -0
  75. package/dist/react/index.d.ts.map +1 -1
  76. package/dist/react/index.js +18 -1
  77. package/dist/react/index.js.map +1 -1
  78. package/dist/runtime/index.js +17 -1
  79. package/dist/runtime/index.js.map +1 -1
  80. package/dist/shared/WebCrypto.d.ts +55 -0
  81. package/dist/shared/WebCrypto.d.ts.map +1 -0
  82. package/dist/shared/WebCrypto.js +345 -0
  83. package/dist/shared/WebCrypto.js.map +1 -0
  84. package/dist/shared/constants.js +15 -11
  85. package/dist/shared/constants.js.map +1 -1
  86. package/dist/shared/datetime.js +110 -83
  87. package/dist/shared/datetime.js.map +1 -1
  88. package/dist/shared/display.d.ts +0 -2
  89. package/dist/shared/display.d.ts.map +1 -1
  90. package/dist/shared/display.js +231 -155
  91. package/dist/shared/display.js.map +1 -1
  92. package/dist/shared/errors.js +12 -5
  93. package/dist/shared/errors.js.map +1 -1
  94. package/dist/shared/graph.js +14 -11
  95. package/dist/shared/graph.js.map +1 -1
  96. package/dist/shared/index.d.ts +2 -1
  97. package/dist/shared/index.d.ts.map +1 -1
  98. package/dist/shared/index.js +32 -10
  99. package/dist/shared/index.js.map +1 -1
  100. package/dist/shared/match.js +25 -17
  101. package/dist/shared/match.js.map +1 -1
  102. package/dist/shared/request.d.ts.map +1 -1
  103. package/dist/shared/request.js +19 -13
  104. package/dist/shared/request.js.map +1 -1
  105. package/dist/shared/shopify.js +31 -21
  106. package/dist/shared/shopify.js.map +1 -1
  107. package/dist/shared/uuid.d.ts +3 -0
  108. package/dist/shared/uuid.d.ts.map +1 -0
  109. package/dist/shared/uuid.js +10 -0
  110. package/dist/shared/uuid.js.map +1 -0
  111. package/dist/shared/verification.d.ts +12 -5
  112. package/dist/shared/verification.d.ts.map +1 -1
  113. package/dist/shared/verification.js +34 -23
  114. package/dist/shared/verification.js.map +1 -1
  115. package/dist/umd/lib/index.d.ts +1 -1
  116. package/dist/umd/lib/index.d.ts.map +1 -1
  117. package/dist/umd/lib/utils/crypto.d.ts +1 -1
  118. package/dist/umd/lib/utils/crypto.d.ts.map +1 -1
  119. package/dist/umd/plugins/index.d.ts +3 -0
  120. package/dist/umd/plugins/index.d.ts.map +1 -0
  121. package/dist/umd/plugins/types.d.ts +1 -0
  122. package/dist/umd/plugins/types.d.ts.map +1 -0
  123. package/dist/umd/plugins/withShopify.d.ts.map +1 -0
  124. package/dist/umd/react/hooks/useVerification.d.ts +1 -1
  125. package/dist/umd/react/index.d.ts +1 -0
  126. package/dist/umd/react/index.d.ts.map +1 -1
  127. package/dist/umd/shared/WebCrypto.d.ts +55 -0
  128. package/dist/umd/shared/WebCrypto.d.ts.map +1 -0
  129. package/dist/umd/shared/display.d.ts +0 -2
  130. package/dist/umd/shared/display.d.ts.map +1 -1
  131. package/dist/umd/shared/index.d.ts +2 -1
  132. package/dist/umd/shared/index.d.ts.map +1 -1
  133. package/dist/umd/shared/request.d.ts.map +1 -1
  134. package/dist/umd/shared/uuid.d.ts +3 -0
  135. package/dist/umd/shared/uuid.d.ts.map +1 -0
  136. package/dist/umd/shared/verification.d.ts +12 -5
  137. package/dist/umd/shared/verification.d.ts.map +1 -1
  138. package/dist/umd/verification/index.d.ts +2 -0
  139. package/dist/umd/verification/index.d.ts.map +1 -1
  140. package/dist/umd/verification/utils/errors.d.ts.map +1 -0
  141. package/dist/umd/verification/utils/index.d.ts +3 -0
  142. package/dist/umd/verification/utils/index.d.ts.map +1 -0
  143. package/dist/umd/verification/utils/rawbody.d.ts.map +1 -0
  144. package/dist/umd/verification/verification.d.ts +3 -1
  145. package/dist/umd/verification/verification.d.ts.map +1 -1
  146. package/dist/umd/verification.js +901 -0
  147. package/dist/umd/verification.js.map +1 -0
  148. package/dist/verification/index.d.ts +2 -0
  149. package/dist/verification/index.d.ts.map +1 -1
  150. package/dist/verification/index.js +19 -1
  151. package/dist/verification/index.js.map +1 -1
  152. package/dist/verification/utils/errors.d.ts.map +1 -0
  153. package/dist/verification/{errors.js → utils/errors.js} +5 -1
  154. package/dist/verification/utils/errors.js.map +1 -0
  155. package/dist/verification/utils/index.d.ts +3 -0
  156. package/dist/verification/utils/index.d.ts.map +1 -0
  157. package/dist/verification/utils/index.js +19 -0
  158. package/dist/verification/utils/index.js.map +1 -0
  159. package/dist/verification/utils/rawbody.d.ts.map +1 -0
  160. package/dist/verification/utils/rawbody.js +57 -0
  161. package/dist/verification/utils/rawbody.js.map +1 -0
  162. package/dist/verification/verification.d.ts +3 -1
  163. package/dist/verification/verification.d.ts.map +1 -1
  164. package/dist/verification/verification.js +71 -62
  165. package/dist/verification/verification.js.map +1 -1
  166. package/package.json +12 -12
  167. package/dist/lib/withShopify.d.ts.map +0 -1
  168. package/dist/lib/withShopify.js.map +0 -1
  169. package/dist/shared/subtlecrypto.d.ts +0 -41
  170. package/dist/shared/subtlecrypto.d.ts.map +0 -1
  171. package/dist/shared/subtlecrypto.js +0 -256
  172. package/dist/shared/subtlecrypto.js.map +0 -1
  173. package/dist/umd/lib/withShopify.d.ts.map +0 -1
  174. package/dist/umd/shared/subtlecrypto.d.ts +0 -41
  175. package/dist/umd/shared/subtlecrypto.d.ts.map +0 -1
  176. package/dist/umd/umd-verification.js +0 -968
  177. package/dist/umd/umd-verification.js.map +0 -1
  178. package/dist/umd/verification/errors.d.ts.map +0 -1
  179. package/dist/umd/verification/rawbody.d.ts.map +0 -1
  180. package/dist/verification/errors.d.ts.map +0 -1
  181. package/dist/verification/errors.js.map +0 -1
  182. package/dist/verification/rawbody.d.ts.map +0 -1
  183. package/dist/verification/rawbody.js +0 -31
  184. package/dist/verification/rawbody.js.map +0 -1
  185. package/node_modules/bytes/History.md +0 -97
  186. package/node_modules/bytes/LICENSE +0 -23
  187. package/node_modules/bytes/Readme.md +0 -152
  188. package/node_modules/bytes/index.js +0 -170
  189. package/node_modules/bytes/package.json +0 -42
  190. package/node_modules/depd/History.md +0 -103
  191. package/node_modules/depd/LICENSE +0 -22
  192. package/node_modules/depd/Readme.md +0 -280
  193. package/node_modules/depd/index.js +0 -538
  194. package/node_modules/depd/lib/browser/index.js +0 -77
  195. package/node_modules/depd/package.json +0 -45
  196. package/node_modules/http-errors/HISTORY.md +0 -180
  197. package/node_modules/http-errors/LICENSE +0 -23
  198. package/node_modules/http-errors/README.md +0 -169
  199. package/node_modules/http-errors/index.js +0 -289
  200. package/node_modules/http-errors/package.json +0 -50
  201. package/node_modules/iconv-lite/Changelog.md +0 -162
  202. package/node_modules/iconv-lite/LICENSE +0 -21
  203. package/node_modules/iconv-lite/README.md +0 -156
  204. package/node_modules/iconv-lite/encodings/dbcs-codec.js +0 -555
  205. package/node_modules/iconv-lite/encodings/dbcs-data.js +0 -176
  206. package/node_modules/iconv-lite/encodings/index.js +0 -22
  207. package/node_modules/iconv-lite/encodings/internal.js +0 -188
  208. package/node_modules/iconv-lite/encodings/sbcs-codec.js +0 -72
  209. package/node_modules/iconv-lite/encodings/sbcs-data-generated.js +0 -451
  210. package/node_modules/iconv-lite/encodings/sbcs-data.js +0 -174
  211. package/node_modules/iconv-lite/encodings/tables/big5-added.json +0 -122
  212. package/node_modules/iconv-lite/encodings/tables/cp936.json +0 -264
  213. package/node_modules/iconv-lite/encodings/tables/cp949.json +0 -273
  214. package/node_modules/iconv-lite/encodings/tables/cp950.json +0 -177
  215. package/node_modules/iconv-lite/encodings/tables/eucjp.json +0 -182
  216. package/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +0 -1
  217. package/node_modules/iconv-lite/encodings/tables/gbk-added.json +0 -55
  218. package/node_modules/iconv-lite/encodings/tables/shiftjis.json +0 -125
  219. package/node_modules/iconv-lite/encodings/utf16.js +0 -177
  220. package/node_modules/iconv-lite/encodings/utf7.js +0 -290
  221. package/node_modules/iconv-lite/lib/bom-handling.js +0 -52
  222. package/node_modules/iconv-lite/lib/extend-node.js +0 -217
  223. package/node_modules/iconv-lite/lib/index.d.ts +0 -24
  224. package/node_modules/iconv-lite/lib/index.js +0 -153
  225. package/node_modules/iconv-lite/lib/streams.js +0 -121
  226. package/node_modules/iconv-lite/package.json +0 -46
  227. package/node_modules/inherits/LICENSE +0 -16
  228. package/node_modules/inherits/README.md +0 -42
  229. package/node_modules/inherits/inherits.js +0 -9
  230. package/node_modules/inherits/inherits_browser.js +0 -27
  231. package/node_modules/inherits/package.json +0 -29
  232. package/node_modules/raw-body/HISTORY.md +0 -308
  233. package/node_modules/raw-body/LICENSE +0 -22
  234. package/node_modules/raw-body/README.md +0 -223
  235. package/node_modules/raw-body/SECURITY.md +0 -24
  236. package/node_modules/raw-body/index.d.ts +0 -87
  237. package/node_modules/raw-body/index.js +0 -336
  238. package/node_modules/raw-body/package.json +0 -49
  239. package/node_modules/safer-buffer/LICENSE +0 -21
  240. package/node_modules/safer-buffer/Porting-Buffer.md +0 -268
  241. package/node_modules/safer-buffer/Readme.md +0 -156
  242. package/node_modules/safer-buffer/dangerous.js +0 -58
  243. package/node_modules/safer-buffer/package.json +0 -34
  244. package/node_modules/safer-buffer/safer.js +0 -77
  245. package/node_modules/safer-buffer/tests.js +0 -406
  246. package/node_modules/setprototypeof/LICENSE +0 -13
  247. package/node_modules/setprototypeof/README.md +0 -31
  248. package/node_modules/setprototypeof/index.d.ts +0 -2
  249. package/node_modules/setprototypeof/index.js +0 -17
  250. package/node_modules/setprototypeof/package.json +0 -38
  251. package/node_modules/setprototypeof/test/index.js +0 -24
  252. package/node_modules/statuses/HISTORY.md +0 -82
  253. package/node_modules/statuses/LICENSE +0 -23
  254. package/node_modules/statuses/README.md +0 -136
  255. package/node_modules/statuses/codes.json +0 -65
  256. package/node_modules/statuses/index.js +0 -146
  257. package/node_modules/statuses/package.json +0 -49
  258. package/node_modules/toidentifier/HISTORY.md +0 -9
  259. package/node_modules/toidentifier/LICENSE +0 -21
  260. package/node_modules/toidentifier/README.md +0 -61
  261. package/node_modules/toidentifier/index.js +0 -32
  262. package/node_modules/toidentifier/package.json +0 -38
  263. package/node_modules/unpipe/HISTORY.md +0 -4
  264. package/node_modules/unpipe/LICENSE +0 -22
  265. package/node_modules/unpipe/README.md +0 -43
  266. package/node_modules/unpipe/index.js +0 -69
  267. package/node_modules/unpipe/package.json +0 -27
  268. /package/dist/{lib → plugins}/withShopify.d.ts +0 -0
  269. /package/dist/umd/{lib → plugins}/withShopify.d.ts +0 -0
  270. /package/dist/umd/verification/{errors.d.ts → utils/errors.d.ts} +0 -0
  271. /package/dist/umd/verification/{rawbody.d.ts → utils/rawbody.d.ts} +0 -0
  272. /package/dist/verification/{errors.d.ts → utils/errors.d.ts} +0 -0
  273. /package/dist/verification/{rawbody.d.ts → utils/rawbody.d.ts} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"umd-verification.js","sources":["../../node_modules/browser-monads-ts/dist/browser-monads-ts.es.js","../../src/shared/display.js","../../src/shared/subtlecrypto.js","../../src/shared/request.js","../../node_modules/raw-body/index.js","../../src/verification/rawbody.js","../../src/verification/errors.js","../../src/verification/verification.js"],"sourcesContent":["var n,r=((n=function(){return r}).toString=n.toLocaleString=n[Symbol.toPrimitive]=function(){return \"\"},n.valueOf=function(){return !1},new Proxy(Object.freeze(n),{get:function(n,t){return n.hasOwnProperty(t)?n[t]:r}})),u=function(n){return n===r};\n\nlet win = global.window;\nlet doc = global.document;\nlet nav = global.navigator;\nlet document = typeof doc !== \"undefined\" ? doc : r;\nlet exists = (variable) => !u(variable);\nlet navigator = typeof nav !== \"undefined\" ? nav : r;\nlet window = typeof win !== \"undefined\" ? win : r;\n\nexport { document, exists, navigator, window };\n//# sourceMappingURL=browser-monads-ts.es.js.map\n","/* eslint-disable no-use-before-define */\nimport { v4 as uuidV4 } from 'uuid'\n\n// #region lib-core\n// TODO!!!: keep in sync between next-shopify and lib-core (and lib-utils-js at bottom)\nexport const normalizeShopifyId = (shopifyData) => {\n const isString = isType(shopifyData, 'string')\n if (isString && !shopifyData.startsWith('gid:')) {\n if (!isNumericOnly(shopifyData)) {\n return {}\n }\n\n return {\n id: `${shopifyData}`,\n }\n }\n\n const { id: _entityId, legacyResourceId } = isString\n ? { id: shopifyData }\n : ensureObject(shopifyData)\n\n if (stringEmpty(_entityId) && stringEmpty(legacyResourceId)) {\n return {}\n }\n\n const entity_id = ensureString(_entityId)\n const { entity_type, parsedId } = entity_id.match(/^gid:\\/\\/shopify\\/(?<entity_type>.*)\\/(?<parsedId>[0-9]+).*$/)?.groups ?? {}\n const id = ensureString(parsedId || legacyResourceId)\n\n const hasEntityId = stringNotEmpty(entity_id)\n const hasEntityType = stringNotEmpty(entity_type)\n\n return {\n ...stringNotEmpty(id) && { id },\n ...hasEntityId && { entity_id },\n ...hasEntityType && { entity_type },\n ...(hasEntityId && hasEntityType) && {\n gid: `gid://shopify/${entity_type}/${entity_id}`,\n },\n }\n}\n\nexport const random = (max = 100, min = 1) => {\n const floor = Math.min(max, min)\n return Math.floor(Math.random() * (max - floor + 1)) + floor\n}\n\nexport const nextRandom = (max = 100, min = 1) => {\n const maximum = Math.max(max, 0)\n const minimum = Math.max(min, 0)\n\n let randomNumber = maximum\n\n if (maximum > minimum) {\n do {\n randomNumber = random(maximum, minimum)\n } while (randomNumber === nextRandom.last)\n\n nextRandom.last = randomNumber\n }\n\n return randomNumber\n}\n\nexport const arrayRandom = (_values, _max = 1) => {\n const values = ensureArray(_values)\n const valuesLength = values.length\n const maxLength = Math.min(_max, valuesLength)\n\n if (valuesLength <= maxLength) {\n return values\n }\n\n const arrayLength = valuesLength - 1\n const randomValues = []\n do {\n const newVal = values[nextRandom(arrayLength, 0)]\n if (!randomValues.includes(newVal)) {\n randomValues.push(newVal)\n }\n } while (randomValues.length < maxLength)\n\n return randomValues\n}\n\nexport const arrayRandomItem = (_values) => (\n arrayRandom(_values)[0]\n)\n\nexport const isArray = (value) => (\n // eslint-disable-next-line eqeqeq\n (value != undefined) && Array.isArray(value)\n)\n\nexport const isSet = (value) => (\n // eslint-disable-next-line eqeqeq\n (value != undefined) && (value instanceof Set)\n)\n\nexport const isType = (value, type) => (\n // eslint-disable-next-line eqeqeq, valid-typeof\n (value != undefined) && (typeof value === type)\n)\n\nexport const isTypeEnhanced = (value, type) => {\n switch (true) {\n case (type === 'set'): {\n return isSet(value)\n }\n\n case (type === 'array'): {\n return (\n isArray(value) &&\n !isSet(value)\n )\n }\n\n case (type === 'object'): {\n return (\n isType(value, type) &&\n !isArray(value)\n )\n }\n\n default: {\n return isType(value, type)\n }\n }\n}\n\nexport const safeTrim = (value) => {\n if (isType(value, 'string')) {\n // eslint-disable-next-line no-param-reassign\n value = value.trim()\n }\n\n return value\n}\n\nexport const safeParse = (value, trim) => {\n if (isType(value, 'string')) {\n if (trim) {\n // eslint-disable-next-line no-param-reassign\n value = safeTrim(value)\n }\n\n if (value.startsWith('{') || value.startsWith('[') || value.startsWith('\"')) {\n // eslint-disable-next-line no-param-reassign\n value = JSON.parse(value)\n }\n }\n\n // TODO: should this be value ?? {}\n return value\n}\n\nexport const ensureString = (string) => (\n string ? `${string}` : ''\n)\n\n// HMMM: what if 'string' is an object?\nexport const ensureStringOnly = (string) => (\n // eslint-disable-next-line eqeqeq\n (string != undefined) ? `${string}` : ''\n)\n\nexport const ensureStringAscii = (string) => (\n // eslint-disable-next-line no-control-regex\n ensureStringOnly(string).replace(/[^\\x00-\\x7F]/g, '')\n)\n\nexport const ensureStringClean = (string) => (\n // eslint-disable-next-line no-control-regex\n ensureStringOnly(string).replace(/[^a-z0-9_-]/gi, '')\n)\n\nexport const ensureAlphaNumeric = (string) => (\n // eslint-disable-next-line no-control-regex\n ensureStringOnly(string).replace(/[^a-z0-9]/gi, '')\n)\n\nexport const isNumericOnly = (value) => {\n const [matched] = `${value}`.match(/^([0-9]+)$/) ?? []\n // eslint-disable-next-line eqeqeq\n return (matched != undefined)\n}\n\nexport const isNumericNegatable = (value) => {\n const [matched] = `${value}`.match(/^(-?[0-9]+(\\.[0-9]+)?)?$/) ?? []\n // eslint-disable-next-line eqeqeq\n return (matched != undefined)\n}\n\n// TODO: explore places using ensureNumeric to move to isNumericNegatable\nexport const ensureNumeric = (string) => (\n Number(ensureString(string).replace(/[^0-9.]/gi, ''))\n)\n\nexport const ensureNumericOnly = (string) => (\n Number(ensureString(string).replace(/[^0-9]/gi, ''))\n)\n\n// TODO: update regex to handle negative number returns negative. Something like (?!\\d\\.)(-?\\d+(\\.\\d)?)\nexport const ensureNumericNegatable = (string) => (\n Number(ensureString(string).replace(/[^0-9.-]/gi, ''))\n)\n\nexport const ensureNumericConstrained = (value, { min: _min = 0, max: _max = 100 } = {}) => {\n const min = ensureNumericNegatable(_min)\n const max = ensureNumericNegatable(_max)\n\n return Math.max(\n min,\n Math.min(ensureNumeric(value), max)\n )\n}\n\nexport const ensureArray = (array = []) => (\n // eslint-disable-next-line no-nested-ternary\n !array ? [] : Array.isArray(array) ? array : [array]\n)\n\nexport const ensureArraySet = (arrayOrSet) => (\n ensureArray(isSet(arrayOrSet) ? [...arrayOrSet] : arrayOrSet)\n)\n\nexport const arrayEmpty = (array, disableEmptyString = false) => (\n // eslint-disable-next-line eqeqeq\n !array || !array.length || (array.length === 1 && (array[0] == undefined || (disableEmptyString && stringEmpty(array[0]))))\n)\n\nexport const arrayNotEmpty = (array, disableEmptyString = false) => (\n // eslint-disable-next-line eqeqeq\n !arrayEmpty(array) && array[0] != undefined && (!disableEmptyString || stringNotEmpty(array[0]))\n)\n\nexport const findLastMatch = (array, filterCallback = (value) => (value)) => (\n ensureArray(array).filter(filterCallback).slice(-1)[0]\n)\n\nexport const ensureObject = (object) => (\n object ?? {}\n)\n\n// NOTE: this does not ensure !isType(string)\nexport const objectEmpty = (object) => (\n !object || !Object.keys(object).length\n)\n\nexport const objectNotEmpty = (object) => (\n !objectEmpty(object)\n)\n\nexport const nullable = (object) => (\n (!object || (object === 'null') || (object === undefined) || (object === null))\n ? null // TODO: explore undefined here??\n : object\n)\n\nexport const objectContainsAnyValue = (object) => (\n Object.values(ensureObject(object)).some((value) => nullable(value))\n)\n\nconst isUndefined = (value) => (\n // eslint-disable-next-line eqeqeq\n value == undefined\n)\n\nexport const cleanObject = (object, allowEmptyLeafs, isEmptyCallback) => (\n Object.entries(ensureObject(object)).reduce((\n _cleanedObject,\n [key, _value]\n ) => {\n if (!allowEmptyLeafs && (isEmptyCallback?.(_value) ?? isUndefined(_value))) {\n return _cleanedObject // skip key if null or undefined\n }\n\n const value = !Array.isArray(_value)\n ? cleanObjectValue(_value, allowEmptyLeafs, isEmptyCallback)\n : _value.reduce((_data, __value) => ([\n ..._data,\n cleanObjectValue(__value, allowEmptyLeafs, isEmptyCallback)\n ]), [])\n\n return {\n ..._cleanedObject,\n [key]: value,\n }\n }, {})\n)\n\nconst cleanObjectValue = (value, allowEmptyLeafs, isEmptyCallback) => (\n isType(value, 'object') ? cleanObject(value, allowEmptyLeafs, isEmptyCallback) : value\n)\n\nexport const stringNotEmptyOnly = (stringable) => {\n const string = ensureStringOnly(stringable)\n return ((string.length > 0) && !['null', 'undefined'].includes(string))\n}\n\nexport const stringEmptyOnly = (stringable) => (\n !stringNotEmptyOnly(stringable)\n)\n\nexport const stringNotEmpty = (stringable) => {\n const string = ensureString(stringable)\n return ((string.length > 0) && !['null', 'undefined'].includes(string))\n}\n\nexport const stringEmpty = (stringable) => (\n !stringNotEmpty(stringable)\n)\n\nconst splitString = (splitting, index = splitting.length) => {\n const string = ensureString(splitting)\n return [string.slice(0, index), string.slice(index)]\n}\n\nexport const compareNumber = (number1 = 0, number2 = 0) => (\n number1 - number2\n)\n\nexport const compareString = (string1, string2) => {\n if (stringEmpty(string1)) {\n return 1\n }\n\n if (stringEmpty(string2)) {\n return -1\n }\n\n return ensureString(string1).localeCompare(string2)\n}\n\nexport const compareEntryKeys = ([string1], [string2]) => (\n compareString(string1, string2)\n)\n\nexport const objectToSortedString = (object, separator = '') => (\n Object.entries(ensureObject(object))\n .sort(compareEntryKeys)\n .map(([key, value]) => `${key}=${value}`)\n .join(separator)\n)\n\nexport const isHTML = (string) => (\n (string?.startsWith?.('<') || string?.startsWith?.('\\n<')) ?? false\n)\n\nexport const freeze = (logMessage, object, type = 'log') => {\n console[type](logMessage, !object ? object : JSON.parse(JSON.stringify(ensureObject(object))))\n}\n\nexport const replaceSpaces = (string, replacement = '') => (\n !isType(string, 'string')\n ? ''\n : string.replace(/\\s/g, replacement)\n)\n\nconst recase = (string, replacement = '') => (\n !isType(string, 'string')\n ? ''\n : string\n .replace(/[^a-zA-Z0-9]+/g, replacement)\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1-$2')\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .replace(/([0-9])([^0-9])/g, '$1-$2')\n .replace(/([^0-9])([0-9])/g, '$1-$2')\n .replace(/[-_]+/g, replacement)\n .replace(new RegExp(`${replacement}$`), '')\n .toLowerCase()\n)\n\nexport const zencase = (string, replacement = '-') => (\n !isType(string, 'string')\n ? ''\n : replaceSpaces(string, replacement)\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1-$2')\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .replace(new RegExp(`${replacement}$`), '')\n .toLowerCase()\n)\n\nexport const dashcase = (string) => (\n recase(string, '-')\n)\n\nexport const undashcase = (string, replacement = ' ') => (\n ensureString(string).replace(/-/g, replacement).trim()\n)\n\nexport const snakecase = (string) => (\n recase(string, '_')\n)\n\nexport const unsnakecase = (string, replacement = ' ') => (\n ensureString(string).replace(/_/g, replacement).trim()\n)\n\nexport const uppercase = (string) => (\n ensureString(string).toUpperCase()\n)\n\nexport const lowercase = (string, defaultValue = '') => (\n !stringNotEmpty(string)\n ? defaultValue\n : ensureString(string).toLowerCase()\n)\n\nexport const slugify = (string) => (\n lowercase(dashcase(string))\n)\n\nexport const capitalize = (string) => {\n const parts = splitString(string, 1)\n return `${uppercase(parts[0])}${parts[1]}`\n}\n\nexport const camelCase = (string) => (\n stringNotEmpty(string)\n ? unsnakecase(undashcase(string)).replace(/\\w\\S*/g, (word, charIndex) => {\n if (charIndex === 0) {\n return lowercase(word)\n }\n return `${uppercase(word.charAt(0))}${lowercase(word.substr(1))}`\n }).split(' ').join('')\n : ''\n)\n\nexport const titleCase = (string, _overrides) => {\n if (!stringNotEmpty(string)) {\n return ''\n }\n\n const overrides = {\n 'add-ons': 'Add-Ons',\n agnostack: 'agnoStack',\n ai: 'AI',\n b2b: 'B2B',\n b2c: 'B2C',\n cartcollab: 'CartCollab',\n 'cartcollab(sm)': 'CartCollab(SM)',\n chatgpt: 'ChatGPT',\n covid: 'COVID',\n covid19: 'COVID-19',\n 'covid-19': 'COVID-19',\n crm: 'CRM',\n elasticpath: 'Elastic Path',\n ecommerce: 'eCommerce',\n 'e-commerce': 'eCommerce',\n faqs: 'FAQs',\n gpt: 'GPT',\n 'smile.io': 'Smile.io',\n 'stamped.io': 'Stamped.io',\n 'judge.me': 'Judge.me',\n 'influence.io': 'Influence.io',\n keepsmallstrong: 'KeepSmallStrong',\n loyaltylion: 'LoyaltyLion',\n openai: 'OpenAI',\n paypal: 'PayPal',\n 'postscript.io': 'Postscript.io',\n recharge: 'ReCharge',\n 'stay.ai': 'Stay.ai',\n 'stay ai': 'Stay Ai',\n shipengine: 'ShipEngine',\n shipperhq: 'ShipperHQ',\n shipstation: 'ShipStation',\n taxjar: 'TaxJar',\n yotpo: 'YotPo',\n ..._overrides,\n }\n\n const stringParts = lowercase(string)\n .split(' ')\n .reduce((\n _stringParts,\n _stringPart\n ) => {\n const stringPart = overrides[_stringPart] ?? _stringPart\n .replace(/([A-Z]+)/g, ' $1')\n .replace(/\\s\\s+/g, ' ')\n .replace(/(\\b[a-z](?!\\s)*)/g, (firstChar) => uppercase(firstChar))\n\n return [\n ..._stringParts,\n ...stringNotEmpty(stringPart) ? [stringPart] : []\n ]\n }, [])\n\n return stringParts.join(' ')\n}\n\nexport const removeLeadingSlash = (string) => (\n ensureString(string).replace(/^\\//, '')\n)\n\nexport const removeLeadingTrailingQuotes = (string) => (\n ensureString(string).replace(/^\"|\"$/g, '')\n)\n\n// TODO: not sure if this should remove multipel at end or just one (as it does now)?\nexport const removeTrailingSlash = (string) => (\n ensureString(string).replace(/\\/$/, '')\n)\n\nexport const removeLeadingTrailingSlash = (string) => (\n removeTrailingSlash(removeLeadingSlash(string))\n)\n\nexport const ensureLeadingSlash = (string) => (\n `/${removeLeadingSlash(string)}`\n)\n\nexport const ensureTrailingSlash = (string) => (\n `${removeTrailingSlash(string)}/`\n)\n\nexport const ensureExtension = (string, extension) => {\n if (stringEmpty(extension)) {\n return string\n }\n\n const filePath = string.match(/(.*)\\..+$/)?.[1] ?? string\n\n return `${filePath}.${extension}`\n}\n\nexport const wrappedEncode = (basePath, _wrappingPath) => {\n const wrappingPath = ensureString(_wrappingPath)\n if (stringEmpty(basePath)) {\n return wrappingPath\n }\n\n return `${basePath}${encodeURIComponent(wrappingPath)}`\n}\n\nexport const splitCommas = (value) => (\n ensureString(value)\n .replace(/, /g, ',')\n .split(',')\n .reduce((_values, _value) => {\n const __value = safeTrim(_value)\n return [\n ..._values,\n ...stringNotEmpty(__value) ? [__value] : [] // TODO: explore stringEmptyOnly?\n ]\n }, [])\n)\n\nexport const combineCommas = (values) => (\n [...new Set(\n ensureArray(values).reduce((\n _combined,\n value\n ) => ([\n ..._combined,\n ...splitCommas(value)\n ]), [])\n )]\n)\n\nexport const normalizeArray = (input, separator = ' ') => {\n const inputArray = ensureArray(input)\n\n return inputArray.reduce((normalized, _ignore, index) => ([\n ...normalized,\n inputArray.slice(0, index + 1).join(separator)\n ]), []).reverse()\n}\n\nexport const arrayToObject = (arrayable, key) => (\n ensureArray(arrayable).reduce((_object, item) => ({\n ..._object,\n [item?.[key]]: item,\n }), {})\n)\n\nexport const isTrue = (value, falsy) => {\n const string = ensureString(value)\n return ![...ensureArray(falsy), '', 'false'].includes(string)\n}\n\n// TODO: move all uses of parseKeywords to parseKeywordGroups\nexport const parseKeywords = (keywordGroup, previous) => (\n [...new Set(ensureArray(keywordGroup).reduce((_parsedKeywords, keyword) => {\n const keywords = splitCommas(keyword)\n\n return [\n ..._parsedKeywords,\n ...keywords.filter((_keyword) => stringNotEmpty(_keyword))\n ]\n }, ensureArray(previous)))].join(', ')\n)\n\nexport const parseKeywordGroups = (keywordGroups) => {\n const parsedKeywords = ensureArray(keywordGroups).reduce((_parsedKeywords, keywordGroup) => ([\n ..._parsedKeywords,\n ...ensureArray(keywordGroup).reduce((_parsedGroupKeywords, keyword) => {\n const keywords = splitCommas(keyword)\n\n return [\n ..._parsedGroupKeywords,\n ...keywords.filter((_keyword) => stringNotEmpty(_keyword))\n ]\n }, [])\n ]), [])\n\n return [...new Set(parsedKeywords)].join(', ')\n}\n\nexport const parseProjectName = (_name) => {\n const name = ensureString(_name)\n const [, organization, ...parts] = /(@.*)([\\\\]+|\\/)+(.*)/.exec(name) ?? []\n const projectName = organization ? name.replace(organization, '').replace('/', '') : name\n\n return {\n name,\n parts,\n organization,\n projectName,\n }\n}\n\nexport const parseProject = (packageInfo) => {\n const { shortName, owner: _appOwner, name: _name, appName: _appName, keywords, siteName: _siteName } = packageInfo ?? {}\n const { name, organization, projectName } = parseProjectName(_name)\n\n const appName = _appName ?? projectName?.slice(projectName?.indexOf('-') + 1)\n const siteName = _siteName ?? projectName?.slice(projectName?.indexOf('-') + 1)\n const companyName = titleCase(organization?.replace('@', ''))\n const appOwner = _appOwner ?? companyName\n\n return [{\n keywords,\n appOwner,\n appName,\n siteName,\n shortName,\n companyName,\n projectName,\n }, organization, name]\n}\n\n// #endregion lib-core\n\n// #region lib-utils-js\n\nexport const querystringToObject = (queryString) => {\n if (stringEmpty(queryString)) {\n return {}\n }\n\n const urlParams = new URLSearchParams(queryString)\n return Object.fromEntries(urlParams)\n}\n\nexport const arrayIncludesAll = (_values, comparison) => {\n const values = ensureArray(_values)\n return ensureArray(comparison).every((value) => (\n stringNotEmpty(value) && values.includes(value)\n ))\n}\n\nexport const arraysMatch = (array1, array2) => (\n arrayIncludesAll(array1, array2) && arrayIncludesAll(array2, array1)\n)\n\nexport const appendQuery = (_basePath, queryString) => {\n const basePath = ensureString(_basePath)\n if (stringEmpty(queryString)) {\n return basePath\n }\n return `${basePath}${basePath.includes('?') ? '&' : '?'}${queryString}`\n}\n\n// #endregion lib-utils-js\n\nexport const getGUID = () => (\n uuidV4()\n)\n\nexport const getInteger = () => (\n getGUID().replace(/\\D/g,'')\n)\n","import { exists, window } from 'browser-monads-ts'\n\nimport { ensureArray, ensureString, objectEmpty } from './display'\n\nconst getWebCrypto = async () => {\n try {\n const crypto = (await import('isomorphic-webcrypto')).default\n return crypto\n } catch (error) {\n console.error('Failed to import isomorphic-webcrypto', error)\n throw error\n }\n}\n\nconst getTextDecoder = async () => {\n if (exists(window) && (typeof window?.TextDecoder === 'function')) {\n return window.TextDecoder\n }\n\n try {\n const TextDecoder = (await import('util')).TextDecoder\n return TextDecoder\n } catch (error) {\n console.error('Failed to import utils.TextDecoder', error)\n throw error\n }\n}\n\nconst getTextEncoder = async () => {\n if (exists(window) && (typeof window?.TextEncoder === 'function')) {\n return window.TextEncoder\n }\n\n try {\n const TextEncoder = (await import('util')).TextEncoder\n return TextEncoder\n } catch (error) {\n console.error('Failed to import utils.TextEncoder', error)\n throw error\n }\n}\n\nconst timingSafeEqual = (value1, value2) => {\n if (\n (value1 == undefined) ||\n (value2 == undefined) ||\n (value1.length !== value2.length)\n ) {\n return false\n }\n\n let result = 0\n // eslint-disable-next-line no-plusplus\n for (let i = 0; i < value1.length; i++) {\n // eslint-disable-next-line no-bitwise\n result |= value1[i] ^ value2[i]\n }\n\n return (result === 0)\n}\n\nconst stringToHex = (stringValue) => (\n Array.from(ensureString(stringValue), (char) => (\n char.charCodeAt(0).toString(16).padStart(2, '0')\n )).join('')\n)\n\nconst hexToString = (hexValue) => (\n ensureArray(\n ensureString(hexValue).match(/.{1,2}/g)\n )\n .map((byte) => String.fromCharCode(parseInt(byte, 16)))\n .join('')\n)\n\nconst arrayBufferToString = async (arrayBuffer) => {\n const uint8Array = new Uint8Array(arrayBuffer)\n const Decoder = await getTextDecoder()\n return new Decoder().decode(uint8Array)\n}\n\nconst arrayToArrayBuffer = (array) => (\n (ArrayBuffer.from != undefined)\n ? ArrayBuffer.from(array)\n : new Uint8Array(array).buffer\n)\n\nconst ensureArrayBuffer = (arrayOrArrayBuffer) => (\n (arrayOrArrayBuffer instanceof ArrayBuffer)\n ? arrayOrArrayBuffer\n : arrayToArrayBuffer(arrayOrArrayBuffer)\n)\n\nconst generateKeyPair = async () => {\n const crypto = await getWebCrypto()\n const keyPair = await crypto.subtle.generateKey(\n {\n name: 'ECDH',\n namedCurve: 'P-256',\n },\n true,\n ['deriveKey']\n )\n\n return keyPair\n}\n\nconst getKeyOperations = (keyType) => {\n switch (keyType) {\n case 'private':\n case 'privateKey': {\n return ['deriveKey']\n }\n\n case 'secret':\n case 'secretKey':\n case 'sharedSecret': {\n return ['encrypt', 'decrypt'] \n }\n\n default: {\n return []\n }\n }\n}\n\nconst getKeyAlgorythm = (keyType) => {\n switch (keyType) {\n case 'derivedKey':\n case 'derived':\n case 'secret':\n case 'secretKey':\n case 'sharedSecret': {\n return {\n name: 'AES-GCM',\n }\n }\n\n default: {\n return {\n name: 'ECDH',\n namedCurve: 'P-256',\n }\n }\n }\n}\n\nconst generateHMAC = async (message, derivedKey) => {\n if (!message || !derivedKey) {\n return undefined\n } \n\n const crypto = await getWebCrypto()\n const Encoder = await getTextEncoder()\n\n const signature = await crypto.subtle.sign(\n 'HMAC',\n derivedKey,\n new Encoder().encode(message)\n )\n\n return stringToHex(\n arrayBufferToString(signature)\n )\n}\n\nconst verifyHMAC = async (message, derivedKey, verifiableHMAC) => {\n const calculatedHMAC = await generateHMAC(message, derivedKey)\n\n return timingSafeEqual(calculatedHMAC, verifiableHMAC)\n}\n\nconst getStorableKey = async (key) => {\n const crypto = await getWebCrypto()\n\n const exportedJWK = await crypto.subtle.exportKey('jwk', key)\n return stringToHex(JSON.stringify(exportedJWK))\n}\n\nconst restoreStorableKey = async (keyType, storableHex) => {\n if (!storableHex) {\n return undefined\n }\n const crypto = await getWebCrypto()\n\n const exportedJWK = JSON.parse(hexToString(storableHex) || '{}')\n if (objectEmpty(exportedJWK)) {\n return undefined\n }\n\n return crypto.subtle.importKey(\n 'jwk',\n exportedJWK,\n getKeyAlgorythm(keyType),\n true,\n getKeyOperations(keyType)\n )\n}\n\nconst getStorableKeyPair = async (keyPair) => {\n const storableKeys = {}\n\n // eslint-disable-next-line no-restricted-syntax\n for (const [keyType, key] of Object.entries(keyPair)) {\n // eslint-disable-next-line no-await-in-loop\n storableKeys[keyType] = await getStorableKey(key)\n }\n\n return storableKeys\n}\n\nconst restoreStorableKeyPair = async (keyPair) => {\n const restoredKeys = {}\n\n // eslint-disable-next-line no-restricted-syntax\n for (const [keyType, key] of Object.entries(keyPair)) {\n // eslint-disable-next-line no-await-in-loop\n restoredKeys[keyType] = await restoreStorableKey(keyType, key)\n }\n\n return restoredKeys\n}\n\nconst deriveSharedKey = async ({ publicKey, privateKey }) => {\n if (!publicKey || !privateKey) {\n return undefined\n }\n\n const crypto = await getWebCrypto()\n const derivedKey = await crypto.subtle.deriveKey(\n {\n name: 'ECDH',\n public: publicKey,\n },\n privateKey,\n {\n name: 'AES-GCM',\n length: 256,\n },\n true,\n ['encrypt', 'decrypt']\n )\n return derivedKey\n}\n\nconst deriveHMACKey = async ({ publicKey, privateKey }) => {\n if (!publicKey || !privateKey) {\n return undefined\n }\n\n const crypto = await getWebCrypto()\n const derivedKey = await crypto.subtle.deriveKey(\n {\n name: 'ECDH',\n public: publicKey,\n },\n privateKey,\n {\n name: 'HMAC',\n hash: { name: 'SHA-256' },\n length: 256, // Adjusted key length, e.g., 128 bits\n },\n true,\n ['sign', 'verify']\n )\n return derivedKey\n}\n\nconst getVerificationKeys = async ({ publicKey, privateKey }) => {\n if (!publicKey || !privateKey) {\n return {}\n }\n\n const sharedKeyPair = await restoreStorableKeyPair({ publicKey, privateKey })\n const derivedHMACKey = await deriveHMACKey(sharedKeyPair)\n const derivedSecretKey = await deriveSharedKey(sharedKeyPair)\n\n return {\n derivedSecretKey,\n derivedHMACKey,\n }\n}\n\nconst encryptMessage = async (decryptedMessage, derivedKey) => {\n if (!decryptedMessage || !derivedKey) {\n return undefined\n }\n\n const crypto = await getWebCrypto()\n const iv = crypto.getRandomValues(new Uint8Array(12))\n const Encoder = await getTextEncoder()\n const encodedMessage = new Encoder().encode(decryptedMessage)\n const ciphertext = await crypto.subtle.encrypt(\n {\n name: 'AES-GCM',\n iv,\n },\n derivedKey,\n encodedMessage\n )\n\n const encryptedMessage = new Uint8Array([\n ...iv,\n ...new Uint8Array(ciphertext)\n ])\n return Array.from(encryptedMessage)\n}\n\nconst decryptMessage = async (encryptedMessage, derivedKey) => {\n if (!encryptedMessage || !derivedKey) {\n return undefined\n }\n\n const crypto = await getWebCrypto()\n // NOTE: this presumed an array or arrayBuffer coming in as encryptedMessage (will fail w/ IV error if its a string)\n const encryptedArrayBuffer = ensureArrayBuffer(encryptedMessage)\n const iv = encryptedArrayBuffer.slice(0, 12)\n const ciphertext = encryptedArrayBuffer.slice(12)\n\n const decryptedArrayBuffer = await crypto.subtle.decrypt(\n {\n name: 'AES-GCM',\n iv,\n },\n derivedKey,\n ciphertext\n )\n\n const Decoder = await getTextDecoder()\n const decryptedMessage = new Decoder().decode(decryptedArrayBuffer)\n return decryptedMessage\n}\n\nexport const subtle = {\n generateKeyPair,\n generateHMAC,\n verifyHMAC,\n getStorableKey,\n getStorableKeyPair,\n restoreStorableKeyPair,\n deriveSharedKey,\n deriveHMACKey,\n getVerificationKeys,\n encryptMessage,\n decryptMessage,\n}\n","import {\n ensureLeadingSlash,\n stringEmpty,\n uppercase,\n safeParse,\n} from './display'\n\n\nconst TEMP_HOSTNAME = 'xyz.com'\nconst REMOVABLE_KEYS = ['shop', 'host']\n\nexport const HEADER_CONTENT_TYPE = 'Content-Type'\nexport const CONTENT_TYPES = {\n APPLICATION_JSON: 'application/json',\n}\n\nexport const getRequestMethod = (body, _method) => {\n const method = _method ?? (body ? 'POST' : 'GET')\n\n return uppercase(method)\n}\n\nexport const prepareRequestOptions = ({ method: _method, body: _body, headers: _header, ...requestOptions } = {}) => {\n const method = getRequestMethod(_body, _method)\n\n const headers = {\n [HEADER_CONTENT_TYPE]: CONTENT_TYPES.APPLICATION_JSON,\n ..._header,\n }\n\n let body = _body\n if (body && headers[HEADER_CONTENT_TYPE].startsWith(CONTENT_TYPES.APPLICATION_JSON)) {\n body = JSON.stringify(safeParse(body))\n }\n\n return {\n method,\n headers,\n ...(body && (method !== 'GET')) && { body },\n ...requestOptions,\n }\n}\n\nconst convertToURL = (uri) => {\n if (stringEmpty(uri)) {\n return undefined\n }\n\n const protocolRegex = /^(https?:\\/\\/).+/i\n\n if (!protocolRegex.test(uri)) {\n return new URL(`https://${TEMP_HOSTNAME}${ensureLeadingSlash(uri)}`)\n }\n\n return new URL(uri)\n}\n\nexport const normalizeURIParts = (uri) => {\n const urlObject = convertToURL(uri)\n if (!urlObject) {\n return undefined\n }\n\n REMOVABLE_KEYS.forEach((key) => urlObject.searchParams.delete(key))\n\n return {\n ...(urlObject.hostname !== TEMP_HOSTNAME) && {\n origin: urlObject.origin,\n },\n pathname: urlObject.pathname,\n search: urlObject.search,\n }\n}\n","/*!\n * raw-body\n * Copyright(c) 2013-2014 Jonathan Ong\n * Copyright(c) 2014-2022 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module dependencies.\n * @private\n */\n\nvar asyncHooks = tryRequireAsyncHooks()\nvar bytes = require('bytes')\nvar createError = require('http-errors')\nvar iconv = require('iconv-lite')\nvar unpipe = require('unpipe')\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = getRawBody\n\n/**\n * Module variables.\n * @private\n */\n\nvar ICONV_ENCODING_MESSAGE_REGEXP = /^Encoding not recognized: /\n\n/**\n * Get the decoder for a given encoding.\n *\n * @param {string} encoding\n * @private\n */\n\nfunction getDecoder (encoding) {\n if (!encoding) return null\n\n try {\n return iconv.getDecoder(encoding)\n } catch (e) {\n // error getting decoder\n if (!ICONV_ENCODING_MESSAGE_REGEXP.test(e.message)) throw e\n\n // the encoding was not found\n throw createError(415, 'specified encoding unsupported', {\n encoding: encoding,\n type: 'encoding.unsupported'\n })\n }\n}\n\n/**\n * Get the raw body of a stream (typically HTTP).\n *\n * @param {object} stream\n * @param {object|string|function} [options]\n * @param {function} [callback]\n * @public\n */\n\nfunction getRawBody (stream, options, callback) {\n var done = callback\n var opts = options || {}\n\n // light validation\n if (stream === undefined) {\n throw new TypeError('argument stream is required')\n } else if (typeof stream !== 'object' || stream === null || typeof stream.on !== 'function') {\n throw new TypeError('argument stream must be a stream')\n }\n\n if (options === true || typeof options === 'string') {\n // short cut for encoding\n opts = {\n encoding: options\n }\n }\n\n if (typeof options === 'function') {\n done = options\n opts = {}\n }\n\n // validate callback is a function, if provided\n if (done !== undefined && typeof done !== 'function') {\n throw new TypeError('argument callback must be a function')\n }\n\n // require the callback without promises\n if (!done && !global.Promise) {\n throw new TypeError('argument callback is required')\n }\n\n // get encoding\n var encoding = opts.encoding !== true\n ? opts.encoding\n : 'utf-8'\n\n // convert the limit to an integer\n var limit = bytes.parse(opts.limit)\n\n // convert the expected length to an integer\n var length = opts.length != null && !isNaN(opts.length)\n ? parseInt(opts.length, 10)\n : null\n\n if (done) {\n // classic callback style\n return readStream(stream, encoding, length, limit, wrap(done))\n }\n\n return new Promise(function executor (resolve, reject) {\n readStream(stream, encoding, length, limit, function onRead (err, buf) {\n if (err) return reject(err)\n resolve(buf)\n })\n })\n}\n\n/**\n * Halt a stream.\n *\n * @param {Object} stream\n * @private\n */\n\nfunction halt (stream) {\n // unpipe everything from the stream\n unpipe(stream)\n\n // pause stream\n if (typeof stream.pause === 'function') {\n stream.pause()\n }\n}\n\n/**\n * Read the data from the stream.\n *\n * @param {object} stream\n * @param {string} encoding\n * @param {number} length\n * @param {number} limit\n * @param {function} callback\n * @public\n */\n\nfunction readStream (stream, encoding, length, limit, callback) {\n var complete = false\n var sync = true\n\n // check the length and limit options.\n // note: we intentionally leave the stream paused,\n // so users should handle the stream themselves.\n if (limit !== null && length !== null && length > limit) {\n return done(createError(413, 'request entity too large', {\n expected: length,\n length: length,\n limit: limit,\n type: 'entity.too.large'\n }))\n }\n\n // streams1: assert request encoding is buffer.\n // streams2+: assert the stream encoding is buffer.\n // stream._decoder: streams1\n // state.encoding: streams2\n // state.decoder: streams2, specifically < 0.10.6\n var state = stream._readableState\n if (stream._decoder || (state && (state.encoding || state.decoder))) {\n // developer error\n return done(createError(500, 'stream encoding should not be set', {\n type: 'stream.encoding.set'\n }))\n }\n\n if (typeof stream.readable !== 'undefined' && !stream.readable) {\n return done(createError(500, 'stream is not readable', {\n type: 'stream.not.readable'\n }))\n }\n\n var received = 0\n var decoder\n\n try {\n decoder = getDecoder(encoding)\n } catch (err) {\n return done(err)\n }\n\n var buffer = decoder\n ? ''\n : []\n\n // attach listeners\n stream.on('aborted', onAborted)\n stream.on('close', cleanup)\n stream.on('data', onData)\n stream.on('end', onEnd)\n stream.on('error', onEnd)\n\n // mark sync section complete\n sync = false\n\n function done () {\n var args = new Array(arguments.length)\n\n // copy arguments\n for (var i = 0; i < args.length; i++) {\n args[i] = arguments[i]\n }\n\n // mark complete\n complete = true\n\n if (sync) {\n process.nextTick(invokeCallback)\n } else {\n invokeCallback()\n }\n\n function invokeCallback () {\n cleanup()\n\n if (args[0]) {\n // halt the stream on error\n halt(stream)\n }\n\n callback.apply(null, args)\n }\n }\n\n function onAborted () {\n if (complete) return\n\n done(createError(400, 'request aborted', {\n code: 'ECONNABORTED',\n expected: length,\n length: length,\n received: received,\n type: 'request.aborted'\n }))\n }\n\n function onData (chunk) {\n if (complete) return\n\n received += chunk.length\n\n if (limit !== null && received > limit) {\n done(createError(413, 'request entity too large', {\n limit: limit,\n received: received,\n type: 'entity.too.large'\n }))\n } else if (decoder) {\n buffer += decoder.write(chunk)\n } else {\n buffer.push(chunk)\n }\n }\n\n function onEnd (err) {\n if (complete) return\n if (err) return done(err)\n\n if (length !== null && received !== length) {\n done(createError(400, 'request size did not match content length', {\n expected: length,\n length: length,\n received: received,\n type: 'request.size.invalid'\n }))\n } else {\n var string = decoder\n ? buffer + (decoder.end() || '')\n : Buffer.concat(buffer)\n done(null, string)\n }\n }\n\n function cleanup () {\n buffer = null\n\n stream.removeListener('aborted', onAborted)\n stream.removeListener('data', onData)\n stream.removeListener('end', onEnd)\n stream.removeListener('error', onEnd)\n stream.removeListener('close', cleanup)\n }\n}\n\n/**\n * Try to require async_hooks\n * @private\n */\n\nfunction tryRequireAsyncHooks () {\n try {\n return require('async_hooks')\n } catch (e) {\n return {}\n }\n}\n\n/**\n * Wrap function with async resource, if possible.\n * AsyncResource.bind static method backported.\n * @private\n */\n\nfunction wrap (fn) {\n var res\n\n // create anonymous resource\n if (asyncHooks.AsyncResource) {\n res = new asyncHooks.AsyncResource(fn.name || 'bound-anonymous-fn')\n }\n\n // incompatible node.js\n if (!res || !res.runInAsyncScope) {\n return fn\n }\n\n // return bound function\n return res.runInAsyncScope.bind(res, fn, null)\n}\n","// import getRawBody from 'raw-body'\nimport * as getRawBody from 'raw-body'\n\n// TODO: explore returning mutated request object adding on req.rawBody??\n// TODO: move to req.text() after next 13.5\nexport const ensureRawBody = async (req) => (\n getRawBody(req)\n .then((_rawBody) => _rawBody.toString())\n .catch((error) => {\n // NOTE: this is intended to ensure if getRawBody is called 2x w/in a route that it returns the already streamed body\n if ((error?.type === 'stream.not.readable')) {\n if (!req?.rawBody) {\n // eslint-disable-next-line max-len\n console.info('Ignoring error reading raw requst body. This can occur if the body is attempted to be read twice in a single request. If intentional, please mutate the request to add the result of this call as req.rawBody (to prevent this warning).')\n return req?.body\n }\n\n return req?.rawBody\n }\n\n console.error(`Error getting raw body for '${req?.url}'`, error)\n throw error\n })\n)\n","export class VerificationError extends Error {\n constructor(message, _data) {\n super(message)\n const { code = 500, ...data } = _data ?? {}\n this.code = code\n this.data = data\n this.name = 'VerificationError'\n Object.setPrototypeOf(this, VerificationError.prototype)\n }\n}\n","import { subtle } from '../shared/subtlecrypto'\nimport { getRequestMethod, normalizeURIParts } from '../shared/request'\nimport {\n objectToSortedString,\n ensureString,\n safeParse,\n isTrue,\n} from '../shared/display'\nimport { ensureRawBody } from './rawbody'\nimport { VerificationError } from './errors'\n\nexport const getVerificationHelpers = ({ keyPairs }) => (\n async (req, params) => {\n const {\n 'x-public-key': apiKey,\n 'x-ephemeral-key': ephemeralPublicKey,\n 'x-authorization-timestamp': customAuthTimestamp,\n 'x-authorization': customAuth,\n } = req.headers ?? {}\n\n const { uri: _uri, disableRecryption: _disableRecryption } = params ?? {}\n const uri = _uri ?? req.url\n const disableRecryption = isTrue(_disableRecryption)\n\n let isVerifiable\n try {\n const [authProtocol, authSignature] = ensureString(customAuth).split(' ')\n isVerifiable = isTrue(\n apiKey &&\n ephemeralPublicKey &&\n keyPairs?.shared &&\n customAuthTimestamp &&\n authSignature &&\n (authProtocol === 'HMAC-SHA256')\n )\n\n let verificationKeys\n const rawBody = await ensureRawBody(req)\n\n // NOTE: requestBody should be wind up decrypted when isVerifiable (unless disableRecryption, then will pass through)\n let requestBody = safeParse(rawBody)\n\n // TEMP!!! remove isVerifiable check once webwidget moved to react\n if (isVerifiable) {\n if (\n !apiKey ||\n !ephemeralPublicKey ||\n !customAuthTimestamp ||\n !authSignature ||\n !keyPairs?.shared ||\n (apiKey !== keyPairs.shared.publicKey) ||\n (authProtocol !== 'HMAC-SHA256')\n ) {\n throw new VerificationError('Invalid or missing authorization', { code: 401 })\n }\n\n verificationKeys = await subtle.getVerificationKeys({\n publicKey: ephemeralPublicKey,\n privateKey: keyPairs.shared.privateKey,\n })\n\n if (!verificationKeys) {\n throw new VerificationError('Invalid or missing verification', { code: 412 })\n }\n\n const verificationPayload = objectToSortedString({\n method: getRequestMethod(rawBody, req.method),\n timestamp: customAuthTimestamp,\n body: requestBody, // NOTE: requestBody should be encrypted when isVerifiable\n ...normalizeURIParts(uri),\n })\n\n const isValid = await subtle.verifyHMAC(\n verificationPayload,\n verificationKeys.derivedHMACKey,\n authSignature\n )\n\n if (!isValid) {\n throw new VerificationError('Invalid or missing verification', { code: 412 })\n }\n\n if (!disableRecryption && requestBody) {\n const decryptedMessage = await subtle.decryptMessage(requestBody, verificationKeys.derivedSecretKey)\n requestBody = safeParse(decryptedMessage)\n }\n }\n\n const processResponse = async (response) => {\n if (!response || disableRecryption || !isVerifiable || !verificationKeys?.derivedSecretKey) {\n return response\n }\n\n return subtle.encryptMessage(JSON.stringify(response), verificationKeys.derivedSecretKey)\n }\n\n return { rawBody, requestBody, processResponse }\n } catch (error) {\n console.error(`Error handling request verification for '${uri}'`, { error, isVerifiable, disableRecryption })\n throw error\n }\n }\n)\n"],"names":["getRawBody"],"mappings":";;;;;;EAAA,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;AACxP;EACA,IAAI,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC;EAIxB,IAAI,MAAM,GAAG,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;EAExC,IAAI,MAAM,GAAG,OAAO,GAAG,KAAK,WAAW,GAAG,GAAG,GAAG,CAAC;;ECRjD;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iC,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;EACvF,SAAS;AACT;EACA,QAAQ,IAAI,CAAC,iBAAiB,IAAI,WAAW,EAAE;EAC/C,UAAU,MAAM,gBAAgB,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,WAAW,EAAE,gBAAgB,CAAC,gBAAgB,EAAC;EAC9G,UAAU,WAAW,GAAG,SAAS,CAAC,gBAAgB,EAAC;EACnD,SAAS;EACT,OAAO;AACP;EACA,MAAM,MAAM,eAAe,GAAG,OAAO,QAAQ,KAAK;EAClD,QAAQ,IAAI,CAAC,QAAQ,IAAI,iBAAiB,IAAI,CAAC,YAAY,IAAI,CAAC,gBAAgB,EAAE,gBAAgB,EAAE;EACpG,UAAU,OAAO,QAAQ;EACzB,SAAS;AACT;EACA,QAAQ,OAAO,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,gBAAgB,CAAC,gBAAgB,CAAC;EACjG,QAAO;AACP;EACA,MAAM,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE;EACtD,KAAK,CAAC,OAAO,KAAK,EAAE;EACpB,MAAM,OAAO,CAAC,KAAK,CAAC,CAAC,yCAAyC,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,EAAC;EACnH,MAAM,MAAM,KAAK;EACjB,KAAK;EACL,GAAG;EACH;;;;;;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/verification/errors.js"],"names":[],"mappings":"AAAA;IACE,sCAOC;IAJC,UAAgB;IAChB,UAAgB;CAInB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"rawbody.d.ts","sourceRoot":"","sources":["../../src/verification/rawbody.js"],"names":[],"mappings":"AAKO,sDAkBN"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/verification/errors.js"],"names":[],"mappings":"AAAA;IACE,sCAOC;IAJC,UAAgB;IAChB,UAAgB;CAInB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/verification/errors.js"],"names":[],"mappings":";;;;;;;;;;;AAAA,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C,YAAY,OAAO,EAAE,KAAK;QACxB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,MAAM,KAA0B,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,EAArC,EAAE,IAAI,GAAG,GAAG,OAAyB,EAApB,IAAI,cAArB,QAAuB,CAAc,CAAA;QAC3C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAA;QAC/B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAA;IAC1D,CAAC;CACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"rawbody.d.ts","sourceRoot":"","sources":["../../src/verification/rawbody.js"],"names":[],"mappings":"AAKO,sDAkBN"}
@@ -1,31 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- // import getRawBody from 'raw-body'
11
- import * as getRawBody from 'raw-body';
12
- // TODO: explore returning mutated request object adding on req.rawBody??
13
- // TODO: move to req.text() after next 13.5
14
- export const ensureRawBody = (req) => __awaiter(void 0, void 0, void 0, function* () {
15
- return (getRawBody(req)
16
- .then((_rawBody) => _rawBody.toString())
17
- .catch((error) => {
18
- // NOTE: this is intended to ensure if getRawBody is called 2x w/in a route that it returns the already streamed body
19
- if (((error === null || error === void 0 ? void 0 : error.type) === 'stream.not.readable')) {
20
- if (!(req === null || req === void 0 ? void 0 : req.rawBody)) {
21
- // eslint-disable-next-line max-len
22
- console.info('Ignoring error reading raw requst body. This can occur if the body is attempted to be read twice in a single request. If intentional, please mutate the request to add the result of this call as req.rawBody (to prevent this warning).');
23
- return req === null || req === void 0 ? void 0 : req.body;
24
- }
25
- return req === null || req === void 0 ? void 0 : req.rawBody;
26
- }
27
- console.error(`Error getting raw body for '${req === null || req === void 0 ? void 0 : req.url}'`, error);
28
- throw error;
29
- }));
30
- });
31
- //# sourceMappingURL=rawbody.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rawbody.js","sourceRoot":"","sources":["../../src/verification/rawbody.js"],"names":[],"mappings":";;;;;;;;;AAAA,oCAAoC;AACpC,OAAO,KAAK,UAAU,MAAM,UAAU,CAAA;AAEtC,yEAAyE;AACzE,2CAA2C;AAC3C,MAAM,CAAC,MAAM,aAAa,GAAG,CAAO,GAAG,EAAE,EAAE;IAAC,OAAA,CAC1C,UAAU,CAAC,GAAG,CAAC;SACZ,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;SACvC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACf,qHAAqH;QACrH,IAAI,CAAC,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAK,qBAAqB,CAAC,EAAE;YAC3C,IAAI,CAAC,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,OAAO,CAAA,EAAE;gBACjB,mCAAmC;gBACnC,OAAO,CAAC,IAAI,CAAC,0OAA0O,CAAC,CAAA;gBACxP,OAAO,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,CAAA;aACjB;YAED,OAAO,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,OAAO,CAAA;SACpB;QAED,OAAO,CAAC,KAAK,CAAC,+BAA+B,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,GAAG,GAAG,EAAE,KAAK,CAAC,CAAA;QAChE,MAAM,KAAK,CAAA;IACf,CAAC,CAAC,CACH,CAAA;EAAA,CAAA"}
@@ -1,97 +0,0 @@
1
- 3.1.2 / 2022-01-27
2
- ==================
3
-
4
- * Fix return value for un-parsable strings
5
-
6
- 3.1.1 / 2021-11-15
7
- ==================
8
-
9
- * Fix "thousandsSeparator" incorrecting formatting fractional part
10
-
11
- 3.1.0 / 2019-01-22
12
- ==================
13
-
14
- * Add petabyte (`pb`) support
15
-
16
- 3.0.0 / 2017-08-31
17
- ==================
18
-
19
- * Change "kB" to "KB" in format output
20
- * Remove support for Node.js 0.6
21
- * Remove support for ComponentJS
22
-
23
- 2.5.0 / 2017-03-24
24
- ==================
25
-
26
- * Add option "unit"
27
-
28
- 2.4.0 / 2016-06-01
29
- ==================
30
-
31
- * Add option "unitSeparator"
32
-
33
- 2.3.0 / 2016-02-15
34
- ==================
35
-
36
- * Drop partial bytes on all parsed units
37
- * Fix non-finite numbers to `.format` to return `null`
38
- * Fix parsing byte string that looks like hex
39
- * perf: hoist regular expressions
40
-
41
- 2.2.0 / 2015-11-13
42
- ==================
43
-
44
- * add option "decimalPlaces"
45
- * add option "fixedDecimals"
46
-
47
- 2.1.0 / 2015-05-21
48
- ==================
49
-
50
- * add `.format` export
51
- * add `.parse` export
52
-
53
- 2.0.2 / 2015-05-20
54
- ==================
55
-
56
- * remove map recreation
57
- * remove unnecessary object construction
58
-
59
- 2.0.1 / 2015-05-07
60
- ==================
61
-
62
- * fix browserify require
63
- * remove node.extend dependency
64
-
65
- 2.0.0 / 2015-04-12
66
- ==================
67
-
68
- * add option "case"
69
- * add option "thousandsSeparator"
70
- * return "null" on invalid parse input
71
- * support proper round-trip: bytes(bytes(num)) === num
72
- * units no longer case sensitive when parsing
73
-
74
- 1.0.0 / 2014-05-05
75
- ==================
76
-
77
- * add negative support. fixes #6
78
-
79
- 0.3.0 / 2014-03-19
80
- ==================
81
-
82
- * added terabyte support
83
-
84
- 0.2.1 / 2013-04-01
85
- ==================
86
-
87
- * add .component
88
-
89
- 0.2.0 / 2012-10-28
90
- ==================
91
-
92
- * bytes(200).should.eql('200b')
93
-
94
- 0.1.0 / 2012-07-04
95
- ==================
96
-
97
- * add bytes to string conversion [yields]
@@ -1,23 +0,0 @@
1
- (The MIT License)
2
-
3
- Copyright (c) 2012-2014 TJ Holowaychuk <tj@vision-media.ca>
4
- Copyright (c) 2015 Jed Watson <jed.watson@me.com>
5
-
6
- Permission is hereby granted, free of charge, to any person obtaining
7
- a copy of this software and associated documentation files (the
8
- 'Software'), to deal in the Software without restriction, including
9
- without limitation the rights to use, copy, modify, merge, publish,
10
- distribute, sublicense, and/or sell copies of the Software, and to
11
- permit persons to whom the Software is furnished to do so, subject to
12
- the following conditions:
13
-
14
- The above copyright notice and this permission notice shall be
15
- included in all copies or substantial portions of the Software.
16
-
17
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,152 +0,0 @@
1
- # Bytes utility
2
-
3
- [![NPM Version][npm-image]][npm-url]
4
- [![NPM Downloads][downloads-image]][downloads-url]
5
- [![Build Status][ci-image]][ci-url]
6
- [![Test Coverage][coveralls-image]][coveralls-url]
7
-
8
- Utility to parse a string bytes (ex: `1TB`) to bytes (`1099511627776`) and vice-versa.
9
-
10
- ## Installation
11
-
12
- This is a [Node.js](https://nodejs.org/en/) module available through the
13
- [npm registry](https://www.npmjs.com/). Installation is done using the
14
- [`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
15
-
16
- ```bash
17
- $ npm install bytes
18
- ```
19
-
20
- ## Usage
21
-
22
- ```js
23
- var bytes = require('bytes');
24
- ```
25
-
26
- #### bytes(number|string value, [options]): number|string|null
27
-
28
- Default export function. Delegates to either `bytes.format` or `bytes.parse` based on the type of `value`.
29
-
30
- **Arguments**
31
-
32
- | Name | Type | Description |
33
- |---------|----------|--------------------|
34
- | value | `number`|`string` | Number value to format or string value to parse |
35
- | options | `Object` | Conversion options for `format` |
36
-
37
- **Returns**
38
-
39
- | Name | Type | Description |
40
- |---------|------------------|-------------------------------------------------|
41
- | results | `string`|`number`|`null` | Return null upon error. Numeric value in bytes, or string value otherwise. |
42
-
43
- **Example**
44
-
45
- ```js
46
- bytes(1024);
47
- // output: '1KB'
48
-
49
- bytes('1KB');
50
- // output: 1024
51
- ```
52
-
53
- #### bytes.format(number value, [options]): string|null
54
-
55
- Format the given value in bytes into a string. If the value is negative, it is kept as such. If it is a float, it is
56
- rounded.
57
-
58
- **Arguments**
59
-
60
- | Name | Type | Description |
61
- |---------|----------|--------------------|
62
- | value | `number` | Value in bytes |
63
- | options | `Object` | Conversion options |
64
-
65
- **Options**
66
-
67
- | Property | Type | Description |
68
- |-------------------|--------|-----------------------------------------------------------------------------------------|
69
- | decimalPlaces | `number`|`null` | Maximum number of decimal places to include in output. Default value to `2`. |
70
- | fixedDecimals | `boolean`|`null` | Whether to always display the maximum number of decimal places. Default value to `false` |
71
- | thousandsSeparator | `string`|`null` | Example of values: `' '`, `','` and `'.'`... Default value to `''`. |
72
- | unit | `string`|`null` | The unit in which the result will be returned (B/KB/MB/GB/TB). Default value to `''` (which means auto detect). |
73
- | unitSeparator | `string`|`null` | Separator to use between number and unit. Default value to `''`. |
74
-
75
- **Returns**
76
-
77
- | Name | Type | Description |
78
- |---------|------------------|-------------------------------------------------|
79
- | results | `string`|`null` | Return null upon error. String value otherwise. |
80
-
81
- **Example**
82
-
83
- ```js
84
- bytes.format(1024);
85
- // output: '1KB'
86
-
87
- bytes.format(1000);
88
- // output: '1000B'
89
-
90
- bytes.format(1000, {thousandsSeparator: ' '});
91
- // output: '1 000B'
92
-
93
- bytes.format(1024 * 1.7, {decimalPlaces: 0});
94
- // output: '2KB'
95
-
96
- bytes.format(1024, {unitSeparator: ' '});
97
- // output: '1 KB'
98
- ```
99
-
100
- #### bytes.parse(string|number value): number|null
101
-
102
- Parse the string value into an integer in bytes. If no unit is given, or `value`
103
- is a number, it is assumed the value is in bytes.
104
-
105
- Supported units and abbreviations are as follows and are case-insensitive:
106
-
107
- * `b` for bytes
108
- * `kb` for kilobytes
109
- * `mb` for megabytes
110
- * `gb` for gigabytes
111
- * `tb` for terabytes
112
- * `pb` for petabytes
113
-
114
- The units are in powers of two, not ten. This means 1kb = 1024b according to this parser.
115
-
116
- **Arguments**
117
-
118
- | Name | Type | Description |
119
- |---------------|--------|--------------------|
120
- | value | `string`|`number` | String to parse, or number in bytes. |
121
-
122
- **Returns**
123
-
124
- | Name | Type | Description |
125
- |---------|-------------|-------------------------|
126
- | results | `number`|`null` | Return null upon error. Value in bytes otherwise. |
127
-
128
- **Example**
129
-
130
- ```js
131
- bytes.parse('1KB');
132
- // output: 1024
133
-
134
- bytes.parse('1024');
135
- // output: 1024
136
-
137
- bytes.parse(1024);
138
- // output: 1024
139
- ```
140
-
141
- ## License
142
-
143
- [MIT](LICENSE)
144
-
145
- [ci-image]: https://badgen.net/github/checks/visionmedia/bytes.js/master?label=ci
146
- [ci-url]: https://github.com/visionmedia/bytes.js/actions?query=workflow%3Aci
147
- [coveralls-image]: https://badgen.net/coveralls/c/github/visionmedia/bytes.js/master
148
- [coveralls-url]: https://coveralls.io/r/visionmedia/bytes.js?branch=master
149
- [downloads-image]: https://badgen.net/npm/dm/bytes
150
- [downloads-url]: https://npmjs.org/package/bytes
151
- [npm-image]: https://badgen.net/npm/v/bytes
152
- [npm-url]: https://npmjs.org/package/bytes
@@ -1,170 +0,0 @@
1
- /*!
2
- * bytes
3
- * Copyright(c) 2012-2014 TJ Holowaychuk
4
- * Copyright(c) 2015 Jed Watson
5
- * MIT Licensed
6
- */
7
-
8
- 'use strict';
9
-
10
- /**
11
- * Module exports.
12
- * @public
13
- */
14
-
15
- module.exports = bytes;
16
- module.exports.format = format;
17
- module.exports.parse = parse;
18
-
19
- /**
20
- * Module variables.
21
- * @private
22
- */
23
-
24
- var formatThousandsRegExp = /\B(?=(\d{3})+(?!\d))/g;
25
-
26
- var formatDecimalsRegExp = /(?:\.0*|(\.[^0]+)0+)$/;
27
-
28
- var map = {
29
- b: 1,
30
- kb: 1 << 10,
31
- mb: 1 << 20,
32
- gb: 1 << 30,
33
- tb: Math.pow(1024, 4),
34
- pb: Math.pow(1024, 5),
35
- };
36
-
37
- var parseRegExp = /^((-|\+)?(\d+(?:\.\d+)?)) *(kb|mb|gb|tb|pb)$/i;
38
-
39
- /**
40
- * Convert the given value in bytes into a string or parse to string to an integer in bytes.
41
- *
42
- * @param {string|number} value
43
- * @param {{
44
- * case: [string],
45
- * decimalPlaces: [number]
46
- * fixedDecimals: [boolean]
47
- * thousandsSeparator: [string]
48
- * unitSeparator: [string]
49
- * }} [options] bytes options.
50
- *
51
- * @returns {string|number|null}
52
- */
53
-
54
- function bytes(value, options) {
55
- if (typeof value === 'string') {
56
- return parse(value);
57
- }
58
-
59
- if (typeof value === 'number') {
60
- return format(value, options);
61
- }
62
-
63
- return null;
64
- }
65
-
66
- /**
67
- * Format the given value in bytes into a string.
68
- *
69
- * If the value is negative, it is kept as such. If it is a float,
70
- * it is rounded.
71
- *
72
- * @param {number} value
73
- * @param {object} [options]
74
- * @param {number} [options.decimalPlaces=2]
75
- * @param {number} [options.fixedDecimals=false]
76
- * @param {string} [options.thousandsSeparator=]
77
- * @param {string} [options.unit=]
78
- * @param {string} [options.unitSeparator=]
79
- *
80
- * @returns {string|null}
81
- * @public
82
- */
83
-
84
- function format(value, options) {
85
- if (!Number.isFinite(value)) {
86
- return null;
87
- }
88
-
89
- var mag = Math.abs(value);
90
- var thousandsSeparator = (options && options.thousandsSeparator) || '';
91
- var unitSeparator = (options && options.unitSeparator) || '';
92
- var decimalPlaces = (options && options.decimalPlaces !== undefined) ? options.decimalPlaces : 2;
93
- var fixedDecimals = Boolean(options && options.fixedDecimals);
94
- var unit = (options && options.unit) || '';
95
-
96
- if (!unit || !map[unit.toLowerCase()]) {
97
- if (mag >= map.pb) {
98
- unit = 'PB';
99
- } else if (mag >= map.tb) {
100
- unit = 'TB';
101
- } else if (mag >= map.gb) {
102
- unit = 'GB';
103
- } else if (mag >= map.mb) {
104
- unit = 'MB';
105
- } else if (mag >= map.kb) {
106
- unit = 'KB';
107
- } else {
108
- unit = 'B';
109
- }
110
- }
111
-
112
- var val = value / map[unit.toLowerCase()];
113
- var str = val.toFixed(decimalPlaces);
114
-
115
- if (!fixedDecimals) {
116
- str = str.replace(formatDecimalsRegExp, '$1');
117
- }
118
-
119
- if (thousandsSeparator) {
120
- str = str.split('.').map(function (s, i) {
121
- return i === 0
122
- ? s.replace(formatThousandsRegExp, thousandsSeparator)
123
- : s
124
- }).join('.');
125
- }
126
-
127
- return str + unitSeparator + unit;
128
- }
129
-
130
- /**
131
- * Parse the string value into an integer in bytes.
132
- *
133
- * If no unit is given, it is assumed the value is in bytes.
134
- *
135
- * @param {number|string} val
136
- *
137
- * @returns {number|null}
138
- * @public
139
- */
140
-
141
- function parse(val) {
142
- if (typeof val === 'number' && !isNaN(val)) {
143
- return val;
144
- }
145
-
146
- if (typeof val !== 'string') {
147
- return null;
148
- }
149
-
150
- // Test if the string passed is valid
151
- var results = parseRegExp.exec(val);
152
- var floatValue;
153
- var unit = 'b';
154
-
155
- if (!results) {
156
- // Nothing could be extracted from the given string
157
- floatValue = parseInt(val, 10);
158
- unit = 'b'
159
- } else {
160
- // Retrieve the value and the unit
161
- floatValue = parseFloat(results[1]);
162
- unit = results[4].toLowerCase();
163
- }
164
-
165
- if (isNaN(floatValue)) {
166
- return null;
167
- }
168
-
169
- return Math.floor(map[unit] * floatValue);
170
- }