@ripwords/myinvois-client 0.0.9 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (558) hide show
  1. package/bun.lock +89 -132
  2. package/dist/0X-C4IRh_fJ.d.ts +211 -0
  3. package/dist/0X-C4IRh_fJ.d.ts.map +1 -0
  4. package/dist/0X-Yw7mZEro.d.cts +211 -0
  5. package/dist/0X-Yw7mZEro.d.cts.map +1 -0
  6. package/dist/1X-Brnls9Jh.d.ts +112 -0
  7. package/dist/1X-Brnls9Jh.d.ts.map +1 -0
  8. package/dist/1X-BwpSoT3o.d.cts +20 -0
  9. package/dist/1X-BwpSoT3o.d.cts.map +1 -0
  10. package/dist/1X-C-_KHV-Q.d.ts +20 -0
  11. package/dist/1X-C-_KHV-Q.d.ts.map +1 -0
  12. package/dist/1X-D_aUVsuM.d.cts +112 -0
  13. package/dist/1X-D_aUVsuM.d.cts.map +1 -0
  14. package/dist/2X-Bb6elyzV.d.cts +40 -0
  15. package/dist/2X-Bb6elyzV.d.cts.map +1 -0
  16. package/dist/2X-DkS1BoE5.d.ts +40 -0
  17. package/dist/2X-DkS1BoE5.d.ts.map +1 -0
  18. package/dist/2X-UdQcQW24.d.ts +140 -0
  19. package/dist/2X-UdQcQW24.d.ts.map +1 -0
  20. package/dist/2X-hClUyw26.d.cts +140 -0
  21. package/dist/2X-hClUyw26.d.cts.map +1 -0
  22. package/dist/3X-C7VFD-n-.d.cts +21 -0
  23. package/dist/3X-C7VFD-n-.d.cts.map +1 -0
  24. package/dist/3X-CLMESDvz.d.cts +62 -0
  25. package/dist/3X-CLMESDvz.d.cts.map +1 -0
  26. package/dist/3X-DFI-4RQQ.d.ts +21 -0
  27. package/dist/3X-DFI-4RQQ.d.ts.map +1 -0
  28. package/dist/3X-DVDyspgb.d.ts +62 -0
  29. package/dist/3X-DVDyspgb.d.ts.map +1 -0
  30. package/dist/4X-CIJ2JJ2w.d.ts +31 -0
  31. package/dist/4X-CIJ2JJ2w.d.ts.map +1 -0
  32. package/dist/4X-CUR8jlaZ.d.ts +265 -0
  33. package/dist/4X-CUR8jlaZ.d.ts.map +1 -0
  34. package/dist/4X-CvScPJTf.d.cts +265 -0
  35. package/dist/4X-CvScPJTf.d.cts.map +1 -0
  36. package/dist/4X-DIfvpU6V.d.cts +31 -0
  37. package/dist/4X-DIfvpU6V.d.cts.map +1 -0
  38. package/dist/5X-BOUxhadJ.d.cts +22 -0
  39. package/dist/5X-BOUxhadJ.d.cts.map +1 -0
  40. package/dist/5X-C6db432h.d.ts +77 -0
  41. package/dist/5X-C6db432h.d.ts.map +1 -0
  42. package/dist/5X-COsZHUaQ.d.ts +22 -0
  43. package/dist/5X-COsZHUaQ.d.ts.map +1 -0
  44. package/dist/5X-CkLu7Vyd.d.cts +77 -0
  45. package/dist/5X-CkLu7Vyd.d.cts.map +1 -0
  46. package/dist/6X-C_fFIcJC.d.ts +105 -0
  47. package/dist/6X-C_fFIcJC.d.ts.map +1 -0
  48. package/dist/6X-ClZDKOTC.d.ts +16 -0
  49. package/dist/6X-ClZDKOTC.d.ts.map +1 -0
  50. package/dist/6X-DE7RJeV6.d.cts +16 -0
  51. package/dist/6X-DE7RJeV6.d.cts.map +1 -0
  52. package/dist/6X-Mf32k1d0.d.cts +105 -0
  53. package/dist/6X-Mf32k1d0.d.cts.map +1 -0
  54. package/dist/7X-BZyesooz.d.ts +16 -0
  55. package/dist/7X-BZyesooz.d.ts.map +1 -0
  56. package/dist/7X-Chtd6B66.d.cts +16 -0
  57. package/dist/7X-Chtd6B66.d.cts.map +1 -0
  58. package/dist/7X-DoCUcp-J.d.cts +71 -0
  59. package/dist/7X-DoCUcp-J.d.cts.map +1 -0
  60. package/dist/7X-kot_VccM.d.ts +71 -0
  61. package/dist/7X-kot_VccM.d.ts.map +1 -0
  62. package/dist/8X-Df4DOBOe.d.ts +110 -0
  63. package/dist/8X-Df4DOBOe.d.ts.map +1 -0
  64. package/dist/8X-DkuKAkHz.d.ts +19 -0
  65. package/dist/8X-DkuKAkHz.d.ts.map +1 -0
  66. package/dist/8X-DqZyMvyV.d.cts +19 -0
  67. package/dist/8X-DqZyMvyV.d.cts.map +1 -0
  68. package/dist/8X-Dr9RunRw.d.cts +110 -0
  69. package/dist/8X-Dr9RunRw.d.cts.map +1 -0
  70. package/dist/9X-BDgifncF.d.ts +15 -0
  71. package/dist/9X-BDgifncF.d.ts.map +1 -0
  72. package/dist/9X-BaoZtjWF.d.cts +98 -0
  73. package/dist/9X-BaoZtjWF.d.cts.map +1 -0
  74. package/dist/9X-BcAb6Uso.d.cts +15 -0
  75. package/dist/9X-BcAb6Uso.d.cts.map +1 -0
  76. package/dist/9X-BhBWlgxG.d.ts +98 -0
  77. package/dist/9X-BhBWlgxG.d.ts.map +1 -0
  78. package/dist/AX-BY72FohC.d.cts +111 -0
  79. package/dist/AX-BY72FohC.d.cts.map +1 -0
  80. package/dist/AX-D6XHWdrY.d.ts +111 -0
  81. package/dist/AX-D6XHWdrY.d.ts.map +1 -0
  82. package/dist/BX-CA0OmrUZ.d.cts +115 -0
  83. package/dist/BX-CA0OmrUZ.d.cts.map +1 -0
  84. package/dist/BX-D_0C8Qbd.d.ts +115 -0
  85. package/dist/BX-D_0C8Qbd.d.ts.map +1 -0
  86. package/dist/CX-HH4cSZRX.d.ts +128 -0
  87. package/dist/CX-HH4cSZRX.d.ts.map +1 -0
  88. package/dist/CX-glpQSL8x.d.cts +128 -0
  89. package/dist/CX-glpQSL8x.d.cts.map +1 -0
  90. package/dist/DX-DimL1MDM.d.cts +115 -0
  91. package/dist/DX-DimL1MDM.d.cts.map +1 -0
  92. package/dist/DX-Dx22ax_I.d.ts +115 -0
  93. package/dist/DX-Dx22ax_I.d.ts.map +1 -0
  94. package/dist/EX-BRWh1wFc.d.ts +107 -0
  95. package/dist/EX-BRWh1wFc.d.ts.map +1 -0
  96. package/dist/EX-Cx87Ruxl.d.cts +107 -0
  97. package/dist/EX-Cx87Ruxl.d.cts.map +1 -0
  98. package/dist/FX-D81UlxNN.d.cts +127 -0
  99. package/dist/FX-D81UlxNN.d.cts.map +1 -0
  100. package/dist/FX-RmjwAr40.d.ts +127 -0
  101. package/dist/FX-RmjwAr40.d.ts.map +1 -0
  102. package/dist/GX-9i7piP9G.d.cts +136 -0
  103. package/dist/GX-9i7piP9G.d.cts.map +1 -0
  104. package/dist/GX-CJyo7oDp.d.ts +136 -0
  105. package/dist/GX-CJyo7oDp.d.ts.map +1 -0
  106. package/dist/HX-20GVJAvl.d.cts +126 -0
  107. package/dist/HX-20GVJAvl.d.cts.map +1 -0
  108. package/dist/HX-XALBTdLA.d.ts +126 -0
  109. package/dist/HX-XALBTdLA.d.ts.map +1 -0
  110. package/dist/IX-6SZ55QKb.d.ts +23 -0
  111. package/dist/IX-6SZ55QKb.d.ts.map +1 -0
  112. package/dist/IX-D54NGPsc.d.cts +23 -0
  113. package/dist/IX-D54NGPsc.d.cts.map +1 -0
  114. package/dist/JX-C1RYcwQX.d.cts +104 -0
  115. package/dist/JX-C1RYcwQX.d.cts.map +1 -0
  116. package/dist/JX-hQ1XRmLp.d.ts +104 -0
  117. package/dist/JX-hQ1XRmLp.d.ts.map +1 -0
  118. package/dist/KX-BNwunEfn.d.ts +151 -0
  119. package/dist/KX-BNwunEfn.d.ts.map +1 -0
  120. package/dist/KX-gQHCIgtQ.d.cts +151 -0
  121. package/dist/KX-gQHCIgtQ.d.cts.map +1 -0
  122. package/dist/LX-CHYX3X3J.d.ts +123 -0
  123. package/dist/LX-CHYX3X3J.d.ts.map +1 -0
  124. package/dist/LX-CPurJGIh.d.cts +123 -0
  125. package/dist/LX-CPurJGIh.d.cts.map +1 -0
  126. package/dist/MX-BPGLWSUz.d.ts +153 -0
  127. package/dist/MX-BPGLWSUz.d.ts.map +1 -0
  128. package/dist/MX-BnyW5eHf.d.cts +153 -0
  129. package/dist/MX-BnyW5eHf.d.cts.map +1 -0
  130. package/dist/MyInvoisClient-BrNyMjS-.d.cts +178 -0
  131. package/dist/MyInvoisClient-BrNyMjS-.d.cts.map +1 -0
  132. package/dist/MyInvoisClient-CXu4pdl-.d.ts +178 -0
  133. package/dist/MyInvoisClient-CXu4pdl-.d.ts.map +1 -0
  134. package/dist/MyInvoisClient-Cnvb5iUC.js +299 -0
  135. package/dist/MyInvoisClient-Cnvb5iUC.js.map +1 -0
  136. package/dist/MyInvoisClient-DO1dJfQq.cjs +304 -0
  137. package/dist/MyInvoisClient-DO1dJfQq.cjs.map +1 -0
  138. package/dist/NX-B11fQuco.d.cts +122 -0
  139. package/dist/NX-B11fQuco.d.cts.map +1 -0
  140. package/dist/NX-RulN5Ml3.d.ts +122 -0
  141. package/dist/NX-RulN5Ml3.d.ts.map +1 -0
  142. package/dist/OX-DgKVSp7I.d.ts +26 -0
  143. package/dist/OX-DgKVSp7I.d.ts.map +1 -0
  144. package/dist/OX-T-ydRXQS.d.cts +26 -0
  145. package/dist/OX-T-ydRXQS.d.cts.map +1 -0
  146. package/dist/PX-DA4A2kEv.d.ts +121 -0
  147. package/dist/PX-DA4A2kEv.d.ts.map +1 -0
  148. package/dist/PX-p0n1SzvU.d.cts +121 -0
  149. package/dist/PX-p0n1SzvU.d.cts.map +1 -0
  150. package/dist/QX-CI1NccIB.d.cts +59 -0
  151. package/dist/QX-CI1NccIB.d.cts.map +1 -0
  152. package/dist/QX-DrFqsMEs.d.ts +59 -0
  153. package/dist/QX-DrFqsMEs.d.ts.map +1 -0
  154. package/dist/RX-Cm7vFcFN.d.ts +23 -0
  155. package/dist/RX-Cm7vFcFN.d.ts.map +1 -0
  156. package/dist/RX-DnNKol22.d.cts +23 -0
  157. package/dist/RX-DnNKol22.d.cts.map +1 -0
  158. package/dist/SX-BUjiWQYz.d.cts +40 -0
  159. package/dist/SX-BUjiWQYz.d.cts.map +1 -0
  160. package/dist/SX-CsPPTu-W.d.ts +40 -0
  161. package/dist/SX-CsPPTu-W.d.ts.map +1 -0
  162. package/dist/TX-DCY25MdR.d.ts +31 -0
  163. package/dist/TX-DCY25MdR.d.ts.map +1 -0
  164. package/dist/TX-DOEpsf05.d.cts +31 -0
  165. package/dist/TX-DOEpsf05.d.cts.map +1 -0
  166. package/dist/UX-DauyagHy.d.ts +18 -0
  167. package/dist/UX-DauyagHy.d.ts.map +1 -0
  168. package/dist/UX-DgUOnTFK.d.cts +18 -0
  169. package/dist/UX-DgUOnTFK.d.cts.map +1 -0
  170. package/dist/VX-DD4scgCe.d.ts +17 -0
  171. package/dist/VX-DD4scgCe.d.ts.map +1 -0
  172. package/dist/VX-kUX6LM-3.d.cts +17 -0
  173. package/dist/VX-kUX6LM-3.d.cts.map +1 -0
  174. package/dist/WX-CjkoppdY.d.ts +26 -0
  175. package/dist/WX-CjkoppdY.d.ts.map +1 -0
  176. package/dist/WX-DPfyPFFh.d.cts +26 -0
  177. package/dist/WX-DPfyPFFh.d.cts.map +1 -0
  178. package/dist/XX-C4C1gQZH.d.cts +828 -0
  179. package/dist/XX-C4C1gQZH.d.cts.map +1 -0
  180. package/dist/XX-sbsIUOnA.d.ts +828 -0
  181. package/dist/XX-sbsIUOnA.d.ts.map +1 -0
  182. package/dist/YX-BeT-LsiA.d.cts +20 -0
  183. package/dist/YX-BeT-LsiA.d.cts.map +1 -0
  184. package/dist/YX-DUdO8mRC.d.ts +20 -0
  185. package/dist/YX-DUdO8mRC.d.ts.map +1 -0
  186. package/dist/ZX-BuVTTq-D.d.cts +22 -0
  187. package/dist/ZX-BuVTTq-D.d.cts.map +1 -0
  188. package/dist/ZX-DwfcSA-D.d.ts +22 -0
  189. package/dist/ZX-DwfcSA-D.d.ts.map +1 -0
  190. package/dist/api/platform/platformLogin.d.ts +67 -0
  191. package/dist/api/platform/platformLogin.d.ts.map +1 -0
  192. package/dist/api/platform/platformLogin.js +3 -0
  193. package/dist/canonicalize-C_fNNpYr.cjs +80 -0
  194. package/dist/canonicalize-C_fNNpYr.cjs.map +1 -0
  195. package/dist/canonicalize-DNUrCGad.js +68 -0
  196. package/dist/canonicalize-DNUrCGad.js.map +1 -0
  197. package/dist/chunk-CUT6urMc.cjs +30 -0
  198. package/dist/classification-codes-B15PbWxz.d.cts +118 -0
  199. package/dist/classification-codes-B15PbWxz.d.cts.map +1 -0
  200. package/dist/classification-codes-C2X4xW5-.d.ts +118 -0
  201. package/dist/classification-codes-C2X4xW5-.d.ts.map +1 -0
  202. package/dist/country-code-DPeNFMMi.d.cts +543 -0
  203. package/dist/country-code-DPeNFMMi.d.cts.map +1 -0
  204. package/dist/country-code-DsI8Mbzx.d.ts +543 -0
  205. package/dist/country-code-DsI8Mbzx.d.ts.map +1 -0
  206. package/dist/currencies-DKuDflOO.d.ts +208 -0
  207. package/dist/currencies-DKuDflOO.d.ts.map +1 -0
  208. package/dist/currencies-S5g1gzBU.d.cts +208 -0
  209. package/dist/currencies-S5g1gzBU.d.cts.map +1 -0
  210. package/dist/e-invoice-BuwtFnlI.d.cts +44 -0
  211. package/dist/e-invoice-BuwtFnlI.d.cts.map +1 -0
  212. package/dist/e-invoice-C2TxhyrK.d.ts +44 -0
  213. package/dist/e-invoice-C2TxhyrK.d.ts.map +1 -0
  214. package/dist/getBaseUrl-CO7Jp27d.cjs +14 -0
  215. package/dist/getBaseUrl-CO7Jp27d.cjs.map +1 -0
  216. package/dist/getBaseUrl-Dx6RDC8I.js +8 -0
  217. package/dist/getBaseUrl-Dx6RDC8I.js.map +1 -0
  218. package/dist/hashCert-Bol7lIh2.js +62 -0
  219. package/dist/hashCert-Bol7lIh2.js.map +1 -0
  220. package/dist/hashCert-mlYEuYex.cjs +68 -0
  221. package/dist/hashCert-mlYEuYex.cjs.map +1 -0
  222. package/dist/hashSignedProperties-9vj5wlYR.js +83 -0
  223. package/dist/hashSignedProperties-9vj5wlYR.js.map +1 -0
  224. package/dist/hashSignedProperties-CU_ZqqmY.cjs +95 -0
  225. package/dist/hashSignedProperties-CU_ZqqmY.cjs.map +1 -0
  226. package/dist/index-B1DSs-wd.d.cts +16 -0
  227. package/dist/index-B1DSs-wd.d.cts.map +1 -0
  228. package/dist/index-CJNLQVjx.d.ts +1 -0
  229. package/dist/index-FTgB2nM6.d.ts +16 -0
  230. package/dist/index-FTgB2nM6.d.ts.map +1 -0
  231. package/dist/index-Wy1ONBjV.d.cts +1 -0
  232. package/dist/index.cjs +13 -97
  233. package/dist/index.d.ts +60 -5664
  234. package/dist/index.js +11 -93
  235. package/dist/index10.cjs +34 -0
  236. package/dist/index10.cjs.map +1 -0
  237. package/dist/index11.cjs +24 -0
  238. package/dist/index11.cjs.map +1 -0
  239. package/dist/index12.cjs +0 -0
  240. package/dist/index13.cjs +13 -0
  241. package/dist/index14.cjs +13 -0
  242. package/dist/index14.cjs.map +1 -0
  243. package/dist/index15.cjs +3 -0
  244. package/dist/index16.cjs +17 -0
  245. package/dist/index17.cjs +3 -0
  246. package/dist/index18.cjs +208 -0
  247. package/dist/index18.cjs.map +1 -0
  248. package/dist/index19.cjs +109 -0
  249. package/dist/index19.cjs.map +1 -0
  250. package/dist/index2.cjs +62 -0
  251. package/dist/index2.cjs.map +1 -0
  252. package/dist/index20.cjs +137 -0
  253. package/dist/index20.cjs.map +1 -0
  254. package/dist/index21.cjs +64 -0
  255. package/dist/index21.cjs.map +1 -0
  256. package/dist/index22.cjs +267 -0
  257. package/dist/index22.cjs.map +1 -0
  258. package/dist/index23.cjs +79 -0
  259. package/dist/index23.cjs.map +1 -0
  260. package/dist/index24.cjs +107 -0
  261. package/dist/index24.cjs.map +1 -0
  262. package/dist/index25.cjs +73 -0
  263. package/dist/index25.cjs.map +1 -0
  264. package/dist/index26.cjs +112 -0
  265. package/dist/index26.cjs.map +1 -0
  266. package/dist/index27.cjs +100 -0
  267. package/dist/index27.cjs.map +1 -0
  268. package/dist/index28.cjs +18 -0
  269. package/dist/index28.cjs.map +1 -0
  270. package/dist/index29.cjs +38 -0
  271. package/dist/index29.cjs.map +1 -0
  272. package/dist/index3.cjs +532 -0
  273. package/dist/index3.cjs.map +1 -0
  274. package/dist/index30.cjs +19 -0
  275. package/dist/index30.cjs.map +1 -0
  276. package/dist/index31.cjs +29 -0
  277. package/dist/index31.cjs.map +1 -0
  278. package/dist/index32.cjs +20 -0
  279. package/dist/index32.cjs.map +1 -0
  280. package/dist/index33.cjs +14 -0
  281. package/dist/index33.cjs.map +1 -0
  282. package/dist/index34.cjs +14 -0
  283. package/dist/index34.cjs.map +1 -0
  284. package/dist/index35.cjs +17 -0
  285. package/dist/index35.cjs.map +1 -0
  286. package/dist/index36.cjs +13 -0
  287. package/dist/index36.cjs.map +1 -0
  288. package/dist/index37.cjs +108 -0
  289. package/dist/index37.cjs.map +1 -0
  290. package/dist/index38.cjs +113 -0
  291. package/dist/index38.cjs.map +1 -0
  292. package/dist/index39.cjs +126 -0
  293. package/dist/index39.cjs.map +1 -0
  294. package/dist/index4.cjs +196 -0
  295. package/dist/index4.cjs.map +1 -0
  296. package/dist/index40.cjs +113 -0
  297. package/dist/index40.cjs.map +1 -0
  298. package/dist/index41.cjs +105 -0
  299. package/dist/index41.cjs.map +1 -0
  300. package/dist/index42.cjs +125 -0
  301. package/dist/index42.cjs.map +1 -0
  302. package/dist/index43.cjs +134 -0
  303. package/dist/index43.cjs.map +1 -0
  304. package/dist/index44.cjs +124 -0
  305. package/dist/index44.cjs.map +1 -0
  306. package/dist/index45.cjs +21 -0
  307. package/dist/index45.cjs.map +1 -0
  308. package/dist/index46.cjs +102 -0
  309. package/dist/index46.cjs.map +1 -0
  310. package/dist/index47.cjs +149 -0
  311. package/dist/index47.cjs.map +1 -0
  312. package/dist/index48.cjs +121 -0
  313. package/dist/index48.cjs.map +1 -0
  314. package/dist/index49.cjs +151 -0
  315. package/dist/index49.cjs.map +1 -0
  316. package/dist/index5.cjs +25 -0
  317. package/dist/index5.cjs.map +1 -0
  318. package/dist/index50.cjs +120 -0
  319. package/dist/index50.cjs.map +1 -0
  320. package/dist/index51.cjs +24 -0
  321. package/dist/index51.cjs.map +1 -0
  322. package/dist/index52.cjs +119 -0
  323. package/dist/index52.cjs.map +1 -0
  324. package/dist/index53.cjs +54 -0
  325. package/dist/index53.cjs.map +1 -0
  326. package/dist/index54.cjs +21 -0
  327. package/dist/index54.cjs.map +1 -0
  328. package/dist/index55.cjs +35 -0
  329. package/dist/index55.cjs.map +1 -0
  330. package/dist/index56.cjs +29 -0
  331. package/dist/index56.cjs.map +1 -0
  332. package/dist/index57.cjs +16 -0
  333. package/dist/index57.cjs.map +1 -0
  334. package/dist/index58.cjs +15 -0
  335. package/dist/index58.cjs.map +1 -0
  336. package/dist/index59.cjs +24 -0
  337. package/dist/index59.cjs.map +1 -0
  338. package/dist/index59.cts.map +1 -0
  339. package/dist/index6.cjs +0 -0
  340. package/dist/index60.cjs +419 -0
  341. package/dist/index60.cjs.map +1 -0
  342. package/dist/index61.cjs +15 -0
  343. package/dist/index61.cjs.map +1 -0
  344. package/dist/index62.cjs +16 -0
  345. package/dist/index62.cjs.map +1 -0
  346. package/dist/index62.cts.map +1 -0
  347. package/dist/index63.cjs +0 -0
  348. package/dist/index63.cts.map +1 -0
  349. package/dist/index64.cjs +0 -0
  350. package/dist/index64.cts.map +1 -0
  351. package/dist/index65.cjs +122 -0
  352. package/dist/index65.cjs.map +1 -0
  353. package/dist/index65.cts.map +1 -0
  354. package/dist/index66.cjs +229 -0
  355. package/dist/index66.cjs.map +1 -0
  356. package/dist/index66.cts.map +1 -0
  357. package/dist/index67.cjs +4 -0
  358. package/dist/index67.cts.map +1 -0
  359. package/dist/index68.cjs +3 -0
  360. package/dist/index68.cts.map +1 -0
  361. package/dist/index69.cjs +4 -0
  362. package/dist/index69.cts.map +1 -0
  363. package/dist/index7.cjs +0 -0
  364. package/dist/index70.cjs +3 -0
  365. package/dist/index70.cts.map +1 -0
  366. package/dist/index71.cjs +3 -0
  367. package/dist/index71.cts.map +1 -0
  368. package/dist/index72.cjs +3 -0
  369. package/dist/index72.cts.map +1 -0
  370. package/dist/index73.cjs +3 -0
  371. package/dist/index73.cts.map +1 -0
  372. package/dist/index8.cjs +25 -0
  373. package/dist/index8.cjs.map +1 -0
  374. package/dist/index9.cjs +0 -0
  375. package/dist/invoice-1_1-BJVcw-oE.d.ts +432 -0
  376. package/dist/invoice-1_1-BJVcw-oE.d.ts.map +1 -0
  377. package/dist/invoice-1_1-DWdNPRzr.d.cts +432 -0
  378. package/dist/invoice-1_1-DWdNPRzr.d.cts.map +1 -0
  379. package/dist/invoice1-1-8S-QQn7P.cjs +547 -0
  380. package/dist/invoice1-1-8S-QQn7P.cjs.map +1 -0
  381. package/dist/invoice1-1-CHuLpkFz.js +504 -0
  382. package/dist/invoice1-1-CHuLpkFz.js.map +1 -0
  383. package/dist/msic-codes-B_1W6lZF.d.cts +26 -0
  384. package/dist/msic-codes-B_1W6lZF.d.cts.map +1 -0
  385. package/dist/msic-codes-bs0lTfSZ.d.ts +26 -0
  386. package/dist/msic-codes-bs0lTfSZ.d.ts.map +1 -0
  387. package/dist/payment-modes-B8dNy3SM.d.ts +44 -0
  388. package/dist/payment-modes-B8dNy3SM.d.ts.map +1 -0
  389. package/dist/payment-modes-DHihrywe.d.cts +44 -0
  390. package/dist/payment-modes-DHihrywe.d.cts.map +1 -0
  391. package/dist/platformLogin-DsxWWUXr.js +31 -0
  392. package/dist/platformLogin-DsxWWUXr.js.map +1 -0
  393. package/dist/platformLogin-PGzMhw1X.cjs +37 -0
  394. package/dist/platformLogin-PGzMhw1X.cjs.map +1 -0
  395. package/dist/populateFinalDocument-BdyYzz5Y.cjs +96 -0
  396. package/dist/populateFinalDocument-BdyYzz5Y.cjs.map +1 -0
  397. package/dist/populateFinalDocument-BpLXmgLv.js +90 -0
  398. package/dist/populateFinalDocument-BpLXmgLv.js.map +1 -0
  399. package/dist/populateSignedProperties-BJMcBQ6S.cjs +58 -0
  400. package/dist/populateSignedProperties-BJMcBQ6S.cjs.map +1 -0
  401. package/dist/populateSignedProperties-BvGN-YZH.js +52 -0
  402. package/dist/populateSignedProperties-BvGN-YZH.js.map +1 -0
  403. package/dist/sign-B61Cy3gO.cjs +40 -0
  404. package/dist/sign-B61Cy3gO.cjs.map +1 -0
  405. package/dist/sign-DzHK7UhR.js +34 -0
  406. package/dist/sign-DzHK7UhR.js.map +1 -0
  407. package/dist/signatures-BKi9DP2K.d.cts +173 -0
  408. package/dist/signatures-BKi9DP2K.d.cts.map +1 -0
  409. package/dist/signatures-C9QPZTQd.d.ts +173 -0
  410. package/dist/signatures-C9QPZTQd.d.ts.map +1 -0
  411. package/dist/state-codes-CxG1S9YY.d.ts +62 -0
  412. package/dist/state-codes-CxG1S9YY.d.ts.map +1 -0
  413. package/dist/state-codes-DXSWtE6a.d.cts +62 -0
  414. package/dist/state-codes-DXSWtE6a.d.cts.map +1 -0
  415. package/dist/tax-types-CEpfSh5P.d.ts +42 -0
  416. package/dist/tax-types-CEpfSh5P.d.ts.map +1 -0
  417. package/dist/tax-types-CgwxONDS.d.cts +42 -0
  418. package/dist/tax-types-CgwxONDS.d.cts.map +1 -0
  419. package/dist/transform-BLz0S687.cjs +72 -0
  420. package/dist/transform-BLz0S687.cjs.map +1 -0
  421. package/dist/transform-D1q-U6Zj.js +66 -0
  422. package/dist/transform-D1q-U6Zj.js.map +1 -0
  423. package/dist/types/classification-codes.d.ts +2 -0
  424. package/dist/types/country-code.d.ts +2 -0
  425. package/dist/types/currencies.d.ts +2 -0
  426. package/dist/types/documents/index.d.ts +57 -0
  427. package/dist/types/documents/invoice-1_1.d.ts +56 -0
  428. package/dist/types/e-invoice.d.ts +2 -0
  429. package/dist/types/index.d.ts +59 -0
  430. package/dist/types/msic/0X.d.ts +2 -0
  431. package/dist/types/msic/1X.d.ts +2 -0
  432. package/dist/types/msic/2X.d.ts +2 -0
  433. package/dist/types/msic/3X.d.ts +2 -0
  434. package/dist/types/msic/4X.d.ts +2 -0
  435. package/dist/types/msic/5X.d.ts +2 -0
  436. package/dist/types/msic/6X.d.ts +2 -0
  437. package/dist/types/msic/7X.d.ts +2 -0
  438. package/dist/types/msic/8X.d.ts +2 -0
  439. package/dist/types/msic/9X.d.ts +2 -0
  440. package/dist/types/msic-codes.d.ts +12 -0
  441. package/dist/types/payment-modes.d.ts +2 -0
  442. package/dist/types/signatures.d.ts +2 -0
  443. package/dist/types/state-codes.d.ts +2 -0
  444. package/dist/types/tax-types.d.ts +2 -0
  445. package/dist/types/unit/1X.d.ts +2 -0
  446. package/dist/types/unit/2X.d.ts +2 -0
  447. package/dist/types/unit/3X.d.ts +2 -0
  448. package/dist/types/unit/4X.d.ts +2 -0
  449. package/dist/types/unit/5X.d.ts +2 -0
  450. package/dist/types/unit/6X.d.ts +2 -0
  451. package/dist/types/unit/7X.d.ts +2 -0
  452. package/dist/types/unit/8X.d.ts +2 -0
  453. package/dist/types/unit/9X.d.ts +2 -0
  454. package/dist/types/unit/AX.d.ts +2 -0
  455. package/dist/types/unit/BX.d.ts +2 -0
  456. package/dist/types/unit/CX.d.ts +2 -0
  457. package/dist/types/unit/DX.d.ts +2 -0
  458. package/dist/types/unit/EX.d.ts +2 -0
  459. package/dist/types/unit/FX.d.ts +2 -0
  460. package/dist/types/unit/GX.d.ts +2 -0
  461. package/dist/types/unit/HX.d.ts +2 -0
  462. package/dist/types/unit/IX.d.ts +2 -0
  463. package/dist/types/unit/JX.d.ts +2 -0
  464. package/dist/types/unit/KX.d.ts +2 -0
  465. package/dist/types/unit/LX.d.ts +2 -0
  466. package/dist/types/unit/MX.d.ts +2 -0
  467. package/dist/types/unit/NX.d.ts +2 -0
  468. package/dist/types/unit/OX.d.ts +2 -0
  469. package/dist/types/unit/PX.d.ts +2 -0
  470. package/dist/types/unit/QX.d.ts +2 -0
  471. package/dist/types/unit/RX.d.ts +2 -0
  472. package/dist/types/unit/SX.d.ts +2 -0
  473. package/dist/types/unit/TX.d.ts +2 -0
  474. package/dist/types/unit/UX.d.ts +2 -0
  475. package/dist/types/unit/VX.d.ts +2 -0
  476. package/dist/types/unit/WX.d.ts +2 -0
  477. package/dist/types/unit/XX.d.ts +2 -0
  478. package/dist/types/unit/YX.d.ts +2 -0
  479. package/dist/types/unit/ZX.d.ts +2 -0
  480. package/dist/types/unit-types.d.ts +37 -0
  481. package/dist/unit-types-1bF0KhIp.d.ts +56 -0
  482. package/dist/unit-types-1bF0KhIp.d.ts.map +1 -0
  483. package/dist/unit-types-CsrkvgfG.d.cts +56 -0
  484. package/dist/unit-types-CsrkvgfG.d.cts.map +1 -0
  485. package/dist/utils/MyInvoisClient.d.ts +60 -0
  486. package/dist/utils/MyInvoisClient.js +13 -0
  487. package/dist/utils/base64.d.ts +6 -0
  488. package/dist/utils/base64.d.ts.map +1 -0
  489. package/dist/utils/base64.js +11 -0
  490. package/dist/utils/base64.js.map +1 -0
  491. package/dist/utils/debug/debug-document-hash.d.ts +100 -0
  492. package/dist/utils/debug/debug-document-hash.d.ts.map +1 -0
  493. package/dist/utils/debug/debug-document-hash.js +120 -0
  494. package/dist/utils/debug/debug-document-hash.js.map +1 -0
  495. package/dist/utils/debug/debug-invoice-submission.d.ts +152 -0
  496. package/dist/utils/debug/debug-invoice-submission.d.ts.map +1 -0
  497. package/dist/utils/debug/debug-invoice-submission.js +226 -0
  498. package/dist/utils/debug/debug-invoice-submission.js.map +1 -0
  499. package/dist/utils/getBaseUrl.d.ts +5 -0
  500. package/dist/utils/getBaseUrl.d.ts.map +1 -0
  501. package/dist/utils/getBaseUrl.js +3 -0
  502. package/dist/utils/invoice1-1.d.ts +117 -0
  503. package/dist/utils/invoice1-1.d.ts.map +1 -0
  504. package/dist/utils/invoice1-1.js +10 -0
  505. package/dist/utils/signature/canonicalize.d.ts +26 -0
  506. package/dist/utils/signature/canonicalize.d.ts.map +1 -0
  507. package/dist/utils/signature/canonicalize.js +3 -0
  508. package/dist/utils/signature/hashCert.d.ts +15 -0
  509. package/dist/utils/signature/hashCert.d.ts.map +1 -0
  510. package/dist/utils/signature/hashCert.js +3 -0
  511. package/dist/utils/signature/hashSignedProperties.d.ts +25 -0
  512. package/dist/utils/signature/hashSignedProperties.d.ts.map +1 -0
  513. package/dist/utils/signature/hashSignedProperties.js +3 -0
  514. package/dist/utils/signature/populateFinalDocument.d.ts +23 -0
  515. package/dist/utils/signature/populateFinalDocument.d.ts.map +1 -0
  516. package/dist/utils/signature/populateFinalDocument.js +3 -0
  517. package/dist/utils/signature/populateSignedProperties.d.ts +23 -0
  518. package/dist/utils/signature/populateSignedProperties.d.ts.map +1 -0
  519. package/dist/utils/signature/populateSignedProperties.js +3 -0
  520. package/dist/utils/signature/sign.d.ts +16 -0
  521. package/dist/utils/signature/sign.d.ts.map +1 -0
  522. package/dist/utils/signature/sign.js +3 -0
  523. package/dist/utils/signature/transform.d.ts +16 -0
  524. package/dist/utils/signature/transform.d.ts.map +1 -0
  525. package/dist/utils/signature/transform.js +3 -0
  526. package/package.json +12 -5
  527. package/src/api/platform/{taxpayerLogin.ts → platformLogin.ts} +8 -2
  528. package/src/types/documents/invoice-1_1.d.ts +90 -0
  529. package/src/types/index.d.ts +1 -0
  530. package/src/types/msic-codes.d.ts +1 -7
  531. package/src/utils/MyInvoisClient.ts +428 -11
  532. package/src/utils/base64.ts +7 -0
  533. package/src/utils/debug/debug-document-hash.ts +249 -0
  534. package/src/utils/debug/debug-invoice-submission.ts +355 -0
  535. package/src/utils/getBaseUrl.ts +1 -1
  536. package/src/utils/invoice1-1.ts +671 -0
  537. package/src/utils/signature/canonicalize.ts +104 -0
  538. package/src/utils/signature/hashCert.ts +115 -0
  539. package/src/utils/signature/hashSignedProperties.ts +155 -0
  540. package/src/utils/signature/populateFinalDocument.ts +187 -0
  541. package/src/utils/signature/populateSignedProperties.ts +87 -0
  542. package/src/utils/signature/sign.ts +51 -0
  543. package/src/utils/signature/transform.ts +99 -0
  544. package/test/MyInvoiClientWithRealData.test.ts +2 -1
  545. package/test/MyInvoisClient.test.ts +16 -8
  546. package/test/base64.test.ts +43 -0
  547. package/test/canonicalize.test.ts +110 -0
  548. package/test/hashCert.test.ts +95 -0
  549. package/test/hashSignedProperties.test.ts +140 -0
  550. package/test/populateFinalDocument.test.ts +218 -0
  551. package/test/populateSignedProperties.test.ts +155 -0
  552. package/test/sign.test.ts +70 -0
  553. package/test/signAndSubmitInvoice.test.ts +915 -0
  554. package/test/transform.test.ts +158 -0
  555. package/tsconfig.json +7 -1
  556. package/tsdown.config.ts +31 -0
  557. package/dist/index.cjs.map +0 -1
  558. package/rolldown.config.ts +0 -26
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hashCert-Bol7lIh2.js","names":["pemCert: string","certificatePem: string","error: any"],"sources":["../src/utils/signature/hashCert.ts"],"sourcesContent":["import * as crypto from 'crypto'\n\n/**\n * Extracts the Base64 encoded DER certificate from a PEM string.\n * Removes headers/footers and newlines.\n *\n * @param pemCert The certificate in PEM format (string).\n * @returns The Base64 encoded DER certificate string.\n * @throws {Error} If the PEM format is invalid or content is not found.\n */\nfunction extractBase64FromPem(pemCert: string): string {\n const beginMarker = '-----BEGIN CERTIFICATE-----'\n const endMarker = '-----END CERTIFICATE-----'\n\n let startIndex = pemCert.indexOf(beginMarker)\n let endIndex = pemCert.indexOf(endMarker)\n let currentBeginMarker = beginMarker\n\n // Check for primary markers\n if (startIndex === -1 || endIndex === -1 || endIndex <= startIndex) {\n // Try finding other common markers if the primary one fails\n const altBeginMarker = '-----BEGIN PUBLIC KEY-----'\n const altEndMarker = '-----END PUBLIC KEY-----'\n startIndex = pemCert.indexOf(altBeginMarker)\n endIndex = pemCert.indexOf(altEndMarker)\n currentBeginMarker = altBeginMarker\n\n if (startIndex === -1 || endIndex === -1 || endIndex <= startIndex) {\n throw new Error(\n 'Invalid PEM format: Missing or misplaced BEGIN/END markers (CERTIFICATE or other expected type).',\n )\n }\n }\n\n // Extract the raw content between markers (including newlines, etc.)\n const content = pemCert.substring(\n startIndex + currentBeginMarker.length,\n endIndex,\n )\n\n // Validate the raw content *before* cleaning - check for invalid chars within the block\n // This regex checks if there's anything *other than* whitespace or Base64 characters.\n const invalidCharRegex = /[^A-Za-z0-9+/=\\s]/\n if (invalidCharRegex.test(content)) {\n throw new Error(\n 'Invalid non-Base64, non-whitespace characters detected in PEM content block.',\n )\n }\n\n // Clean the extracted content: remove only whitespace (newlines, spaces)\n const base64Der = content.replace(/\\s/g, '')\n\n // Final check: ensure the cleaned string is valid Base64 format (e.g., correct padding)\n const base64FormatRegex = /^[A-Za-z0-9+/]*={0,2}$/\n if (!base64FormatRegex.test(base64Der)) {\n // This might catch incorrect padding or other structural issues post-cleaning\n throw new Error(\n 'Invalid Base64 structure (e.g., padding) after cleaning PEM content.',\n )\n }\n\n if (base64Der.length === 0) {\n throw new Error(\n 'Invalid PEM format: No Base64 content found between markers after cleaning.',\n )\n }\n\n return base64Der\n}\n\n/**\n * Hashes the signing certificate using SHA-256 and encodes the hash in Base64.\n *\n * Corresponds to Step 5 in the MyInvois Signature Creation guide:\n * https://sdk.myinvois.hasil.gov.my/signature-creation/#step-5-generate-the-certificate-hash\n *\n * @param certificatePem The signing certificate in PEM format (string).\n * @returns The Base64 encoded SHA-256 hash of the certificate (CertDigest).\n * @throws {Error} If hashing fails or PEM is invalid.\n */\nexport function hashCertificate(certificatePem: string): string {\n try {\n // 1. Extract *and validate* Base64 DER content from PEM\n const base64Der = extractBase64FromPem(certificatePem)\n\n // Base64 validation is now done inside extractBase64FromPem\n // const base64Regex = /^[A-Za-z0-9+/]*={0,2}$/;\n // if (base64Der.length > 0 && !base64Regex.test(base64Der)) {\n // throw new Error('Invalid Base64 characters detected in PEM certificate content.')\n // }\n\n // 2. Decode Base64 to get the raw DER bytes\n const rawDer = Buffer.from(base64Der, 'base64')\n\n // The check below might be redundant now with the improved extraction/validation,\n // but kept as a fallback safety measure.\n if (base64Der.length > 0 && rawDer.length === 0) {\n throw new Error(\n 'Invalid Base64 content characters in PEM certificate (Buffer decoding check).',\n )\n }\n\n // 3. Hash the raw DER certificate using SHA-256\n const hash = crypto.createHash('sha256')\n hash.update(rawDer)\n\n // 4. Encode the hash digest to Base64\n const base64CertDigest = hash.digest('base64')\n\n return base64CertDigest\n } catch (error: any) {\n console.error('Error hashing certificate:', error)\n throw new Error(`Failed to hash certificate: ${error.message || error}`)\n }\n}\n"],"mappings":";;;;;;;;;;;AAUA,SAAS,qBAAqBA,SAAyB;CACrD,MAAM,cAAc;CACpB,MAAM,YAAY;CAElB,IAAI,aAAa,QAAQ,QAAQ,YAAY;CAC7C,IAAI,WAAW,QAAQ,QAAQ,UAAU;CACzC,IAAI,qBAAqB;AAGzB,KAAI,eAAe,MAAM,aAAa,MAAM,YAAY,YAAY;EAElE,MAAM,iBAAiB;EACvB,MAAM,eAAe;AACrB,eAAa,QAAQ,QAAQ,eAAe;AAC5C,aAAW,QAAQ,QAAQ,aAAa;AACxC,uBAAqB;AAErB,MAAI,eAAe,MAAM,aAAa,MAAM,YAAY,WACtD,OAAM,IAAI,MACR;CAGL;CAGD,MAAM,UAAU,QAAQ,UACtB,aAAa,mBAAmB,QAChC,SACD;CAID,MAAM,mBAAmB;AACzB,KAAI,iBAAiB,KAAK,QAAQ,CAChC,OAAM,IAAI,MACR;CAKJ,MAAM,YAAY,QAAQ,QAAQ,OAAO,GAAG;CAG5C,MAAM,oBAAoB;AAC1B,MAAK,kBAAkB,KAAK,UAAU,CAEpC,OAAM,IAAI,MACR;AAIJ,KAAI,UAAU,WAAW,EACvB,OAAM,IAAI,MACR;AAIJ,QAAO;AACR;;;;;;;;;;;AAYD,SAAgB,gBAAgBC,gBAAgC;AAC9D,KAAI;EAEF,MAAM,YAAY,qBAAqB,eAAe;EAStD,MAAM,SAAS,OAAO,KAAK,WAAW,SAAS;AAI/C,MAAI,UAAU,SAAS,KAAK,OAAO,WAAW,EAC5C,OAAM,IAAI,MACR;EAKJ,MAAM,OAAO,OAAO,WAAW,SAAS;AACxC,OAAK,OAAO,OAAO;EAGnB,MAAM,mBAAmB,KAAK,OAAO,SAAS;AAE9C,SAAO;CACR,SAAQC,OAAY;AACnB,UAAQ,MAAM,8BAA8B,MAAM;AAClD,QAAM,IAAI,OAAO,8BAA8B,MAAM,WAAW,MAAM;CACvE;AACF"}
@@ -0,0 +1,68 @@
1
+ const require_chunk = require('./chunk-CUT6urMc.cjs');
2
+ const crypto = require_chunk.__toESM(require("crypto"));
3
+
4
+ //#region src/utils/signature/hashCert.ts
5
+ /**
6
+ * Extracts the Base64 encoded DER certificate from a PEM string.
7
+ * Removes headers/footers and newlines.
8
+ *
9
+ * @param pemCert The certificate in PEM format (string).
10
+ * @returns The Base64 encoded DER certificate string.
11
+ * @throws {Error} If the PEM format is invalid or content is not found.
12
+ */
13
+ function extractBase64FromPem(pemCert) {
14
+ const beginMarker = "-----BEGIN CERTIFICATE-----";
15
+ const endMarker = "-----END CERTIFICATE-----";
16
+ let startIndex = pemCert.indexOf(beginMarker);
17
+ let endIndex = pemCert.indexOf(endMarker);
18
+ let currentBeginMarker = beginMarker;
19
+ if (startIndex === -1 || endIndex === -1 || endIndex <= startIndex) {
20
+ const altBeginMarker = "-----BEGIN PUBLIC KEY-----";
21
+ const altEndMarker = "-----END PUBLIC KEY-----";
22
+ startIndex = pemCert.indexOf(altBeginMarker);
23
+ endIndex = pemCert.indexOf(altEndMarker);
24
+ currentBeginMarker = altBeginMarker;
25
+ if (startIndex === -1 || endIndex === -1 || endIndex <= startIndex) throw new Error("Invalid PEM format: Missing or misplaced BEGIN/END markers (CERTIFICATE or other expected type).");
26
+ }
27
+ const content = pemCert.substring(startIndex + currentBeginMarker.length, endIndex);
28
+ const invalidCharRegex = /[^A-Za-z0-9+/=\s]/;
29
+ if (invalidCharRegex.test(content)) throw new Error("Invalid non-Base64, non-whitespace characters detected in PEM content block.");
30
+ const base64Der = content.replace(/\s/g, "");
31
+ const base64FormatRegex = /^[A-Za-z0-9+/]*={0,2}$/;
32
+ if (!base64FormatRegex.test(base64Der)) throw new Error("Invalid Base64 structure (e.g., padding) after cleaning PEM content.");
33
+ if (base64Der.length === 0) throw new Error("Invalid PEM format: No Base64 content found between markers after cleaning.");
34
+ return base64Der;
35
+ }
36
+ /**
37
+ * Hashes the signing certificate using SHA-256 and encodes the hash in Base64.
38
+ *
39
+ * Corresponds to Step 5 in the MyInvois Signature Creation guide:
40
+ * https://sdk.myinvois.hasil.gov.my/signature-creation/#step-5-generate-the-certificate-hash
41
+ *
42
+ * @param certificatePem The signing certificate in PEM format (string).
43
+ * @returns The Base64 encoded SHA-256 hash of the certificate (CertDigest).
44
+ * @throws {Error} If hashing fails or PEM is invalid.
45
+ */
46
+ function hashCertificate(certificatePem) {
47
+ try {
48
+ const base64Der = extractBase64FromPem(certificatePem);
49
+ const rawDer = Buffer.from(base64Der, "base64");
50
+ if (base64Der.length > 0 && rawDer.length === 0) throw new Error("Invalid Base64 content characters in PEM certificate (Buffer decoding check).");
51
+ const hash = crypto.createHash("sha256");
52
+ hash.update(rawDer);
53
+ const base64CertDigest = hash.digest("base64");
54
+ return base64CertDigest;
55
+ } catch (error) {
56
+ console.error("Error hashing certificate:", error);
57
+ throw new Error(`Failed to hash certificate: ${error.message || error}`);
58
+ }
59
+ }
60
+
61
+ //#endregion
62
+ Object.defineProperty(exports, 'hashCertificate', {
63
+ enumerable: true,
64
+ get: function () {
65
+ return hashCertificate;
66
+ }
67
+ });
68
+ //# sourceMappingURL=hashCert-mlYEuYex.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hashCert-mlYEuYex.cjs","names":["pemCert: string","certificatePem: string","error: any"],"sources":["../src/utils/signature/hashCert.ts"],"sourcesContent":["import * as crypto from 'crypto'\n\n/**\n * Extracts the Base64 encoded DER certificate from a PEM string.\n * Removes headers/footers and newlines.\n *\n * @param pemCert The certificate in PEM format (string).\n * @returns The Base64 encoded DER certificate string.\n * @throws {Error} If the PEM format is invalid or content is not found.\n */\nfunction extractBase64FromPem(pemCert: string): string {\n const beginMarker = '-----BEGIN CERTIFICATE-----'\n const endMarker = '-----END CERTIFICATE-----'\n\n let startIndex = pemCert.indexOf(beginMarker)\n let endIndex = pemCert.indexOf(endMarker)\n let currentBeginMarker = beginMarker\n\n // Check for primary markers\n if (startIndex === -1 || endIndex === -1 || endIndex <= startIndex) {\n // Try finding other common markers if the primary one fails\n const altBeginMarker = '-----BEGIN PUBLIC KEY-----'\n const altEndMarker = '-----END PUBLIC KEY-----'\n startIndex = pemCert.indexOf(altBeginMarker)\n endIndex = pemCert.indexOf(altEndMarker)\n currentBeginMarker = altBeginMarker\n\n if (startIndex === -1 || endIndex === -1 || endIndex <= startIndex) {\n throw new Error(\n 'Invalid PEM format: Missing or misplaced BEGIN/END markers (CERTIFICATE or other expected type).',\n )\n }\n }\n\n // Extract the raw content between markers (including newlines, etc.)\n const content = pemCert.substring(\n startIndex + currentBeginMarker.length,\n endIndex,\n )\n\n // Validate the raw content *before* cleaning - check for invalid chars within the block\n // This regex checks if there's anything *other than* whitespace or Base64 characters.\n const invalidCharRegex = /[^A-Za-z0-9+/=\\s]/\n if (invalidCharRegex.test(content)) {\n throw new Error(\n 'Invalid non-Base64, non-whitespace characters detected in PEM content block.',\n )\n }\n\n // Clean the extracted content: remove only whitespace (newlines, spaces)\n const base64Der = content.replace(/\\s/g, '')\n\n // Final check: ensure the cleaned string is valid Base64 format (e.g., correct padding)\n const base64FormatRegex = /^[A-Za-z0-9+/]*={0,2}$/\n if (!base64FormatRegex.test(base64Der)) {\n // This might catch incorrect padding or other structural issues post-cleaning\n throw new Error(\n 'Invalid Base64 structure (e.g., padding) after cleaning PEM content.',\n )\n }\n\n if (base64Der.length === 0) {\n throw new Error(\n 'Invalid PEM format: No Base64 content found between markers after cleaning.',\n )\n }\n\n return base64Der\n}\n\n/**\n * Hashes the signing certificate using SHA-256 and encodes the hash in Base64.\n *\n * Corresponds to Step 5 in the MyInvois Signature Creation guide:\n * https://sdk.myinvois.hasil.gov.my/signature-creation/#step-5-generate-the-certificate-hash\n *\n * @param certificatePem The signing certificate in PEM format (string).\n * @returns The Base64 encoded SHA-256 hash of the certificate (CertDigest).\n * @throws {Error} If hashing fails or PEM is invalid.\n */\nexport function hashCertificate(certificatePem: string): string {\n try {\n // 1. Extract *and validate* Base64 DER content from PEM\n const base64Der = extractBase64FromPem(certificatePem)\n\n // Base64 validation is now done inside extractBase64FromPem\n // const base64Regex = /^[A-Za-z0-9+/]*={0,2}$/;\n // if (base64Der.length > 0 && !base64Regex.test(base64Der)) {\n // throw new Error('Invalid Base64 characters detected in PEM certificate content.')\n // }\n\n // 2. Decode Base64 to get the raw DER bytes\n const rawDer = Buffer.from(base64Der, 'base64')\n\n // The check below might be redundant now with the improved extraction/validation,\n // but kept as a fallback safety measure.\n if (base64Der.length > 0 && rawDer.length === 0) {\n throw new Error(\n 'Invalid Base64 content characters in PEM certificate (Buffer decoding check).',\n )\n }\n\n // 3. Hash the raw DER certificate using SHA-256\n const hash = crypto.createHash('sha256')\n hash.update(rawDer)\n\n // 4. Encode the hash digest to Base64\n const base64CertDigest = hash.digest('base64')\n\n return base64CertDigest\n } catch (error: any) {\n console.error('Error hashing certificate:', error)\n throw new Error(`Failed to hash certificate: ${error.message || error}`)\n }\n}\n"],"mappings":";;;;;;;;;;;;AAUA,SAAS,qBAAqBA,SAAyB;CACrD,MAAM,cAAc;CACpB,MAAM,YAAY;CAElB,IAAI,aAAa,QAAQ,QAAQ,YAAY;CAC7C,IAAI,WAAW,QAAQ,QAAQ,UAAU;CACzC,IAAI,qBAAqB;AAGzB,KAAI,eAAe,MAAM,aAAa,MAAM,YAAY,YAAY;EAElE,MAAM,iBAAiB;EACvB,MAAM,eAAe;AACrB,eAAa,QAAQ,QAAQ,eAAe;AAC5C,aAAW,QAAQ,QAAQ,aAAa;AACxC,uBAAqB;AAErB,MAAI,eAAe,MAAM,aAAa,MAAM,YAAY,WACtD,OAAM,IAAI,MACR;CAGL;CAGD,MAAM,UAAU,QAAQ,UACtB,aAAa,mBAAmB,QAChC,SACD;CAID,MAAM,mBAAmB;AACzB,KAAI,iBAAiB,KAAK,QAAQ,CAChC,OAAM,IAAI,MACR;CAKJ,MAAM,YAAY,QAAQ,QAAQ,OAAO,GAAG;CAG5C,MAAM,oBAAoB;AAC1B,MAAK,kBAAkB,KAAK,UAAU,CAEpC,OAAM,IAAI,MACR;AAIJ,KAAI,UAAU,WAAW,EACvB,OAAM,IAAI,MACR;AAIJ,QAAO;AACR;;;;;;;;;;;AAYD,SAAgB,gBAAgBC,gBAAgC;AAC9D,KAAI;EAEF,MAAM,YAAY,qBAAqB,eAAe;EAStD,MAAM,SAAS,OAAO,KAAK,WAAW,SAAS;AAI/C,MAAI,UAAU,SAAS,KAAK,OAAO,WAAW,EAC5C,OAAM,IAAI,MACR;EAKJ,MAAM,OAAO,OAAO,WAAW,SAAS;AACxC,OAAK,OAAO,OAAO;EAGnB,MAAM,mBAAmB,KAAK,OAAO,SAAS;AAE9C,SAAO;CACR,SAAQC,OAAY;AACnB,UAAQ,MAAM,8BAA8B,MAAM;AAClD,QAAM,IAAI,OAAO,8BAA8B,MAAM,WAAW,MAAM;CACvE;AACF"}
@@ -0,0 +1,83 @@
1
+ import * as crypto from "crypto";
2
+ import c14nFactory from "xml-c14n";
3
+ import * as xpath from "xpath-ts";
4
+
5
+ //#region src/utils/signature/hashSignedProperties.ts
6
+ /**
7
+ * Selects the SignedProperties element, canonicalizes it using the best available
8
+ * canonicalization algorithm, hashes it using SHA-256, and returns the Base64 encoded digest.
9
+ *
10
+ * Corresponds to Step 7 in the MyInvois Signature Creation guide:
11
+ * https://sdk.myinvois.hasil.gov.my/signature-creation/#step-7-generate-signed-properties-hash
12
+ *
13
+ * Note: MyInvois documentation specifies C14N 1.1, but due to limited Node.js library support,
14
+ * this implementation uses Exclusive C14N which is widely supported and should be compatible
15
+ * in most cases. If signature validation fails, this may need to be updated.
16
+ *
17
+ * @param doc The XML Document object (from xmldom-ts) after SignedProperties population (Step 6).
18
+ * @param algorithm Optional canonicalization algorithm URI. Defaults to Exclusive C14N.
19
+ * @returns A Promise resolving to the Base64 encoded SHA-256 hash (PropsDigest).
20
+ * @throws {Error} If the SignedProperties element cannot be found or canonicalization/hashing fails.
21
+ */
22
+ function hashSignedProperties(doc, algorithm = "http://www.w3.org/2001/10/xml-exc-c14n#") {
23
+ return new Promise((resolve, reject) => {
24
+ try {
25
+ const ns = {
26
+ inv: "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2",
27
+ ext: "urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2",
28
+ sig: "urn:oasis:names:specification:ubl:schema:xsd:CommonSignatureComponents-2",
29
+ sac: "urn:oasis:names:specification:ubl:schema:xsd:SignatureAggregateComponents-2",
30
+ ds: "http://www.w3.org/2000/09/xmldsig#",
31
+ xades: "http://uri.etsi.org/01903/v1.3.2#"
32
+ };
33
+ const select = xpath.useNamespaces(ns);
34
+ const signedPropertiesXPath = "/inv:Invoice/ext:UBLExtensions/ext:UBLExtension/ext:ExtensionContent/sig:UBLDocumentSignatures/sac:SignatureInformation/ds:Signature/ds:Object/xades:QualifyingProperties/xades:SignedProperties";
35
+ const nodes = select(signedPropertiesXPath, doc);
36
+ if (!Array.isArray(nodes) || nodes.length === 0) throw new Error(`SignedProperties element not found for XPath: ${signedPropertiesXPath}`);
37
+ if (nodes.length > 1) throw new Error(`Multiple SignedProperties elements found (expected 1): ${signedPropertiesXPath}`);
38
+ const signedPropertiesNode = nodes[0];
39
+ if (!signedPropertiesNode) throw new Error("Selected SignedProperties node is invalid or null.");
40
+ const c14n = c14nFactory();
41
+ let algorithmUri = algorithm;
42
+ if (algorithm === "https://www.w3.org/TR/xml-c14n11") {
43
+ console.warn("C14N 1.1 requested for SignedProperties but may not be supported, falling back to Exclusive C14N");
44
+ algorithmUri = "http://www.w3.org/2001/10/xml-exc-c14n#";
45
+ }
46
+ const canonicaliser = c14n.createCanonicaliser(algorithmUri);
47
+ canonicaliser.canonicalise(signedPropertiesNode, (error, canonicalXml) => {
48
+ if (error) {
49
+ console.error("Error during SignedProperties canonicalization:", error);
50
+ return reject(new Error(`SignedProperties canonicalization failed: ${error.message || error}`));
51
+ }
52
+ if (typeof canonicalXml !== "string") return reject(new Error("SignedProperties canonicalization did not return a string result."));
53
+ try {
54
+ const hash = crypto.createHash("sha256");
55
+ hash.update(canonicalXml, "utf8");
56
+ const base64PropsDigest = hash.digest("base64");
57
+ resolve(base64PropsDigest);
58
+ } catch (hashError) {
59
+ console.error("Error during SignedProperties hashing:", hashError);
60
+ reject(new Error(`SignedProperties hashing failed: ${hashError.message || hashError}`));
61
+ }
62
+ });
63
+ } catch (setupError) {
64
+ console.error("Error setting up or selecting SignedProperties:", setupError);
65
+ reject(new Error(`SignedProperties processing setup failed: ${setupError.message || setupError}`));
66
+ }
67
+ });
68
+ }
69
+ /**
70
+ * Attempts to use C14N 1.1 for SignedProperties if available, otherwise falls back to Exclusive C14N.
71
+ */
72
+ async function hashSignedPropertiesWithC14N11Fallback(doc) {
73
+ try {
74
+ return await hashSignedProperties(doc, "http://www.w3.org/2006/12/xml-c14n11");
75
+ } catch (error) {
76
+ console.warn("C14N 1.1 failed for SignedProperties, falling back to Exclusive C14N:", error);
77
+ return await hashSignedProperties(doc, "http://www.w3.org/2001/10/xml-exc-c14n#");
78
+ }
79
+ }
80
+
81
+ //#endregion
82
+ export { hashSignedProperties, hashSignedPropertiesWithC14N11Fallback };
83
+ //# sourceMappingURL=hashSignedProperties-9vj5wlYR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hashSignedProperties-9vj5wlYR.js","names":["doc: Document","algorithm: string","hashError: any","setupError: any"],"sources":["../src/utils/signature/hashSignedProperties.ts"],"sourcesContent":["import * as crypto from 'crypto'\nimport * as xpath from 'xpath-ts'\nimport c14nFactory from 'xml-c14n'\n\n/**\n * Selects the SignedProperties element, canonicalizes it using the best available\n * canonicalization algorithm, hashes it using SHA-256, and returns the Base64 encoded digest.\n *\n * Corresponds to Step 7 in the MyInvois Signature Creation guide:\n * https://sdk.myinvois.hasil.gov.my/signature-creation/#step-7-generate-signed-properties-hash\n *\n * Note: MyInvois documentation specifies C14N 1.1, but due to limited Node.js library support,\n * this implementation uses Exclusive C14N which is widely supported and should be compatible\n * in most cases. If signature validation fails, this may need to be updated.\n *\n * @param doc The XML Document object (from xmldom-ts) after SignedProperties population (Step 6).\n * @param algorithm Optional canonicalization algorithm URI. Defaults to Exclusive C14N.\n * @returns A Promise resolving to the Base64 encoded SHA-256 hash (PropsDigest).\n * @throws {Error} If the SignedProperties element cannot be found or canonicalization/hashing fails.\n */\nexport function hashSignedProperties(\n doc: Document,\n algorithm: string = 'http://www.w3.org/2001/10/xml-exc-c14n#',\n): Promise<string> {\n return new Promise((resolve, reject) => {\n try {\n // Define namespaces, including the default namespace for Invoice\n const ns = {\n inv: 'urn:oasis:names:specification:ubl:schema:xsd:Invoice-2',\n ext: 'urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2',\n sig: 'urn:oasis:names:specification:ubl:schema:xsd:CommonSignatureComponents-2',\n sac: 'urn:oasis:names:specification:ubl:schema:xsd:SignatureAggregateComponents-2',\n ds: 'http://www.w3.org/2000/09/xmldsig#',\n xades: 'http://uri.etsi.org/01903/v1.3.2#',\n }\n const select = xpath.useNamespaces(ns)\n\n // 1. Get the SignedProperties element using XPath\n const signedPropertiesXPath =\n '/inv:Invoice/ext:UBLExtensions/ext:UBLExtension/ext:ExtensionContent/sig:UBLDocumentSignatures/sac:SignatureInformation/ds:Signature/ds:Object/xades:QualifyingProperties/xades:SignedProperties'\n const nodes = select(signedPropertiesXPath, doc)\n\n if (!Array.isArray(nodes) || nodes.length === 0) {\n throw new Error(\n `SignedProperties element not found for XPath: ${signedPropertiesXPath}`,\n )\n }\n if (nodes.length > 1) {\n throw new Error(\n `Multiple SignedProperties elements found (expected 1): ${signedPropertiesXPath}`,\n )\n }\n const signedPropertiesNode = nodes[0] as Node\n\n if (!signedPropertiesNode) {\n throw new Error('Selected SignedProperties node is invalid or null.')\n }\n\n // 2. Canonicalize the SignedProperties node\n const c14n = c14nFactory()\n\n // Try C14N 1.1 first, fallback to Exclusive C14N\n let algorithmUri = algorithm\n\n // If C14N 1.1 is requested but not available, use Exclusive C14N\n if (algorithm === 'https://www.w3.org/TR/xml-c14n11') {\n console.warn(\n 'C14N 1.1 requested for SignedProperties but may not be supported, falling back to Exclusive C14N',\n )\n algorithmUri = 'http://www.w3.org/2001/10/xml-exc-c14n#'\n }\n\n const canonicaliser = c14n.createCanonicaliser(algorithmUri)\n\n // Canonicalize the SignedProperties node using the callback pattern\n canonicaliser.canonicalise(\n signedPropertiesNode,\n (error, canonicalXml) => {\n if (error) {\n console.error(\n 'Error during SignedProperties canonicalization:',\n error,\n )\n return reject(\n new Error(\n `SignedProperties canonicalization failed: ${error.message || error}`,\n ),\n )\n }\n\n if (typeof canonicalXml !== 'string') {\n return reject(\n new Error(\n 'SignedProperties canonicalization did not return a string result.',\n ),\n )\n }\n\n try {\n // 3. Hash the canonicalized property tag using SHA-256\n const hash = crypto.createHash('sha256')\n hash.update(canonicalXml, 'utf8')\n\n // 4. Encode the hashed property tag using Base64 Encoder\n const base64PropsDigest = hash.digest('base64')\n\n resolve(base64PropsDigest)\n } catch (hashError: any) {\n console.error('Error during SignedProperties hashing:', hashError)\n reject(\n new Error(\n `SignedProperties hashing failed: ${hashError.message || hashError}`,\n ),\n )\n }\n },\n )\n } catch (setupError: any) {\n console.error(\n 'Error setting up or selecting SignedProperties:',\n setupError,\n )\n reject(\n new Error(\n `SignedProperties processing setup failed: ${setupError.message || setupError}`,\n ),\n )\n }\n })\n}\n\n/**\n * Attempts to use C14N 1.1 for SignedProperties if available, otherwise falls back to Exclusive C14N.\n */\nexport async function hashSignedPropertiesWithC14N11Fallback(\n doc: Document,\n): Promise<string> {\n try {\n // Try C14N 1.1 first (may not be supported by xml-c14n library)\n return await hashSignedProperties(\n doc,\n 'http://www.w3.org/2006/12/xml-c14n11',\n )\n } catch (error) {\n console.warn(\n 'C14N 1.1 failed for SignedProperties, falling back to Exclusive C14N:',\n error,\n )\n // Fallback to Exclusive C14N\n return await hashSignedProperties(\n doc,\n 'http://www.w3.org/2001/10/xml-exc-c14n#',\n )\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,qBACdA,KACAC,YAAoB,2CACH;AACjB,QAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,MAAI;GAEF,MAAM,KAAK;IACT,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,IAAI;IACJ,OAAO;GACR;GACD,MAAM,SAAS,MAAM,cAAc,GAAG;GAGtC,MAAM,wBACJ;GACF,MAAM,QAAQ,OAAO,uBAAuB,IAAI;AAEhD,QAAK,MAAM,QAAQ,MAAM,IAAI,MAAM,WAAW,EAC5C,OAAM,IAAI,OACP,gDAAgD,sBAAsB;AAG3E,OAAI,MAAM,SAAS,EACjB,OAAM,IAAI,OACP,yDAAyD,sBAAsB;GAGpF,MAAM,uBAAuB,MAAM;AAEnC,QAAK,qBACH,OAAM,IAAI,MAAM;GAIlB,MAAM,OAAO,aAAa;GAG1B,IAAI,eAAe;AAGnB,OAAI,cAAc,oCAAoC;AACpD,YAAQ,KACN,mGACD;AACD,mBAAe;GAChB;GAED,MAAM,gBAAgB,KAAK,oBAAoB,aAAa;AAG5D,iBAAc,aACZ,sBACA,CAAC,OAAO,iBAAiB;AACvB,QAAI,OAAO;AACT,aAAQ,MACN,mDACA,MACD;AACD,YAAO,OACL,IAAI,OACD,4CAA4C,MAAM,WAAW,MAAM,GAEvE;IACF;AAED,eAAW,iBAAiB,SAC1B,QAAO,OACL,IAAI,MACF,qEAEH;AAGH,QAAI;KAEF,MAAM,OAAO,OAAO,WAAW,SAAS;AACxC,UAAK,OAAO,cAAc,OAAO;KAGjC,MAAM,oBAAoB,KAAK,OAAO,SAAS;AAE/C,aAAQ,kBAAkB;IAC3B,SAAQC,WAAgB;AACvB,aAAQ,MAAM,0CAA0C,UAAU;AAClE,YACE,IAAI,OACD,mCAAmC,UAAU,WAAW,UAAU,GAEtE;IACF;GACF,EACF;EACF,SAAQC,YAAiB;AACxB,WAAQ,MACN,mDACA,WACD;AACD,UACE,IAAI,OACD,4CAA4C,WAAW,WAAW,WAAW,GAEjF;EACF;CACF;AACF;;;;AAKD,eAAsB,uCACpBH,KACiB;AACjB,KAAI;AAEF,SAAO,MAAM,qBACX,KACA,uCACD;CACF,SAAQ,OAAO;AACd,UAAQ,KACN,yEACA,MACD;AAED,SAAO,MAAM,qBACX,KACA,0CACD;CACF;AACF"}
@@ -0,0 +1,95 @@
1
+ const require_chunk = require('./chunk-CUT6urMc.cjs');
2
+ const crypto = require_chunk.__toESM(require("crypto"));
3
+ const xml_c14n = require_chunk.__toESM(require("xml-c14n"));
4
+ const xpath_ts = require_chunk.__toESM(require("xpath-ts"));
5
+
6
+ //#region src/utils/signature/hashSignedProperties.ts
7
+ /**
8
+ * Selects the SignedProperties element, canonicalizes it using the best available
9
+ * canonicalization algorithm, hashes it using SHA-256, and returns the Base64 encoded digest.
10
+ *
11
+ * Corresponds to Step 7 in the MyInvois Signature Creation guide:
12
+ * https://sdk.myinvois.hasil.gov.my/signature-creation/#step-7-generate-signed-properties-hash
13
+ *
14
+ * Note: MyInvois documentation specifies C14N 1.1, but due to limited Node.js library support,
15
+ * this implementation uses Exclusive C14N which is widely supported and should be compatible
16
+ * in most cases. If signature validation fails, this may need to be updated.
17
+ *
18
+ * @param doc The XML Document object (from xmldom-ts) after SignedProperties population (Step 6).
19
+ * @param algorithm Optional canonicalization algorithm URI. Defaults to Exclusive C14N.
20
+ * @returns A Promise resolving to the Base64 encoded SHA-256 hash (PropsDigest).
21
+ * @throws {Error} If the SignedProperties element cannot be found or canonicalization/hashing fails.
22
+ */
23
+ function hashSignedProperties(doc, algorithm = "http://www.w3.org/2001/10/xml-exc-c14n#") {
24
+ return new Promise((resolve, reject) => {
25
+ try {
26
+ const ns = {
27
+ inv: "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2",
28
+ ext: "urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2",
29
+ sig: "urn:oasis:names:specification:ubl:schema:xsd:CommonSignatureComponents-2",
30
+ sac: "urn:oasis:names:specification:ubl:schema:xsd:SignatureAggregateComponents-2",
31
+ ds: "http://www.w3.org/2000/09/xmldsig#",
32
+ xades: "http://uri.etsi.org/01903/v1.3.2#"
33
+ };
34
+ const select = xpath_ts.useNamespaces(ns);
35
+ const signedPropertiesXPath = "/inv:Invoice/ext:UBLExtensions/ext:UBLExtension/ext:ExtensionContent/sig:UBLDocumentSignatures/sac:SignatureInformation/ds:Signature/ds:Object/xades:QualifyingProperties/xades:SignedProperties";
36
+ const nodes = select(signedPropertiesXPath, doc);
37
+ if (!Array.isArray(nodes) || nodes.length === 0) throw new Error(`SignedProperties element not found for XPath: ${signedPropertiesXPath}`);
38
+ if (nodes.length > 1) throw new Error(`Multiple SignedProperties elements found (expected 1): ${signedPropertiesXPath}`);
39
+ const signedPropertiesNode = nodes[0];
40
+ if (!signedPropertiesNode) throw new Error("Selected SignedProperties node is invalid or null.");
41
+ const c14n = (0, xml_c14n.default)();
42
+ let algorithmUri = algorithm;
43
+ if (algorithm === "https://www.w3.org/TR/xml-c14n11") {
44
+ console.warn("C14N 1.1 requested for SignedProperties but may not be supported, falling back to Exclusive C14N");
45
+ algorithmUri = "http://www.w3.org/2001/10/xml-exc-c14n#";
46
+ }
47
+ const canonicaliser = c14n.createCanonicaliser(algorithmUri);
48
+ canonicaliser.canonicalise(signedPropertiesNode, (error, canonicalXml) => {
49
+ if (error) {
50
+ console.error("Error during SignedProperties canonicalization:", error);
51
+ return reject(new Error(`SignedProperties canonicalization failed: ${error.message || error}`));
52
+ }
53
+ if (typeof canonicalXml !== "string") return reject(new Error("SignedProperties canonicalization did not return a string result."));
54
+ try {
55
+ const hash = crypto.createHash("sha256");
56
+ hash.update(canonicalXml, "utf8");
57
+ const base64PropsDigest = hash.digest("base64");
58
+ resolve(base64PropsDigest);
59
+ } catch (hashError) {
60
+ console.error("Error during SignedProperties hashing:", hashError);
61
+ reject(new Error(`SignedProperties hashing failed: ${hashError.message || hashError}`));
62
+ }
63
+ });
64
+ } catch (setupError) {
65
+ console.error("Error setting up or selecting SignedProperties:", setupError);
66
+ reject(new Error(`SignedProperties processing setup failed: ${setupError.message || setupError}`));
67
+ }
68
+ });
69
+ }
70
+ /**
71
+ * Attempts to use C14N 1.1 for SignedProperties if available, otherwise falls back to Exclusive C14N.
72
+ */
73
+ async function hashSignedPropertiesWithC14N11Fallback(doc) {
74
+ try {
75
+ return await hashSignedProperties(doc, "http://www.w3.org/2006/12/xml-c14n11");
76
+ } catch (error) {
77
+ console.warn("C14N 1.1 failed for SignedProperties, falling back to Exclusive C14N:", error);
78
+ return await hashSignedProperties(doc, "http://www.w3.org/2001/10/xml-exc-c14n#");
79
+ }
80
+ }
81
+
82
+ //#endregion
83
+ Object.defineProperty(exports, 'hashSignedProperties', {
84
+ enumerable: true,
85
+ get: function () {
86
+ return hashSignedProperties;
87
+ }
88
+ });
89
+ Object.defineProperty(exports, 'hashSignedPropertiesWithC14N11Fallback', {
90
+ enumerable: true,
91
+ get: function () {
92
+ return hashSignedPropertiesWithC14N11Fallback;
93
+ }
94
+ });
95
+ //# sourceMappingURL=hashSignedProperties-CU_ZqqmY.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hashSignedProperties-CU_ZqqmY.cjs","names":["doc: Document","algorithm: string","hashError: any","setupError: any"],"sources":["../src/utils/signature/hashSignedProperties.ts"],"sourcesContent":["import * as crypto from 'crypto'\nimport * as xpath from 'xpath-ts'\nimport c14nFactory from 'xml-c14n'\n\n/**\n * Selects the SignedProperties element, canonicalizes it using the best available\n * canonicalization algorithm, hashes it using SHA-256, and returns the Base64 encoded digest.\n *\n * Corresponds to Step 7 in the MyInvois Signature Creation guide:\n * https://sdk.myinvois.hasil.gov.my/signature-creation/#step-7-generate-signed-properties-hash\n *\n * Note: MyInvois documentation specifies C14N 1.1, but due to limited Node.js library support,\n * this implementation uses Exclusive C14N which is widely supported and should be compatible\n * in most cases. If signature validation fails, this may need to be updated.\n *\n * @param doc The XML Document object (from xmldom-ts) after SignedProperties population (Step 6).\n * @param algorithm Optional canonicalization algorithm URI. Defaults to Exclusive C14N.\n * @returns A Promise resolving to the Base64 encoded SHA-256 hash (PropsDigest).\n * @throws {Error} If the SignedProperties element cannot be found or canonicalization/hashing fails.\n */\nexport function hashSignedProperties(\n doc: Document,\n algorithm: string = 'http://www.w3.org/2001/10/xml-exc-c14n#',\n): Promise<string> {\n return new Promise((resolve, reject) => {\n try {\n // Define namespaces, including the default namespace for Invoice\n const ns = {\n inv: 'urn:oasis:names:specification:ubl:schema:xsd:Invoice-2',\n ext: 'urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2',\n sig: 'urn:oasis:names:specification:ubl:schema:xsd:CommonSignatureComponents-2',\n sac: 'urn:oasis:names:specification:ubl:schema:xsd:SignatureAggregateComponents-2',\n ds: 'http://www.w3.org/2000/09/xmldsig#',\n xades: 'http://uri.etsi.org/01903/v1.3.2#',\n }\n const select = xpath.useNamespaces(ns)\n\n // 1. Get the SignedProperties element using XPath\n const signedPropertiesXPath =\n '/inv:Invoice/ext:UBLExtensions/ext:UBLExtension/ext:ExtensionContent/sig:UBLDocumentSignatures/sac:SignatureInformation/ds:Signature/ds:Object/xades:QualifyingProperties/xades:SignedProperties'\n const nodes = select(signedPropertiesXPath, doc)\n\n if (!Array.isArray(nodes) || nodes.length === 0) {\n throw new Error(\n `SignedProperties element not found for XPath: ${signedPropertiesXPath}`,\n )\n }\n if (nodes.length > 1) {\n throw new Error(\n `Multiple SignedProperties elements found (expected 1): ${signedPropertiesXPath}`,\n )\n }\n const signedPropertiesNode = nodes[0] as Node\n\n if (!signedPropertiesNode) {\n throw new Error('Selected SignedProperties node is invalid or null.')\n }\n\n // 2. Canonicalize the SignedProperties node\n const c14n = c14nFactory()\n\n // Try C14N 1.1 first, fallback to Exclusive C14N\n let algorithmUri = algorithm\n\n // If C14N 1.1 is requested but not available, use Exclusive C14N\n if (algorithm === 'https://www.w3.org/TR/xml-c14n11') {\n console.warn(\n 'C14N 1.1 requested for SignedProperties but may not be supported, falling back to Exclusive C14N',\n )\n algorithmUri = 'http://www.w3.org/2001/10/xml-exc-c14n#'\n }\n\n const canonicaliser = c14n.createCanonicaliser(algorithmUri)\n\n // Canonicalize the SignedProperties node using the callback pattern\n canonicaliser.canonicalise(\n signedPropertiesNode,\n (error, canonicalXml) => {\n if (error) {\n console.error(\n 'Error during SignedProperties canonicalization:',\n error,\n )\n return reject(\n new Error(\n `SignedProperties canonicalization failed: ${error.message || error}`,\n ),\n )\n }\n\n if (typeof canonicalXml !== 'string') {\n return reject(\n new Error(\n 'SignedProperties canonicalization did not return a string result.',\n ),\n )\n }\n\n try {\n // 3. Hash the canonicalized property tag using SHA-256\n const hash = crypto.createHash('sha256')\n hash.update(canonicalXml, 'utf8')\n\n // 4. Encode the hashed property tag using Base64 Encoder\n const base64PropsDigest = hash.digest('base64')\n\n resolve(base64PropsDigest)\n } catch (hashError: any) {\n console.error('Error during SignedProperties hashing:', hashError)\n reject(\n new Error(\n `SignedProperties hashing failed: ${hashError.message || hashError}`,\n ),\n )\n }\n },\n )\n } catch (setupError: any) {\n console.error(\n 'Error setting up or selecting SignedProperties:',\n setupError,\n )\n reject(\n new Error(\n `SignedProperties processing setup failed: ${setupError.message || setupError}`,\n ),\n )\n }\n })\n}\n\n/**\n * Attempts to use C14N 1.1 for SignedProperties if available, otherwise falls back to Exclusive C14N.\n */\nexport async function hashSignedPropertiesWithC14N11Fallback(\n doc: Document,\n): Promise<string> {\n try {\n // Try C14N 1.1 first (may not be supported by xml-c14n library)\n return await hashSignedProperties(\n doc,\n 'http://www.w3.org/2006/12/xml-c14n11',\n )\n } catch (error) {\n console.warn(\n 'C14N 1.1 failed for SignedProperties, falling back to Exclusive C14N:',\n error,\n )\n // Fallback to Exclusive C14N\n return await hashSignedProperties(\n doc,\n 'http://www.w3.org/2001/10/xml-exc-c14n#',\n )\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,qBACdA,KACAC,YAAoB,2CACH;AACjB,QAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,MAAI;GAEF,MAAM,KAAK;IACT,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,IAAI;IACJ,OAAO;GACR;GACD,MAAM,SAAS,SAAM,cAAc,GAAG;GAGtC,MAAM,wBACJ;GACF,MAAM,QAAQ,OAAO,uBAAuB,IAAI;AAEhD,QAAK,MAAM,QAAQ,MAAM,IAAI,MAAM,WAAW,EAC5C,OAAM,IAAI,OACP,gDAAgD,sBAAsB;AAG3E,OAAI,MAAM,SAAS,EACjB,OAAM,IAAI,OACP,yDAAyD,sBAAsB;GAGpF,MAAM,uBAAuB,MAAM;AAEnC,QAAK,qBACH,OAAM,IAAI,MAAM;GAIlB,MAAM,OAAO,uBAAa;GAG1B,IAAI,eAAe;AAGnB,OAAI,cAAc,oCAAoC;AACpD,YAAQ,KACN,mGACD;AACD,mBAAe;GAChB;GAED,MAAM,gBAAgB,KAAK,oBAAoB,aAAa;AAG5D,iBAAc,aACZ,sBACA,CAAC,OAAO,iBAAiB;AACvB,QAAI,OAAO;AACT,aAAQ,MACN,mDACA,MACD;AACD,YAAO,OACL,IAAI,OACD,4CAA4C,MAAM,WAAW,MAAM,GAEvE;IACF;AAED,eAAW,iBAAiB,SAC1B,QAAO,OACL,IAAI,MACF,qEAEH;AAGH,QAAI;KAEF,MAAM,OAAO,OAAO,WAAW,SAAS;AACxC,UAAK,OAAO,cAAc,OAAO;KAGjC,MAAM,oBAAoB,KAAK,OAAO,SAAS;AAE/C,aAAQ,kBAAkB;IAC3B,SAAQC,WAAgB;AACvB,aAAQ,MAAM,0CAA0C,UAAU;AAClE,YACE,IAAI,OACD,mCAAmC,UAAU,WAAW,UAAU,GAEtE;IACF;GACF,EACF;EACF,SAAQC,YAAiB;AACxB,WAAQ,MACN,mDACA,WACD;AACD,UACE,IAAI,OACD,4CAA4C,WAAW,WAAW,WAAW,GAEjF;EACF;CACF;AACF;;;;AAKD,eAAsB,uCACpBH,KACiB;AACjB,KAAI;AAEF,SAAO,MAAM,qBACX,KACA,uCACD;CACF,SAAQ,OAAO;AACd,UAAQ,KACN,yEACA,MACD;AAED,SAAO,MAAM,qBACX,KACA,0CACD;CACF;AACF"}
@@ -0,0 +1,16 @@
1
+ //#region src/types/index.d.ts
2
+
3
+ interface TokenResponse {
4
+ access_token: string;
5
+ expires_in: number;
6
+ }
7
+ interface ClientCredentials {
8
+ clientId: string;
9
+ clientSecret: string;
10
+ baseUrl: string;
11
+ onBehalfOf?: string;
12
+ debug?: boolean;
13
+ }
14
+ //#endregion
15
+ export { ClientCredentials, TokenResponse };
16
+ //# sourceMappingURL=index-B1DSs-wd.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-B1DSs-wd.d.cts","names":["TokenResponse","ClientCredentials"],"sources":["../src/types/index.d.ts"],"sourcesContent":["export type * from './documents/index.d.ts'\nexport type * from './country-code.d.ts'\nexport type * from './classification-codes.d.ts'\nexport type * from './payment-modes.d.ts'\nexport type * from './tax-types.d.ts'\nexport type * from './unit-types.d.ts'\nexport type * from './signatures.d.ts'\nexport type * from './currencies.d.ts'\nexport type * from './state-codes.d.ts'\nexport type * from './e-invoice.d.ts'\nexport type * from './msic-codes.d.ts'\n\nexport interface TokenResponse {\n access_token: string\n expires_in: number\n}\n\nexport interface ClientCredentials {\n clientId: string\n clientSecret: string\n baseUrl: string\n onBehalfOf?: string\n debug?: boolean\n}\n"],"mappings":";;UAYiBA,aAAAA;;;;UAKAC,iBAAAA"}
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,16 @@
1
+ //#region src/types/index.d.ts
2
+
3
+ interface TokenResponse {
4
+ access_token: string;
5
+ expires_in: number;
6
+ }
7
+ interface ClientCredentials {
8
+ clientId: string;
9
+ clientSecret: string;
10
+ baseUrl: string;
11
+ onBehalfOf?: string;
12
+ debug?: boolean;
13
+ }
14
+ //#endregion
15
+ export { ClientCredentials, TokenResponse };
16
+ //# sourceMappingURL=index-FTgB2nM6.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-FTgB2nM6.d.ts","names":["TokenResponse","ClientCredentials"],"sources":["../src/types/index.d.ts"],"sourcesContent":["export type * from './documents/index.d.ts'\nexport type * from './country-code.d.ts'\nexport type * from './classification-codes.d.ts'\nexport type * from './payment-modes.d.ts'\nexport type * from './tax-types.d.ts'\nexport type * from './unit-types.d.ts'\nexport type * from './signatures.d.ts'\nexport type * from './currencies.d.ts'\nexport type * from './state-codes.d.ts'\nexport type * from './e-invoice.d.ts'\nexport type * from './msic-codes.d.ts'\n\nexport interface TokenResponse {\n access_token: string\n expires_in: number\n}\n\nexport interface ClientCredentials {\n clientId: string\n clientSecret: string\n baseUrl: string\n onBehalfOf?: string\n debug?: boolean\n}\n"],"mappings":";;UAYiBA,aAAAA;;;;UAKAC,iBAAAA"}
@@ -0,0 +1 @@
1
+ export { };
package/dist/index.cjs CHANGED
@@ -1,97 +1,13 @@
1
- "use strict";
2
-
3
- //#region src/utils/getBaseUrl.ts
4
- const getBaseUrl = (environment) => {
5
- return environment === "sandbox" ? "https://preprod-api.myinvois.hasil.gov.my" : "https://api.myinvois.hasil.gov.my";
6
- };
7
-
8
- //#endregion
9
- //#region src/api/platform/taxpayerLogin.ts
10
- const taxpayerLogin = async (client) => {
11
- const { clientId, clientSecret, baseUrl, debug } = client;
12
- try {
13
- const response = await fetch(`${baseUrl}/connect/token`, {
14
- method: "POST",
15
- headers: { "Content-Type": "application/x-www-form-urlencoded" },
16
- body: new URLSearchParams({
17
- grant_type: "client_credentials",
18
- client_id: clientId,
19
- client_secret: clientSecret,
20
- scope: "InvoicingAPI"
21
- })
22
- });
23
- const tokenResponse = await response.json();
24
- return {
25
- token: tokenResponse.access_token,
26
- tokenExpiration: new Date(Date.now() + tokenResponse.expires_in * 1e3)
27
- };
28
- } catch (error) {
29
- if (debug) console.error(error);
30
- throw error;
31
- }
32
- };
33
-
34
- //#endregion
35
- //#region src/utils/MyInvoisClient.ts
36
- var MyInvoisClient = class {
37
- baseUrl;
38
- clientId;
39
- clientSecret;
40
- debug;
41
- token = "";
42
- tokenExpiration;
43
- constructor(clientId, clientSecret, environment, debug = false) {
44
- this.clientId = clientId;
45
- this.clientSecret = clientSecret;
46
- this.baseUrl = getBaseUrl(environment);
47
- this.debug = debug;
48
- }
49
- async refreshToken() {
50
- const tokenResponse = await taxpayerLogin({
51
- clientId: this.clientId,
52
- clientSecret: this.clientSecret,
53
- baseUrl: this.baseUrl,
54
- debug: this.debug
55
- });
56
- this.token = tokenResponse.token;
57
- this.tokenExpiration = tokenResponse.tokenExpiration;
58
- }
59
- async getToken() {
60
- if (!this.tokenExpiration || this.tokenExpiration < new Date()) {
61
- if (this.debug) console.log("Refreshing token");
62
- await this.refreshToken();
63
- }
64
- return this.token;
65
- }
66
- async fetch(path, options = {}) {
67
- const token = await this.getToken();
68
- return fetch(`${this.baseUrl}${path}`, {
69
- ...options,
70
- headers: {
71
- ...options.headers,
72
- Authorization: `Bearer ${token}`
73
- }
74
- });
75
- }
76
- /**
77
- * Validates a TIN against a NRIC
78
- *
79
- * @param tin
80
- * @param nric
81
- * @returns true if the TIN is valid, false otherwise
82
- */
83
- async verifyTin(tin, nric) {
84
- try {
85
- const response = await this.fetch(`/api/v1.0/taxpayer/validate/${tin}?idType=NRIC&idValue=${nric}`, { method: "GET" });
86
- if (response.status === 200) return true;
87
- return false;
88
- } catch (error) {
89
- if (this.debug) console.error(error);
90
- return false;
91
- }
92
- }
93
- };
94
-
95
- //#endregion
96
- exports.MyInvoisClient = MyInvoisClient
97
- //# sourceMappingURL=index.cjs.map
1
+ require('./platformLogin-PGzMhw1X.cjs');
2
+ require('./getBaseUrl-CO7Jp27d.cjs');
3
+ require('./canonicalize-C_fNNpYr.cjs');
4
+ require('./hashCert-mlYEuYex.cjs');
5
+ require('./hashSignedProperties-CU_ZqqmY.cjs');
6
+ require('./populateFinalDocument-BdyYzz5Y.cjs');
7
+ require('./populateSignedProperties-BJMcBQ6S.cjs');
8
+ require('./sign-B61Cy3gO.cjs');
9
+ require('./transform-BLz0S687.cjs');
10
+ require('./invoice1-1-8S-QQn7P.cjs');
11
+ const require_MyInvoisClient = require('./MyInvoisClient-DO1dJfQq.cjs');
12
+
13
+ exports.MyInvoisClient = require_MyInvoisClient.MyInvoisClient;