@ripwords/myinvois-client 0.4.0 → 0.4.1

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 (515) hide show
  1. package/dist/0X-Cr3M7hci.d.cts +211 -0
  2. package/dist/0X-bPhcc9Vv.d.ts +211 -0
  3. package/dist/1X-Bqi8dmY1.d.ts +20 -0
  4. package/dist/1X-CWwmfCzo.d.cts +112 -0
  5. package/dist/1X-DKHYQyRy.d.ts +112 -0
  6. package/dist/1X-DYw2tURz.d.cts +20 -0
  7. package/dist/2X-CXtqiwRg.d.cts +40 -0
  8. package/dist/2X-CemxuAeL.d.ts +40 -0
  9. package/dist/2X-DN6M21cV.d.ts +140 -0
  10. package/dist/2X-DNtkJ0tj.d.cts +140 -0
  11. package/dist/3X-BOxfatu3.d.cts +62 -0
  12. package/dist/3X-Bk_fUIAk.d.cts +21 -0
  13. package/dist/3X-DIYh_ue4.d.ts +21 -0
  14. package/dist/3X-DJRj5xLv.d.ts +62 -0
  15. package/dist/4X-BCvTomUF.d.ts +265 -0
  16. package/dist/4X-C7fzDWJ_.d.cts +265 -0
  17. package/dist/4X-CK9rj5qd.d.cts +31 -0
  18. package/dist/4X-CZi5nwIr.d.ts +31 -0
  19. package/dist/5X-CNAFsDm2.d.cts +77 -0
  20. package/dist/5X-CpAvNxvd.d.cts +22 -0
  21. package/dist/5X-Dji6Soz5.d.ts +77 -0
  22. package/dist/5X-DyYBCAvY.d.ts +22 -0
  23. package/dist/6X-CO_u4RIY.d.ts +105 -0
  24. package/dist/6X-Csxu6lwi.d.ts +16 -0
  25. package/dist/6X-bXWr_7xY.d.cts +16 -0
  26. package/dist/6X-uObUP4VG.d.cts +105 -0
  27. package/dist/7X-BJBOlWhV.d.cts +16 -0
  28. package/dist/7X-BifJnY24.d.cts +71 -0
  29. package/dist/7X-DivvfBsk.d.ts +16 -0
  30. package/dist/7X-vzJ01lNF.d.ts +71 -0
  31. package/dist/8X-C4Wf4jYK.d.ts +110 -0
  32. package/dist/8X-D_Pw1H3K.d.ts +19 -0
  33. package/dist/8X-DioBXCJ0.d.cts +110 -0
  34. package/dist/8X-dshwiOxU.d.cts +19 -0
  35. package/dist/9X-1VwxN9g-.d.ts +98 -0
  36. package/dist/9X-9j2Djy4W.d.cts +15 -0
  37. package/dist/9X-BjffnXuq.d.cts +98 -0
  38. package/dist/9X-BwR9pibT.d.ts +15 -0
  39. package/dist/AX-CDubGAZO.d.ts +111 -0
  40. package/dist/AX-CWCopjCC.d.cts +111 -0
  41. package/dist/BX-CBsKI8np.d.ts +115 -0
  42. package/dist/BX-Cq7WdhD3.d.cts +115 -0
  43. package/dist/CX-DhOdAFyg.d.ts +128 -0
  44. package/dist/CX-DlcVZfxx.d.cts +128 -0
  45. package/dist/DX-CBiRJGqR.d.ts +115 -0
  46. package/dist/DX-DLdv-Nxj.d.cts +115 -0
  47. package/dist/EX-CAn62WaX.d.ts +107 -0
  48. package/dist/EX-CIJv8-Lw.d.cts +107 -0
  49. package/dist/FX-CANpsLC4.d.ts +127 -0
  50. package/dist/FX-DlDM_Zea.d.cts +127 -0
  51. package/dist/GX-BFGNX6Jy.d.cts +136 -0
  52. package/dist/GX-BvSZZ8pE.d.ts +136 -0
  53. package/dist/HX-CxrnY-YC.d.ts +126 -0
  54. package/dist/HX-D7Y9qRSm.d.cts +126 -0
  55. package/dist/IX-DPTrbhgX.d.cts +23 -0
  56. package/dist/IX-wdAD6eW8.d.ts +23 -0
  57. package/dist/JX-B5v815to.d.ts +104 -0
  58. package/dist/JX-D8JmtNpo.d.cts +104 -0
  59. package/dist/KX-B46KJZrH.d.cts +151 -0
  60. package/dist/KX-BI8n7ACj.d.ts +151 -0
  61. package/dist/LX-BVvEz6Ji.d.ts +123 -0
  62. package/dist/LX-CfTKy8Sx.d.cts +123 -0
  63. package/dist/MX-BKJ4gNvV.d.cts +153 -0
  64. package/dist/MX-D_OsOP_v.d.ts +153 -0
  65. package/dist/NX-CSdLIFqU.d.cts +122 -0
  66. package/dist/NX-DIhAzAY3.d.ts +122 -0
  67. package/dist/OX-BZrRnj5g.d.ts +26 -0
  68. package/dist/OX-BwqOsulT.d.cts +26 -0
  69. package/dist/PX-BTx0TXsJ.d.cts +121 -0
  70. package/dist/PX-DGGrJNym.d.ts +121 -0
  71. package/dist/QX-BUXR8RJL.d.cts +59 -0
  72. package/dist/QX-DuTJFnHX.d.ts +59 -0
  73. package/dist/RX-CZ8HiH37.d.cts +23 -0
  74. package/dist/RX-DYQoV7am.d.ts +23 -0
  75. package/dist/SX-CLxsqiQk.d.cts +40 -0
  76. package/dist/SX-Dl1RlNnc.d.ts +40 -0
  77. package/dist/TX-DKc8hLc4.d.cts +31 -0
  78. package/dist/TX-SoIfFaZj.d.ts +31 -0
  79. package/dist/UX-DqBfrSsY.d.ts +18 -0
  80. package/dist/UX-bc7xDnZI.d.cts +18 -0
  81. package/dist/VX-Ahcpp3Si.d.ts +17 -0
  82. package/dist/VX-CIHTFyoC.d.cts +17 -0
  83. package/dist/WX-BHvlq7Jx.d.cts +26 -0
  84. package/dist/WX-Di6vYD7A.d.ts +26 -0
  85. package/dist/XX-BE4flzh6.d.ts +828 -0
  86. package/dist/XX-DztQxYHJ.d.cts +828 -0
  87. package/dist/YX-BPO04gSZ.d.ts +20 -0
  88. package/dist/YX-CkxLeFb4.d.cts +20 -0
  89. package/dist/ZX-DHu4FRKS.d.ts +22 -0
  90. package/dist/ZX-DVb_buNI.d.cts +22 -0
  91. package/dist/{index2.cjs → api/documentManagement.cjs} +1 -1
  92. package/dist/api/documentManagement.d.cts +90 -0
  93. package/dist/api/documentManagement.d.ts +90 -0
  94. package/dist/api/documentManagement.js +3 -0
  95. package/dist/{index3.cjs → api/documentSubmission.cjs} +3 -3
  96. package/dist/api/documentSubmission.d.cts +93 -0
  97. package/dist/api/documentSubmission.d.ts +93 -0
  98. package/dist/api/documentSubmission.js +5 -0
  99. package/dist/{index4.cjs → api/documentTypeManagement.cjs} +1 -1
  100. package/dist/api/documentTypeManagement.d.cts +71 -0
  101. package/dist/api/documentTypeManagement.d.ts +71 -0
  102. package/dist/api/documentTypeManagement.js +3 -0
  103. package/dist/api/notificationManagement.cjs +3 -0
  104. package/dist/api/notificationManagement.d.cts +69 -0
  105. package/dist/api/notificationManagement.d.ts +69 -0
  106. package/dist/api/notificationManagement.js +3 -0
  107. package/dist/api/platformLogin.cjs +3 -0
  108. package/dist/api/platformLogin.d.cts +69 -0
  109. package/dist/api/platformLogin.d.ts +69 -0
  110. package/dist/api/platformLogin.js +3 -0
  111. package/dist/api/taxpayerValidation.cjs +6 -0
  112. package/dist/api/taxpayerValidation.d.cts +72 -0
  113. package/dist/api/taxpayerValidation.d.ts +72 -0
  114. package/dist/api/taxpayerValidation.js +4 -0
  115. package/dist/apiQueue-B6Q644Bz.js +202 -0
  116. package/dist/apiQueue-B6Q644Bz.js.map +1 -0
  117. package/dist/certificate-Cg6spxUs.js +52 -0
  118. package/dist/certificate-Cg6spxUs.js.map +1 -0
  119. package/dist/classification-codes-B15PbWxz.d.cts +118 -0
  120. package/dist/classification-codes-BQMnAQFr.d.ts +118 -0
  121. package/dist/country-code-DAejE5RV.d.ts +543 -0
  122. package/dist/country-code-DPeNFMMi.d.cts +543 -0
  123. package/dist/currencies-Cg9RkxRB.d.ts +208 -0
  124. package/dist/currencies-S5g1gzBU.d.cts +208 -0
  125. package/dist/document-BC52NCdW.js +653 -0
  126. package/dist/document-BC52NCdW.js.map +1 -0
  127. package/dist/document-BQdoGqOl.d.cts +157 -0
  128. package/dist/document-CnamySca.d.ts +157 -0
  129. package/dist/documentManagement-DZKm582-.js +51 -0
  130. package/dist/documentManagement-DZKm582-.js.map +1 -0
  131. package/dist/documentSubmission-DSsX0ldK.js +136 -0
  132. package/dist/documentSubmission-DSsX0ldK.js.map +1 -0
  133. package/dist/documentTypeManagement-cBtVCOY3.js +23 -0
  134. package/dist/documentTypeManagement-cBtVCOY3.js.map +1 -0
  135. package/dist/documents-BpZn3hJq.d.ts +1197 -0
  136. package/dist/documents-D_V38Q_U.d.cts +1197 -0
  137. package/dist/e-invoice-BSCFsH-H.d.ts +44 -0
  138. package/dist/e-invoice-BuwtFnlI.d.cts +44 -0
  139. package/dist/formatIdValue-qTxJqj9o.js +8 -0
  140. package/dist/formatIdValue-qTxJqj9o.js.map +1 -0
  141. package/dist/getBaseUrl-D7nUmoYb.js +8 -0
  142. package/dist/getBaseUrl-D7nUmoYb.js.map +1 -0
  143. package/dist/index-Dn3JIREW.d.ts +16 -0
  144. package/dist/index-Yr1QAbIF.d.cts +16 -0
  145. package/dist/index.d.cts +616 -0
  146. package/dist/index.d.ts +616 -0
  147. package/dist/index.js +629 -0
  148. package/dist/index.js.map +1 -0
  149. package/dist/lineItems-Btjkf6VX.js +58 -0
  150. package/dist/lineItems-Btjkf6VX.js.map +1 -0
  151. package/dist/lineItems-CBSo7giH.d.cts +32 -0
  152. package/dist/lineItems-CrkEXi2m.d.ts +32 -0
  153. package/dist/msic-codes-CIKdPqag.d.cts +26 -0
  154. package/dist/msic-codes-kysVPGdN.d.ts +26 -0
  155. package/dist/notificationManagement-n4Z5e-My.js +20 -0
  156. package/dist/notificationManagement-n4Z5e-My.js.map +1 -0
  157. package/dist/notifications-B4BymhRJ.d.ts +63 -0
  158. package/dist/notifications-DdlEkprb.d.cts +63 -0
  159. package/dist/payment-modes-7c1lWlIr.d.cts +44 -0
  160. package/dist/payment-modes-BGP5McTY.d.ts +44 -0
  161. package/dist/platformLogin-CqI9OLYP.js +40 -0
  162. package/dist/platformLogin-CqI9OLYP.js.map +1 -0
  163. package/dist/signatures-Bk5aKcq6.d.ts +173 -0
  164. package/dist/signatures-CyDSZr_e.d.cts +173 -0
  165. package/dist/state-codes-CAkYQnTd.d.ts +62 -0
  166. package/dist/state-codes-u3ppueWo.d.cts +62 -0
  167. package/dist/tax-types-QeZFKqew.d.ts +42 -0
  168. package/dist/tax-types-fu5Q6dic.d.cts +42 -0
  169. package/dist/taxpayer-B1CSMqNS.d.ts +36 -0
  170. package/dist/taxpayer-DwGzY1IL.d.cts +36 -0
  171. package/dist/taxpayerValidation-Xd_EHDvk.js +48 -0
  172. package/dist/taxpayerValidation-Xd_EHDvk.js.map +1 -0
  173. package/dist/{index17.cjs → types/classification-codes.d.cjs} +1 -1
  174. package/dist/types/classification-codes.d.cjs.map +1 -0
  175. package/dist/types/classification-codes.d.cts +2 -0
  176. package/dist/types/classification-codes.d.ts +2 -0
  177. package/dist/{index18.cjs → types/country-code.d.cjs} +1 -1
  178. package/dist/types/country-code.d.cjs.map +1 -0
  179. package/dist/types/country-code.d.cts +2 -0
  180. package/dist/types/country-code.d.ts +2 -0
  181. package/dist/{index19.cjs → types/currencies.d.cjs} +1 -1
  182. package/dist/types/currencies.d.cjs.map +1 -0
  183. package/dist/types/currencies.d.cts +2 -0
  184. package/dist/types/currencies.d.ts +2 -0
  185. package/dist/types/documents.d.cts +55 -0
  186. package/dist/types/documents.d.ts +55 -0
  187. package/dist/{index21.cjs → types/e-invoice.d.cjs} +1 -1
  188. package/dist/types/e-invoice.d.cjs.map +1 -0
  189. package/dist/types/e-invoice.d.cts +2 -0
  190. package/dist/types/e-invoice.d.ts +2 -0
  191. package/dist/types/index.d.cts +61 -0
  192. package/dist/types/index.d.ts +61 -0
  193. package/dist/{index32.cjs → types/msic/0X.d.cjs} +1 -1
  194. package/dist/types/msic/0X.d.cjs.map +1 -0
  195. package/dist/types/msic/0X.d.cts +2 -0
  196. package/dist/types/msic/0X.d.ts +2 -0
  197. package/dist/{index33.cjs → types/msic/1X.d.cjs} +1 -1
  198. package/dist/types/msic/1X.d.cjs.map +1 -0
  199. package/dist/types/msic/1X.d.cts +2 -0
  200. package/dist/types/msic/1X.d.ts +2 -0
  201. package/dist/{index34.cjs → types/msic/2X.d.cjs} +1 -1
  202. package/dist/types/msic/2X.d.cjs.map +1 -0
  203. package/dist/types/msic/2X.d.cts +2 -0
  204. package/dist/types/msic/2X.d.ts +2 -0
  205. package/dist/{index35.cjs → types/msic/3X.d.cjs} +1 -1
  206. package/dist/types/msic/3X.d.cjs.map +1 -0
  207. package/dist/types/msic/3X.d.cts +2 -0
  208. package/dist/types/msic/3X.d.ts +2 -0
  209. package/dist/{index36.cjs → types/msic/4X.d.cjs} +1 -1
  210. package/dist/types/msic/4X.d.cjs.map +1 -0
  211. package/dist/types/msic/4X.d.cts +2 -0
  212. package/dist/types/msic/4X.d.ts +2 -0
  213. package/dist/{index37.cjs → types/msic/5X.d.cjs} +1 -1
  214. package/dist/types/msic/5X.d.cjs.map +1 -0
  215. package/dist/types/msic/5X.d.cts +2 -0
  216. package/dist/types/msic/5X.d.ts +2 -0
  217. package/dist/{index38.cjs → types/msic/6X.d.cjs} +1 -1
  218. package/dist/types/msic/6X.d.cjs.map +1 -0
  219. package/dist/types/msic/6X.d.cts +2 -0
  220. package/dist/types/msic/6X.d.ts +2 -0
  221. package/dist/{index39.cjs → types/msic/7X.d.cjs} +1 -1
  222. package/dist/types/msic/7X.d.cjs.map +1 -0
  223. package/dist/types/msic/7X.d.cts +2 -0
  224. package/dist/types/msic/7X.d.ts +2 -0
  225. package/dist/{index40.cjs → types/msic/8X.d.cjs} +1 -1
  226. package/dist/types/msic/8X.d.cjs.map +1 -0
  227. package/dist/types/msic/8X.d.cts +2 -0
  228. package/dist/types/msic/8X.d.ts +2 -0
  229. package/dist/{index41.cjs → types/msic/9X.d.cjs} +1 -1
  230. package/dist/types/msic/9X.d.cjs.map +1 -0
  231. package/dist/types/msic/9X.d.cts +2 -0
  232. package/dist/types/msic/9X.d.ts +2 -0
  233. package/dist/types/msic-codes.d.cts +12 -0
  234. package/dist/types/msic-codes.d.ts +12 -0
  235. package/dist/{index24.cjs → types/notifications.d.cjs} +1 -1
  236. package/dist/types/notifications.d.cjs.map +1 -0
  237. package/dist/types/notifications.d.cts +2 -0
  238. package/dist/types/notifications.d.ts +2 -0
  239. package/dist/{index25.cjs → types/payment-modes.d.cjs} +1 -1
  240. package/dist/types/payment-modes.d.cjs.map +1 -0
  241. package/dist/types/payment-modes.d.cts +2 -0
  242. package/dist/types/payment-modes.d.ts +2 -0
  243. package/dist/types/signatures.d.cts +2 -0
  244. package/dist/types/signatures.d.ts +2 -0
  245. package/dist/{index27.cjs → types/state-codes.d.cjs} +1 -1
  246. package/dist/types/state-codes.d.cjs.map +1 -0
  247. package/dist/types/state-codes.d.cts +2 -0
  248. package/dist/types/state-codes.d.ts +2 -0
  249. package/dist/{index28.cjs → types/tax-types.d.cjs} +1 -1
  250. package/dist/types/tax-types.d.cjs.map +1 -0
  251. package/dist/types/tax-types.d.cts +2 -0
  252. package/dist/types/tax-types.d.ts +2 -0
  253. package/dist/types/taxpayer.d.cts +56 -0
  254. package/dist/types/taxpayer.d.ts +56 -0
  255. package/dist/{index42.cjs → types/unit/1X.d.cjs} +1 -1
  256. package/dist/types/unit/1X.d.cjs.map +1 -0
  257. package/dist/types/unit/1X.d.cts +2 -0
  258. package/dist/types/unit/1X.d.ts +2 -0
  259. package/dist/{index43.cjs → types/unit/2X.d.cjs} +1 -1
  260. package/dist/types/unit/2X.d.cjs.map +1 -0
  261. package/dist/types/unit/2X.d.cts +2 -0
  262. package/dist/types/unit/2X.d.ts +2 -0
  263. package/dist/{index44.cjs → types/unit/3X.d.cjs} +1 -1
  264. package/dist/types/unit/3X.d.cjs.map +1 -0
  265. package/dist/types/unit/3X.d.cts +2 -0
  266. package/dist/types/unit/3X.d.ts +2 -0
  267. package/dist/{index45.cjs → types/unit/4X.d.cjs} +1 -1
  268. package/dist/types/unit/4X.d.cjs.map +1 -0
  269. package/dist/types/unit/4X.d.cts +2 -0
  270. package/dist/types/unit/4X.d.ts +2 -0
  271. package/dist/{index46.cjs → types/unit/5X.d.cjs} +1 -1
  272. package/dist/types/unit/5X.d.cjs.map +1 -0
  273. package/dist/types/unit/5X.d.cts +2 -0
  274. package/dist/types/unit/5X.d.ts +2 -0
  275. package/dist/{index47.cjs → types/unit/6X.d.cjs} +1 -1
  276. package/dist/types/unit/6X.d.cjs.map +1 -0
  277. package/dist/types/unit/6X.d.cts +2 -0
  278. package/dist/types/unit/6X.d.ts +2 -0
  279. package/dist/{index48.cjs → types/unit/7X.d.cjs} +1 -1
  280. package/dist/types/unit/7X.d.cjs.map +1 -0
  281. package/dist/types/unit/7X.d.cts +2 -0
  282. package/dist/types/unit/7X.d.ts +2 -0
  283. package/dist/{index49.cjs → types/unit/8X.d.cjs} +1 -1
  284. package/dist/types/unit/8X.d.cjs.map +1 -0
  285. package/dist/types/unit/8X.d.cts +2 -0
  286. package/dist/types/unit/8X.d.ts +2 -0
  287. package/dist/{index50.cjs → types/unit/9X.d.cjs} +1 -1
  288. package/dist/types/unit/9X.d.cjs.map +1 -0
  289. package/dist/types/unit/9X.d.cts +2 -0
  290. package/dist/types/unit/9X.d.ts +2 -0
  291. package/dist/{index51.cjs → types/unit/AX.d.cjs} +1 -1
  292. package/dist/types/unit/AX.d.cjs.map +1 -0
  293. package/dist/types/unit/AX.d.cts +2 -0
  294. package/dist/types/unit/AX.d.ts +2 -0
  295. package/dist/{index52.cjs → types/unit/BX.d.cjs} +1 -1
  296. package/dist/types/unit/BX.d.cjs.map +1 -0
  297. package/dist/types/unit/BX.d.cts +2 -0
  298. package/dist/types/unit/BX.d.ts +2 -0
  299. package/dist/{index53.cjs → types/unit/CX.d.cjs} +1 -1
  300. package/dist/types/unit/CX.d.cjs.map +1 -0
  301. package/dist/types/unit/CX.d.cts +2 -0
  302. package/dist/types/unit/CX.d.ts +2 -0
  303. package/dist/{index54.cjs → types/unit/DX.d.cjs} +1 -1
  304. package/dist/types/unit/DX.d.cjs.map +1 -0
  305. package/dist/types/unit/DX.d.cts +2 -0
  306. package/dist/types/unit/DX.d.ts +2 -0
  307. package/dist/{index55.cjs → types/unit/EX.d.cjs} +1 -1
  308. package/dist/types/unit/EX.d.cjs.map +1 -0
  309. package/dist/types/unit/EX.d.cts +2 -0
  310. package/dist/types/unit/EX.d.ts +2 -0
  311. package/dist/{index56.cjs → types/unit/FX.d.cjs} +1 -1
  312. package/dist/types/unit/FX.d.cjs.map +1 -0
  313. package/dist/types/unit/FX.d.cts +2 -0
  314. package/dist/types/unit/FX.d.ts +2 -0
  315. package/dist/{index57.cjs → types/unit/GX.d.cjs} +1 -1
  316. package/dist/types/unit/GX.d.cjs.map +1 -0
  317. package/dist/types/unit/GX.d.cts +2 -0
  318. package/dist/types/unit/GX.d.ts +2 -0
  319. package/dist/{index58.cjs → types/unit/HX.d.cjs} +1 -1
  320. package/dist/types/unit/HX.d.cjs.map +1 -0
  321. package/dist/types/unit/HX.d.cts +2 -0
  322. package/dist/types/unit/HX.d.ts +2 -0
  323. package/dist/{index59.cjs → types/unit/IX.d.cjs} +1 -1
  324. package/dist/types/unit/IX.d.cjs.map +1 -0
  325. package/dist/types/unit/IX.d.cts +2 -0
  326. package/dist/types/unit/IX.d.ts +2 -0
  327. package/dist/{index60.cjs → types/unit/JX.d.cjs} +1 -1
  328. package/dist/types/unit/JX.d.cjs.map +1 -0
  329. package/dist/types/unit/JX.d.cts +2 -0
  330. package/dist/types/unit/JX.d.ts +2 -0
  331. package/dist/{index61.cjs → types/unit/KX.d.cjs} +1 -1
  332. package/dist/types/unit/KX.d.cjs.map +1 -0
  333. package/dist/types/unit/KX.d.cts +2 -0
  334. package/dist/types/unit/KX.d.ts +2 -0
  335. package/dist/{index62.cjs → types/unit/LX.d.cjs} +1 -1
  336. package/dist/types/unit/LX.d.cjs.map +1 -0
  337. package/dist/types/unit/LX.d.cts +2 -0
  338. package/dist/types/unit/LX.d.ts +2 -0
  339. package/dist/{index63.cjs → types/unit/MX.d.cjs} +1 -1
  340. package/dist/types/unit/MX.d.cjs.map +1 -0
  341. package/dist/types/unit/MX.d.cts +2 -0
  342. package/dist/types/unit/MX.d.ts +2 -0
  343. package/dist/{index64.cjs → types/unit/NX.d.cjs} +1 -1
  344. package/dist/types/unit/NX.d.cjs.map +1 -0
  345. package/dist/types/unit/NX.d.cts +2 -0
  346. package/dist/types/unit/NX.d.ts +2 -0
  347. package/dist/{index65.cjs → types/unit/OX.d.cjs} +1 -1
  348. package/dist/types/unit/OX.d.cjs.map +1 -0
  349. package/dist/types/unit/OX.d.cts +2 -0
  350. package/dist/types/unit/OX.d.ts +2 -0
  351. package/dist/{index66.cjs → types/unit/PX.d.cjs} +1 -1
  352. package/dist/types/unit/PX.d.cjs.map +1 -0
  353. package/dist/types/unit/PX.d.cts +2 -0
  354. package/dist/types/unit/PX.d.ts +2 -0
  355. package/dist/{index67.cjs → types/unit/QX.d.cjs} +1 -1
  356. package/dist/types/unit/QX.d.cjs.map +1 -0
  357. package/dist/types/unit/QX.d.cts +2 -0
  358. package/dist/types/unit/QX.d.ts +2 -0
  359. package/dist/{index68.cjs → types/unit/RX.d.cjs} +1 -1
  360. package/dist/types/unit/RX.d.cjs.map +1 -0
  361. package/dist/types/unit/RX.d.cts +2 -0
  362. package/dist/types/unit/RX.d.ts +2 -0
  363. package/dist/{index69.cjs → types/unit/SX.d.cjs} +1 -1
  364. package/dist/types/unit/SX.d.cjs.map +1 -0
  365. package/dist/types/unit/SX.d.cts +2 -0
  366. package/dist/types/unit/SX.d.ts +2 -0
  367. package/dist/{index70.cjs → types/unit/TX.d.cjs} +1 -1
  368. package/dist/types/unit/TX.d.cjs.map +1 -0
  369. package/dist/types/unit/TX.d.cts +2 -0
  370. package/dist/types/unit/TX.d.ts +2 -0
  371. package/dist/{index71.cjs → types/unit/UX.d.cjs} +1 -1
  372. package/dist/types/unit/UX.d.cjs.map +1 -0
  373. package/dist/types/unit/UX.d.cts +2 -0
  374. package/dist/types/unit/UX.d.ts +2 -0
  375. package/dist/{index72.cjs → types/unit/VX.d.cjs} +1 -1
  376. package/dist/types/unit/VX.d.cjs.map +1 -0
  377. package/dist/types/unit/VX.d.cts +2 -0
  378. package/dist/types/unit/VX.d.ts +2 -0
  379. package/dist/{index73.cjs → types/unit/WX.d.cjs} +1 -1
  380. package/dist/types/unit/WX.d.cjs.map +1 -0
  381. package/dist/types/unit/WX.d.cts +2 -0
  382. package/dist/types/unit/WX.d.ts +2 -0
  383. package/dist/{index74.cjs → types/unit/XX.d.cjs} +1 -1
  384. package/dist/types/unit/XX.d.cjs.map +1 -0
  385. package/dist/types/unit/XX.d.cts +2 -0
  386. package/dist/types/unit/XX.d.ts +2 -0
  387. package/dist/{index75.cjs → types/unit/YX.d.cjs} +1 -1
  388. package/dist/types/unit/YX.d.cjs.map +1 -0
  389. package/dist/types/unit/YX.d.cts +2 -0
  390. package/dist/types/unit/YX.d.ts +2 -0
  391. package/dist/{index76.cjs → types/unit/ZX.d.cjs} +1 -1
  392. package/dist/types/unit/ZX.d.cjs.map +1 -0
  393. package/dist/types/unit/ZX.d.cts +2 -0
  394. package/dist/types/unit/ZX.d.ts +2 -0
  395. package/dist/types/unit-types.d.cts +37 -0
  396. package/dist/types/unit-types.d.ts +37 -0
  397. package/dist/types/utils.d.cts +2 -0
  398. package/dist/types/utils.d.ts +2 -0
  399. package/dist/unit-types-BXdufGWm.d.cts +56 -0
  400. package/dist/unit-types-CZdxXbVN.d.ts +56 -0
  401. package/dist/{index8.cjs → utils/apiQueue.cjs} +1 -1
  402. package/dist/utils/apiQueue.d.cts +46 -0
  403. package/dist/utils/apiQueue.d.ts +46 -0
  404. package/dist/utils/apiQueue.js +3 -0
  405. package/dist/{index9.cjs → utils/base64.cjs} +1 -1
  406. package/dist/utils/base64.cjs.map +1 -0
  407. package/dist/utils/base64.d.cts +6 -0
  408. package/dist/utils/base64.d.ts +6 -0
  409. package/dist/utils/base64.js +11 -0
  410. package/dist/utils/base64.js.map +1 -0
  411. package/dist/utils/certificate.cjs +7 -0
  412. package/dist/utils/certificate.d.cts +78 -0
  413. package/dist/utils/certificate.d.ts +78 -0
  414. package/dist/utils/certificate.js +5 -0
  415. package/dist/{index11.cjs → utils/document.cjs} +2 -2
  416. package/dist/utils/document.d.cts +62 -0
  417. package/dist/utils/document.d.ts +62 -0
  418. package/dist/utils/document.js +4 -0
  419. package/dist/utils/formatIdValue.cjs +3 -0
  420. package/dist/utils/formatIdValue.d.cts +5 -0
  421. package/dist/utils/formatIdValue.d.ts +5 -0
  422. package/dist/utils/formatIdValue.js +3 -0
  423. package/dist/utils/getBaseUrl.cjs +3 -0
  424. package/dist/utils/getBaseUrl.d.cts +5 -0
  425. package/dist/utils/getBaseUrl.d.ts +5 -0
  426. package/dist/utils/getBaseUrl.js +3 -0
  427. package/dist/utils/lineItems.cjs +3 -0
  428. package/dist/utils/lineItems.d.cts +62 -0
  429. package/dist/utils/lineItems.d.ts +62 -0
  430. package/dist/utils/lineItems.js +3 -0
  431. package/dist/{index15.cjs → utils/signature-diagnostics.cjs} +3 -3
  432. package/dist/utils/signature-diagnostics.cjs.map +1 -0
  433. package/dist/utils/signature-diagnostics.d.cts +97 -0
  434. package/dist/utils/signature-diagnostics.d.ts +97 -0
  435. package/dist/utils/signature-diagnostics.js +328 -0
  436. package/dist/utils/signature-diagnostics.js.map +1 -0
  437. package/dist/{index16.cjs → utils/validation.cjs} +1 -1
  438. package/dist/utils/validation.cjs.map +1 -0
  439. package/dist/utils/validation.d.cts +109 -0
  440. package/dist/utils/validation.d.ts +109 -0
  441. package/dist/utils/validation.js +187 -0
  442. package/dist/utils/validation.js.map +1 -0
  443. package/dist/utils-BYVq373g.d.ts +5 -0
  444. package/dist/utils-Cdqbbzca.d.cts +5 -0
  445. package/package.json +17 -7
  446. package/dist/index10.cjs +0 -7
  447. package/dist/index12.cjs +0 -3
  448. package/dist/index13.cjs +0 -3
  449. package/dist/index14.cjs +0 -3
  450. package/dist/index15.cjs.map +0 -1
  451. package/dist/index16.cjs.map +0 -1
  452. package/dist/index17.cjs.map +0 -1
  453. package/dist/index18.cjs.map +0 -1
  454. package/dist/index19.cjs.map +0 -1
  455. package/dist/index21.cjs.map +0 -1
  456. package/dist/index24.cjs.map +0 -1
  457. package/dist/index25.cjs.map +0 -1
  458. package/dist/index27.cjs.map +0 -1
  459. package/dist/index28.cjs.map +0 -1
  460. package/dist/index32.cjs.map +0 -1
  461. package/dist/index33.cjs.map +0 -1
  462. package/dist/index34.cjs.map +0 -1
  463. package/dist/index35.cjs.map +0 -1
  464. package/dist/index36.cjs.map +0 -1
  465. package/dist/index37.cjs.map +0 -1
  466. package/dist/index38.cjs.map +0 -1
  467. package/dist/index39.cjs.map +0 -1
  468. package/dist/index40.cjs.map +0 -1
  469. package/dist/index41.cjs.map +0 -1
  470. package/dist/index42.cjs.map +0 -1
  471. package/dist/index43.cjs.map +0 -1
  472. package/dist/index44.cjs.map +0 -1
  473. package/dist/index45.cjs.map +0 -1
  474. package/dist/index46.cjs.map +0 -1
  475. package/dist/index47.cjs.map +0 -1
  476. package/dist/index48.cjs.map +0 -1
  477. package/dist/index49.cjs.map +0 -1
  478. package/dist/index5.cjs +0 -3
  479. package/dist/index50.cjs.map +0 -1
  480. package/dist/index51.cjs.map +0 -1
  481. package/dist/index52.cjs.map +0 -1
  482. package/dist/index53.cjs.map +0 -1
  483. package/dist/index54.cjs.map +0 -1
  484. package/dist/index55.cjs.map +0 -1
  485. package/dist/index56.cjs.map +0 -1
  486. package/dist/index57.cjs.map +0 -1
  487. package/dist/index58.cjs.map +0 -1
  488. package/dist/index59.cjs.map +0 -1
  489. package/dist/index6.cjs +0 -3
  490. package/dist/index60.cjs.map +0 -1
  491. package/dist/index61.cjs.map +0 -1
  492. package/dist/index62.cjs.map +0 -1
  493. package/dist/index63.cjs.map +0 -1
  494. package/dist/index64.cjs.map +0 -1
  495. package/dist/index65.cjs.map +0 -1
  496. package/dist/index66.cjs.map +0 -1
  497. package/dist/index67.cjs.map +0 -1
  498. package/dist/index68.cjs.map +0 -1
  499. package/dist/index69.cjs.map +0 -1
  500. package/dist/index7.cjs +0 -6
  501. package/dist/index70.cjs.map +0 -1
  502. package/dist/index71.cjs.map +0 -1
  503. package/dist/index72.cjs.map +0 -1
  504. package/dist/index73.cjs.map +0 -1
  505. package/dist/index74.cjs.map +0 -1
  506. package/dist/index75.cjs.map +0 -1
  507. package/dist/index76.cjs.map +0 -1
  508. package/dist/index9.cjs.map +0 -1
  509. /package/dist/{index20.cjs → types/documents.d.cjs} +0 -0
  510. /package/dist/{index22.cjs → types/index.d.cjs} +0 -0
  511. /package/dist/{index23.cjs → types/msic-codes.d.cjs} +0 -0
  512. /package/dist/{index26.cjs → types/signatures.d.cjs} +0 -0
  513. /package/dist/{index29.cjs → types/taxpayer.d.cjs} +0 -0
  514. /package/dist/{index30.cjs → types/unit-types.d.cjs} +0 -0
  515. /package/dist/{index31.cjs → types/utils.d.cjs} +0 -0
@@ -0,0 +1,653 @@
1
+ import { formatIdValue } from "./formatIdValue-qTxJqj9o.js";
2
+ import crypto, { X509Certificate } from "crypto";
3
+
4
+ //#region src/utils/document.ts
5
+ /**
6
+ * MyInvois v1.1 Document Generation and Signing Utilities
7
+ * Strictly follows: https://sdk.myinvois.hasil.gov.my/documents/invoice-v1-1
8
+ * JSON Signature Guide: https://sdk.myinvois.hasil.gov.my/signature-creation-json/
9
+ */
10
+ /**
11
+ * Determines if a line item uses fixed rate taxation
12
+ */
13
+ const isFixedRateTax = (item) => {
14
+ return item.taxPerUnitAmount !== void 0 && item.baseUnitMeasure !== void 0;
15
+ };
16
+ /**
17
+ * Determines if a line item uses percentage taxation
18
+ */
19
+ const isPercentageTax = (item) => {
20
+ return item.taxRate !== void 0 && !isFixedRateTax(item);
21
+ };
22
+ /**
23
+ * Calculates expected tax amount for a line item based on its tax type
24
+ */
25
+ const calculateExpectedTaxAmount = (item) => {
26
+ if (isFixedRateTax(item)) return item.taxPerUnitAmount * item.baseUnitMeasure;
27
+ else if (isPercentageTax(item)) return item.totalTaxableAmountPerLine * item.taxRate / 100;
28
+ return 0;
29
+ };
30
+ /**
31
+ * Extracts the line-item array from any document variant
32
+ */
33
+ const getLineItems = (doc) => {
34
+ if ("invoiceLineItems" in doc) return doc.invoiceLineItems;
35
+ if ("creditNoteLineItems" in doc) return doc.creditNoteLineItems;
36
+ if ("debitNoteLineItems" in doc) return doc.debitNoteLineItems;
37
+ if ("refundNoteLineItems" in doc) return doc.refundNoteLineItems;
38
+ if ("selfBilledCreditNoteLineItems" in doc) return doc.selfBilledCreditNoteLineItems;
39
+ if ("selfBilledRefundNoteLineItems" in doc) return doc.selfBilledRefundNoteLineItems;
40
+ return [];
41
+ };
42
+ /**
43
+ * Helper function to recursively sort object keys for JSON canonicalization
44
+ */
45
+ function sortObjectKeys(obj) {
46
+ if (obj === null || typeof obj !== "object") return obj;
47
+ if (Array.isArray(obj)) return obj.map(sortObjectKeys);
48
+ const sortedObj = {};
49
+ const keys = Object.keys(obj).sort();
50
+ for (const key of keys) sortedObj[key] = sortObjectKeys(obj[key]);
51
+ return sortedObj;
52
+ }
53
+ /**
54
+ * Enhanced canonicalization following MyInvois specification exactly
55
+ * Key changes: ensure consistent ordering and formatting
56
+ */
57
+ const canonicalizeJSON = (obj) => {
58
+ const sortedObj = sortObjectKeys(obj);
59
+ return JSON.stringify(sortedObj, null, 0);
60
+ };
61
+ /**
62
+ * Generates a clean invoice object following MyInvois v1.1 specification exactly
63
+ * This is the base invoice structure WITHOUT signature elements (for hash calculation)
64
+ *
65
+ * Key requirements from working documents:
66
+ * - All mandatory fields must be present
67
+ * - Many optional fields must be present even if empty
68
+ * - Specific field ordering and structure
69
+ * - Correct listID values (e.g., "3166-1" not "ISO3166-1")
70
+ */
71
+ const generateCleanInvoiceObject = (invoice) => {
72
+ const lineItems = getLineItems(invoice);
73
+ const round2 = (n) => Math.round(n * 100) / 100;
74
+ const taxCategoryOrder = [];
75
+ const taxByCategory = /* @__PURE__ */ new Map();
76
+ for (const item of lineItems) {
77
+ const category = item.taxType;
78
+ if (!taxByCategory.has(category)) {
79
+ taxByCategory.set(category, {
80
+ taxable: 0,
81
+ tax: 0
82
+ });
83
+ taxCategoryOrder.push(category);
84
+ }
85
+ const bucket = taxByCategory.get(category);
86
+ bucket.taxable += item.totalTaxableAmountPerLine ?? 0;
87
+ bucket.tax += item.taxAmount ?? 0;
88
+ }
89
+ if (taxCategoryOrder.length === 0) {
90
+ taxCategoryOrder.push(lineItems[0]?.taxType || "01");
91
+ taxByCategory.set(taxCategoryOrder[0], {
92
+ taxable: invoice.legalMonetaryTotal.taxExclusiveAmount,
93
+ tax: invoice.taxTotal.taxAmount
94
+ });
95
+ }
96
+ return {
97
+ ID: [{ _: invoice.eInvoiceCodeOrNumber }],
98
+ IssueDate: [{ _: invoice.eInvoiceDate }],
99
+ IssueTime: [{ _: invoice.eInvoiceTime }],
100
+ InvoiceTypeCode: [{
101
+ _: invoice.eInvoiceTypeCode,
102
+ listVersionID: invoice.eInvoiceVersion || "1.1"
103
+ }],
104
+ DocumentCurrencyCode: [{ _: invoice.invoiceCurrencyCode }],
105
+ ..."originalEInvoiceReferenceNumber" in invoice && "originalEInvoiceInternalId" in invoice && invoice.originalEInvoiceReferenceNumber ? { BillingReference: [{ InvoiceDocumentReference: [{
106
+ UUID: [{ _: invoice.originalEInvoiceReferenceNumber }],
107
+ ID: [{ _: invoice.originalEInvoiceInternalId }]
108
+ }] }] } : {},
109
+ AccountingSupplierParty: [{ Party: [{
110
+ IndustryClassificationCode: [{
111
+ _: invoice.supplier.industryClassificationCode,
112
+ name: invoice.supplier.industryClassificationDescription
113
+ }],
114
+ PartyIdentification: [{ ID: [{
115
+ _: invoice.supplier.tin,
116
+ schemeID: "TIN"
117
+ }] }, { ID: [{
118
+ _: formatIdValue(invoice.supplier.registrationNumber),
119
+ schemeID: invoice.supplier.registrationType || "NRIC"
120
+ }] }],
121
+ PostalAddress: [{
122
+ CityName: [{ _: invoice.supplier.address.cityName }],
123
+ CountrySubentityCode: [{ _: invoice.supplier.address.state }],
124
+ AddressLine: [{ Line: [{ _: invoice.supplier.address.addressLine0 }] }],
125
+ Country: [{ IdentificationCode: [{
126
+ _: invoice.supplier.address.country || "MYS",
127
+ listID: "3166-1",
128
+ listAgencyID: "ISO"
129
+ }] }]
130
+ }],
131
+ PartyLegalEntity: [{ RegistrationName: [{ _: invoice.supplier.name }] }],
132
+ Contact: [{ Telephone: [{ _: invoice.supplier.contactNumber || "" }] }]
133
+ }] }],
134
+ AccountingCustomerParty: [{ Party: [{
135
+ PartyIdentification: [
136
+ { ID: [{
137
+ _: invoice.buyer.tin,
138
+ schemeID: "TIN"
139
+ }] },
140
+ { ID: [{
141
+ _: formatIdValue(invoice.buyer.registrationNumber),
142
+ schemeID: invoice.buyer.registrationType || "NRIC"
143
+ }] },
144
+ { ID: [{
145
+ _: invoice.buyer.sstRegistrationNumber || "NA",
146
+ schemeID: "SST"
147
+ }] }
148
+ ],
149
+ PostalAddress: [{
150
+ CityName: [{ _: invoice.buyer.address.cityName }],
151
+ CountrySubentityCode: [{ _: invoice.buyer.address.state }],
152
+ AddressLine: [{ Line: [{ _: invoice.buyer.address.addressLine0 }] }],
153
+ Country: [{ IdentificationCode: [{
154
+ _: invoice.buyer.address.country || "MYS",
155
+ listID: "3166-1",
156
+ listAgencyID: "ISO"
157
+ }] }]
158
+ }],
159
+ PartyLegalEntity: [{ RegistrationName: [{ _: invoice.buyer.name }] }],
160
+ Contact: [{ Telephone: [{ _: invoice.buyer.contactNumber || "" }] }]
161
+ }] }],
162
+ TaxTotal: [{
163
+ TaxAmount: [{
164
+ _: invoice.taxTotal.taxAmount,
165
+ currencyID: invoice.invoiceCurrencyCode
166
+ }],
167
+ TaxSubtotal: taxCategoryOrder.map((category) => {
168
+ const { taxable, tax } = taxByCategory.get(category);
169
+ return {
170
+ TaxableAmount: [{
171
+ _: round2(taxable),
172
+ currencyID: invoice.invoiceCurrencyCode
173
+ }],
174
+ TaxAmount: [{
175
+ _: round2(tax),
176
+ currencyID: invoice.invoiceCurrencyCode
177
+ }],
178
+ TaxCategory: [{
179
+ ID: [{ _: category }],
180
+ TaxScheme: [{ ID: [{
181
+ _: "OTH",
182
+ schemeAgencyID: "6",
183
+ schemeID: "UN/ECE 5153"
184
+ }] }]
185
+ }]
186
+ };
187
+ })
188
+ }],
189
+ LegalMonetaryTotal: [{
190
+ LineExtensionAmount: [{
191
+ _: invoice.legalMonetaryTotal.taxExclusiveAmount,
192
+ currencyID: invoice.invoiceCurrencyCode
193
+ }],
194
+ TaxExclusiveAmount: [{
195
+ _: invoice.legalMonetaryTotal.taxExclusiveAmount,
196
+ currencyID: invoice.invoiceCurrencyCode
197
+ }],
198
+ TaxInclusiveAmount: [{
199
+ _: invoice.legalMonetaryTotal.taxInclusiveAmount,
200
+ currencyID: invoice.invoiceCurrencyCode
201
+ }],
202
+ PayableRoundingAmount: [{
203
+ _: invoice.legalMonetaryTotal.payableRoundingAmount,
204
+ currencyID: invoice.invoiceCurrencyCode
205
+ }],
206
+ PayableAmount: [{
207
+ _: invoice.legalMonetaryTotal.payableAmount,
208
+ currencyID: invoice.invoiceCurrencyCode
209
+ }]
210
+ }],
211
+ InvoiceLine: lineItems.map((item, index) => ({
212
+ ID: [{ _: (index + 1).toString() }],
213
+ ...item.quantity !== void 0 || item.measurement !== void 0 ? { InvoicedQuantity: [{
214
+ _: item.quantity ?? 1,
215
+ ...item.measurement !== void 0 ? { unitCode: item.measurement } : {}
216
+ }] } : {},
217
+ Item: [{
218
+ CommodityClassification: [{ ItemClassificationCode: [{
219
+ _: item.itemClassificationCode,
220
+ listID: "CLASS"
221
+ }] }],
222
+ Description: [{ _: item.itemDescription }]
223
+ }],
224
+ ItemPriceExtension: [{ Amount: [{
225
+ _: (item.totalTaxableAmountPerLine ?? 0) + (item.discountAmount ?? 0),
226
+ currencyID: invoice.invoiceCurrencyCode
227
+ }] }],
228
+ LineExtensionAmount: [{
229
+ _: item.totalTaxableAmountPerLine,
230
+ currencyID: invoice.invoiceCurrencyCode
231
+ }],
232
+ Price: [{ PriceAmount: [{
233
+ _: item.unitPrice,
234
+ currencyID: invoice.invoiceCurrencyCode
235
+ }] }],
236
+ ...item.discountAmount !== void 0 || item.discountRate !== void 0 ? { AllowanceCharge: [{
237
+ ChargeIndicator: [{ _: false }],
238
+ Amount: [{
239
+ _: item.discountAmount ?? 0,
240
+ currencyID: invoice.invoiceCurrencyCode
241
+ }],
242
+ ...item.discountRate !== void 0 ? {
243
+ MultiplierFactorNumeric: [{ _: item.discountRate }],
244
+ BaseAmount: [{
245
+ _: (item.totalTaxableAmountPerLine ?? 0) + (item.discountAmount ?? 0),
246
+ currencyID: invoice.invoiceCurrencyCode
247
+ }]
248
+ } : {}
249
+ }] } : {},
250
+ TaxTotal: [{
251
+ TaxAmount: [{
252
+ _: item.taxAmount,
253
+ currencyID: invoice.invoiceCurrencyCode
254
+ }],
255
+ TaxSubtotal: [{
256
+ TaxableAmount: [{
257
+ _: item.totalTaxableAmountPerLine,
258
+ currencyID: invoice.invoiceCurrencyCode
259
+ }],
260
+ TaxAmount: [{
261
+ _: item.taxAmount,
262
+ currencyID: invoice.invoiceCurrencyCode
263
+ }],
264
+ ...item.taxPerUnitAmount !== void 0 && item.baseUnitMeasure !== void 0 ? {
265
+ PerUnitAmount: [{
266
+ _: item.taxPerUnitAmount,
267
+ currencyID: invoice.invoiceCurrencyCode
268
+ }],
269
+ BaseUnitMeasure: [{
270
+ _: item.baseUnitMeasure,
271
+ unitCode: item.baseUnitMeasureCode || "C62"
272
+ }]
273
+ } : item.taxRate !== void 0 ? { Percent: [{ _: item.taxRate }] } : {},
274
+ TaxCategory: [{
275
+ ID: [{ _: item.taxType }],
276
+ TaxScheme: [{ ID: [{
277
+ _: "OTH",
278
+ schemeAgencyID: "6",
279
+ schemeID: "UN/ECE 5153"
280
+ }] }]
281
+ }]
282
+ }]
283
+ }]
284
+ })),
285
+ TaxExchangeRate: invoice.currencyExchangeRate ? [{
286
+ SourceCurrencyCode: [{ _: invoice.invoiceCurrencyCode }],
287
+ TargetCurrencyCode: [{ _: "MYR" }],
288
+ CalculationRate: [{ _: invoice.currencyExchangeRate }]
289
+ }] : void 0
290
+ };
291
+ };
292
+ /**
293
+ * Generates the complete UBL document structure with namespace declarations
294
+ */
295
+ const generateCleanUBLDocument = (invoices) => {
296
+ return {
297
+ _D: "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2",
298
+ _A: "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2",
299
+ _B: "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2",
300
+ Invoice: invoices.map(generateCleanInvoiceObject)
301
+ };
302
+ };
303
+ /**
304
+ * Step 1: Transform the document for hashing or transmission
305
+ * Removes UBLExtensions and Signature, and minifies the JSON
306
+ * Returns the minified, cleaned JSON string
307
+ *
308
+ * FIXED: Use regex-based minification to match PowerShell script exactly
309
+ */
310
+ const transformDocumentForHashing = (invoices) => {
311
+ const cleanDocument = generateCleanUBLDocument(invoices);
312
+ const documentForTransform = JSON.parse(JSON.stringify(cleanDocument));
313
+ if (documentForTransform.Invoice && Array.isArray(documentForTransform.Invoice)) documentForTransform.Invoice.forEach((invoice) => {
314
+ delete invoice.UBLExtensions;
315
+ delete invoice.Signature;
316
+ });
317
+ const jsonString = JSON.stringify(documentForTransform);
318
+ const minifiedJson = jsonString.replace(/("(?:\\.|[^"\\])*")|\s+/g, (match, quotedString) => {
319
+ if (quotedString) return quotedString;
320
+ else return "";
321
+ });
322
+ return minifiedJson;
323
+ };
324
+ /**
325
+ * Step 2: Calculate Document Digest
326
+ * FIXED: Remove UBLExtensions and Signature before hashing (DS322)
327
+ * Based on working implementation pattern
328
+ */
329
+ const calculateDocumentDigest = (invoices) => {
330
+ const documentString = transformDocumentForHashing(invoices);
331
+ const hash = crypto.createHash("sha256");
332
+ hash.update(documentString, "utf8");
333
+ return hash.digest("base64");
334
+ };
335
+ /**
336
+ * Step 4: Calculate Certificate Digest
337
+ * Enhanced to handle certificate content properly
338
+ * FIXED: Match PowerShell script exactly - use raw certificate data like $cert.RawData
339
+ */
340
+ const calculateCertificateDigest = (certificatePem) => {
341
+ try {
342
+ const cert = new X509Certificate(certificatePem);
343
+ const rawCertificateData = cert.raw;
344
+ const hash = crypto.createHash("sha256");
345
+ hash.update(rawCertificateData);
346
+ return hash.digest("base64");
347
+ } catch {
348
+ const certificateContent = certificatePem.replace(/-----BEGIN CERTIFICATE-----/g, "").replace(/-----END CERTIFICATE-----/g, "").replace(/\s+/g, "");
349
+ const certificateBinary = Buffer.from(certificateContent, "base64");
350
+ const hash = crypto.createHash("sha256");
351
+ hash.update(certificateBinary);
352
+ return hash.digest("base64");
353
+ }
354
+ };
355
+ /**
356
+ * Enhanced certificate info extraction with better error handling
357
+ * FIXED: Normalize issuer name format to match MyInvois expectations (DS326)
358
+ */
359
+ const extractCertificateInfo = (certificatePem) => {
360
+ try {
361
+ const cert = new X509Certificate(certificatePem);
362
+ const serialNumberHex = cert.serialNumber;
363
+ const escapeXmlSpecialChars = (str) => {
364
+ return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
365
+ };
366
+ const normalizeIssuerName = (issuer) => {
367
+ const parts = issuer.split(/\r?\n|,\s*/).map((part) => part.trim()).filter((part) => part.length > 0).reverse();
368
+ return parts.join(", ").replace(/\s*=\s*/g, "=");
369
+ };
370
+ const formatSerialNumber = (serialHex) => {
371
+ const decimal = BigInt("0x" + serialHex).toString();
372
+ return decimal;
373
+ };
374
+ const rawSubjectName = cert.subject;
375
+ return {
376
+ issuerName: escapeXmlSpecialChars(normalizeIssuerName(cert.issuer)),
377
+ serialNumber: formatSerialNumber(serialNumberHex),
378
+ subjectName: rawSubjectName
379
+ };
380
+ } catch (error) {
381
+ throw new Error(`Failed to extract certificate info: ${error instanceof Error ? error.message : String(error)}`);
382
+ }
383
+ };
384
+ /**
385
+ * Step 5: Create SignedProperties with enhanced structure
386
+ * FIXED: Simplified structure to match MyInvois expectations (DS320)
387
+ * Following MyInvois JSON signature specification exactly
388
+ */
389
+ const createSignedProperties = (certificateDigest, signingTime, issuerName, serialNumber) => {
390
+ return { SignedProperties: [{
391
+ Id: "id-xades-signed-props",
392
+ SignedSignatureProperties: [{
393
+ SigningTime: [{ _: signingTime }],
394
+ SigningCertificate: [{ Cert: [{
395
+ CertDigest: [{
396
+ DigestMethod: [{
397
+ _: "",
398
+ Algorithm: "http://www.w3.org/2001/04/xmlenc#sha256"
399
+ }],
400
+ DigestValue: [{ _: certificateDigest }]
401
+ }],
402
+ IssuerSerial: [{
403
+ X509IssuerName: [{ _: issuerName }],
404
+ X509SerialNumber: [{ _: serialNumber }]
405
+ }]
406
+ }] }]
407
+ }]
408
+ }] };
409
+ };
410
+ /**
411
+ * Step 6: Calculate SignedProperties Digest
412
+ * Calculates the digest over the correct structure for validator compliance.
413
+ * FIXED: Calculate digest from SignedProperties only (without Target wrapper)
414
+ */
415
+ const calculateSignedPropertiesDigest = (signedProperties, useTargetWrapper = true) => {
416
+ let digestObj;
417
+ if (useTargetWrapper) digestObj = {
418
+ Target: "signature",
419
+ SignedProperties: signedProperties.SignedProperties
420
+ };
421
+ else digestObj = signedProperties.SignedProperties;
422
+ const signedPropertiesString = JSON.stringify(digestObj);
423
+ const minifiedSignedProperties = signedPropertiesString.replace(/("(?:\\.|[^"\\])*")|\s+/g, (match, quotedString) => {
424
+ if (quotedString) return quotedString;
425
+ else return "";
426
+ });
427
+ const hash = crypto.createHash("sha256");
428
+ hash.update(minifiedSignedProperties, "utf8");
429
+ return hash.digest("base64");
430
+ };
431
+ /**
432
+ * Step 3: Create SignedInfo and calculate signature
433
+ * Enhanced with better structure and signature generation
434
+ */
435
+ const createSignedInfoAndSign = (docDigest, propsDigest, privateKeyPem) => {
436
+ const signedInfo = {
437
+ CanonicalizationMethod: [{
438
+ _: "",
439
+ Algorithm: "http://www.w3.org/2006/12/xml-c14n11"
440
+ }],
441
+ SignatureMethod: [{
442
+ _: "",
443
+ Algorithm: "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"
444
+ }],
445
+ Reference: [{
446
+ Id: "id-doc-signed-data",
447
+ Type: "",
448
+ URI: "",
449
+ DigestMethod: [{
450
+ _: "",
451
+ Algorithm: "http://www.w3.org/2001/04/xmlenc#sha256"
452
+ }],
453
+ DigestValue: [{ _: docDigest }]
454
+ }, {
455
+ Id: "id-xades-signed-props",
456
+ Type: "http://uri.etsi.org/01903/v1.3.2#SignedProperties",
457
+ URI: "#id-xades-signed-props",
458
+ DigestMethod: [{
459
+ _: "",
460
+ Algorithm: "http://www.w3.org/2001/04/xmlenc#sha256"
461
+ }],
462
+ DigestValue: [{ _: propsDigest }]
463
+ }]
464
+ };
465
+ const signedInfoRaw = JSON.stringify(signedInfo);
466
+ try {
467
+ const signer = crypto.createSign("RSA-SHA256");
468
+ signer.update(signedInfoRaw, "utf8");
469
+ const signatureValue = signer.sign(privateKeyPem, "base64");
470
+ return {
471
+ signedInfo,
472
+ signatureValue
473
+ };
474
+ } catch (error) {
475
+ throw new Error(`Signature generation failed: ${error instanceof Error ? error.message : String(error)}`);
476
+ }
477
+ };
478
+ /**
479
+ * Signs the minified document string using the provided private key PEM
480
+ * Returns the signature as a base64 string
481
+ * FIXED: Match PowerShell script exactly - first compute hash, then sign the hash
482
+ */
483
+ const signDocumentString = (documentString, privateKeyPem) => {
484
+ const signer = crypto.createSign("RSA-SHA256");
485
+ signer.update(documentString, "utf8");
486
+ return signer.sign(privateKeyPem, "base64");
487
+ };
488
+ /**
489
+ * Complete document generation with signatures
490
+ * Follows the complete MyInvois JSON signature creation process (Steps 1-7)
491
+ */
492
+ const generateCompleteDocument = (invoices, signingCredentials) => {
493
+ try {
494
+ const docDigest = calculateDocumentDigest(invoices);
495
+ const documentString = transformDocumentForHashing(invoices);
496
+ const docSignature = signDocumentString(documentString, signingCredentials.privateKeyPem);
497
+ const now = /* @__PURE__ */ new Date();
498
+ const signingTime = now.getFullYear() + "-" + String(now.getMonth() + 1).padStart(2, "0") + "-" + String(now.getDate()).padStart(2, "0") + "T" + String(now.getHours()).padStart(2, "0") + ":" + String(now.getMinutes()).padStart(2, "0") + ":" + String(now.getSeconds()).padStart(2, "0") + "Z";
499
+ const certInfo = extractCertificateInfo(signingCredentials.certificatePem);
500
+ const certificateDigest = calculateCertificateDigest(signingCredentials.certificatePem);
501
+ const signedProperties = createSignedProperties(certificateDigest, signingTime, certInfo.issuerName, certInfo.serialNumber);
502
+ const propsDigest = calculateSignedPropertiesDigest(signedProperties);
503
+ const signedInfo = {
504
+ CanonicalizationMethod: [{
505
+ _: "",
506
+ Algorithm: "http://www.w3.org/2006/12/xml-c14n11"
507
+ }],
508
+ SignatureMethod: [{
509
+ _: "",
510
+ Algorithm: "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"
511
+ }],
512
+ Reference: [{
513
+ Id: "id-doc-signed-data",
514
+ Type: "",
515
+ URI: "",
516
+ DigestMethod: [{
517
+ _: "",
518
+ Algorithm: "http://www.w3.org/2001/04/xmlenc#sha256"
519
+ }],
520
+ DigestValue: [{ _: docDigest }]
521
+ }, {
522
+ Id: "id-xades-signed-props",
523
+ Type: "http://uri.etsi.org/01903/v1.3.2#SignedProperties",
524
+ URI: "#id-xades-signed-props",
525
+ DigestMethod: [{
526
+ _: "",
527
+ Algorithm: "http://www.w3.org/2001/04/xmlenc#sha256"
528
+ }],
529
+ DigestValue: [{ _: propsDigest }]
530
+ }]
531
+ };
532
+ const cert = new X509Certificate(signingCredentials.certificatePem);
533
+ const certificate = cert.raw.toString("base64");
534
+ const signedInvoices = invoices.map((invoice) => {
535
+ const cleanInvoice = generateCleanInvoiceObject(invoice);
536
+ return {
537
+ ...cleanInvoice,
538
+ UBLExtensions: [{ UBLExtension: [{
539
+ ExtensionURI: [{ _: "urn:oasis:names:specification:ubl:dsig:enveloped:xades" }],
540
+ ExtensionContent: [{ UBLDocumentSignatures: [{ SignatureInformation: [{
541
+ ID: [{ _: "urn:oasis:names:specification:ubl:signature:1" }],
542
+ ReferencedSignatureID: [{ _: "urn:oasis:names:specification:ubl:signature:Invoice" }],
543
+ Signature: [{
544
+ Id: "signature",
545
+ Object: [{ QualifyingProperties: [{
546
+ Target: "signature",
547
+ SignedProperties: signedProperties.SignedProperties
548
+ }] }],
549
+ KeyInfo: [{ X509Data: [{
550
+ X509Certificate: [{ _: certificate }],
551
+ X509SubjectName: [{ _: certInfo.subjectName }],
552
+ X509IssuerSerial: [{
553
+ X509IssuerName: [{ _: certInfo.issuerName }],
554
+ X509SerialNumber: [{ _: certInfo.serialNumber }]
555
+ }]
556
+ }] }],
557
+ SignatureValue: [{ _: docSignature }],
558
+ SignedInfo: [signedInfo]
559
+ }]
560
+ }] }] }]
561
+ }] }],
562
+ Signature: [{
563
+ ID: [{ _: "urn:oasis:names:specification:ubl:signature:Invoice" }],
564
+ SignatureMethod: [{ _: "urn:oasis:names:specification:ubl:dsig:enveloped:xades" }]
565
+ }]
566
+ };
567
+ });
568
+ return {
569
+ _D: "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2",
570
+ _A: "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2",
571
+ _B: "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2",
572
+ Invoice: signedInvoices
573
+ };
574
+ } catch (error) {
575
+ throw new Error(`Document generation failed: ${error instanceof Error ? error.message : String(error)}`);
576
+ }
577
+ };
578
+ /**
579
+ * Creates a line item with percentage-based taxation (e.g., SST, GST)
580
+ */
581
+ const createPercentageTaxLineItem = (params) => {
582
+ const quantity = params.quantity ? params.quantity <= 0 ? 1 : params.quantity ?? 1 : 1;
583
+ const preDiscountAmount = params.unitPrice * quantity;
584
+ const hasDiscount = params.discountAmount !== void 0 || params.discountRate !== void 0;
585
+ const computedDiscountByRate = hasDiscount && params.discountRate !== void 0 ? preDiscountAmount * params.discountRate : 0;
586
+ const discountAmount = hasDiscount && params.discountAmount !== void 0 ? params.discountAmount : computedDiscountByRate;
587
+ const totalTaxableAmount = Math.max(0, preDiscountAmount - (hasDiscount ? discountAmount : 0));
588
+ const taxAmount = totalTaxableAmount * params.taxRate / 100;
589
+ return {
590
+ itemClassificationCode: params.itemClassificationCode,
591
+ itemDescription: params.itemDescription,
592
+ unitPrice: params.unitPrice,
593
+ taxType: params.taxType,
594
+ taxRate: params.taxRate,
595
+ ...params.quantity !== void 0 ? { quantity: params.quantity } : {},
596
+ ...params.measurement !== void 0 ? { measurement: params.measurement } : {},
597
+ ...hasDiscount && discountAmount !== void 0 ? { discountAmount } : {},
598
+ ...hasDiscount && params.discountRate !== void 0 ? { discountRate: params.discountRate } : {},
599
+ taxAmount: Math.round(taxAmount * 100) / 100,
600
+ totalTaxableAmountPerLine: totalTaxableAmount,
601
+ totalAmountPerLine: totalTaxableAmount + taxAmount
602
+ };
603
+ };
604
+ /**
605
+ * Creates a line item with fixed rate taxation (e.g., Tourism Tax)
606
+ */
607
+ const createFixedRateTaxLineItem = (params) => {
608
+ const quantity = params.quantity || 1;
609
+ const preDiscountAmount = params.unitPrice * quantity;
610
+ const hasDiscount = params.discountAmount !== void 0 || params.discountRate !== void 0;
611
+ const computedDiscountByRate = hasDiscount && params.discountRate !== void 0 ? preDiscountAmount * params.discountRate : 0;
612
+ const discountAmount = hasDiscount && params.discountAmount !== void 0 ? params.discountAmount : computedDiscountByRate;
613
+ const totalTaxableAmount = Math.max(0, preDiscountAmount - (hasDiscount ? discountAmount : 0));
614
+ const taxAmount = params.taxPerUnitAmount * params.baseUnitMeasure;
615
+ return {
616
+ itemClassificationCode: params.itemClassificationCode,
617
+ itemDescription: params.itemDescription,
618
+ unitPrice: params.unitPrice,
619
+ taxType: params.taxType,
620
+ taxPerUnitAmount: params.taxPerUnitAmount,
621
+ baseUnitMeasure: params.baseUnitMeasure,
622
+ baseUnitMeasureCode: params.baseUnitMeasureCode,
623
+ ...params.quantity !== void 0 ? { quantity: params.quantity } : {},
624
+ ...params.measurement !== void 0 ? { measurement: params.measurement } : {},
625
+ ...hasDiscount && discountAmount !== void 0 ? { discountAmount } : {},
626
+ ...hasDiscount && params.discountRate !== void 0 ? { discountRate: params.discountRate } : {},
627
+ taxAmount: Math.round(taxAmount * 100) / 100,
628
+ totalTaxableAmountPerLine: totalTaxableAmount,
629
+ totalAmountPerLine: totalTaxableAmount + taxAmount
630
+ };
631
+ };
632
+ /**
633
+ * Calculates invoice totals from line items
634
+ */
635
+ const calculateInvoiceTotals = (lineItems, payableRoundingAmount = 0) => {
636
+ const taxExclusiveAmount = lineItems.reduce((sum, item) => sum + item.totalTaxableAmountPerLine, 0);
637
+ const totalTaxAmount = lineItems.reduce((sum, item) => sum + item.taxAmount, 0);
638
+ const taxInclusiveAmount = taxExclusiveAmount + totalTaxAmount;
639
+ const payableAmount = taxInclusiveAmount + payableRoundingAmount;
640
+ return {
641
+ legalMonetaryTotal: {
642
+ taxExclusiveAmount: Math.round(taxExclusiveAmount * 100) / 100,
643
+ taxInclusiveAmount: Math.round(taxInclusiveAmount * 100) / 100,
644
+ payableRoundingAmount: Math.round(payableRoundingAmount * 100) / 100,
645
+ payableAmount: Math.round(payableAmount * 100) / 100
646
+ },
647
+ taxTotal: { taxAmount: Math.round(totalTaxAmount * 100) / 100 }
648
+ };
649
+ };
650
+
651
+ //#endregion
652
+ export { calculateCertificateDigest, calculateDocumentDigest, calculateExpectedTaxAmount, calculateInvoiceTotals, calculateSignedPropertiesDigest, canonicalizeJSON, createFixedRateTaxLineItem, createPercentageTaxLineItem, createSignedInfoAndSign, createSignedProperties, extractCertificateInfo, generateCleanInvoiceObject, generateCleanUBLDocument, generateCompleteDocument, isFixedRateTax, isPercentageTax, signDocumentString, sortObjectKeys, transformDocumentForHashing };
653
+ //# sourceMappingURL=document-BC52NCdW.js.map