@ripwords/myinvois-client 0.3.7 → 0.4.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 (395) hide show
  1. package/README.md +27 -0
  2. package/dist/{apiQueue-DgKWaQDS.cjs → apiQueue-C45w-ymm.cjs} +1 -1
  3. package/dist/{apiQueue-DgKWaQDS.cjs.map → apiQueue-C45w-ymm.cjs.map} +1 -1
  4. package/dist/{certificate-CWmfCPdt.cjs → certificate-Dw46fkYv.cjs} +5 -31
  5. package/dist/certificate-Dw46fkYv.cjs.map +1 -0
  6. package/dist/{document-B6ab06s1.cjs → document-B11B5lqd.cjs} +75 -21
  7. package/dist/document-B11B5lqd.cjs.map +1 -0
  8. package/dist/{documentManagement-BviJDtf2.cjs → documentManagement-qJnd0l1z.cjs} +3 -2
  9. package/dist/documentManagement-qJnd0l1z.cjs.map +1 -0
  10. package/dist/{documentSubmission-C-v4_4-x.cjs → documentSubmission-BaPECvYU.cjs} +5 -5
  11. package/dist/{documentSubmission-C-v4_4-x.cjs.map → documentSubmission-BaPECvYU.cjs.map} +1 -1
  12. package/dist/{documentTypeManagement-D_-LiQVg.cjs → documentTypeManagement-DXRLfTsW.cjs} +1 -1
  13. package/dist/{documentTypeManagement-D_-LiQVg.cjs.map → documentTypeManagement-DXRLfTsW.cjs.map} +1 -1
  14. package/dist/{getBaseUrl-D0G4GZmp.cjs → getBaseUrl-D2iJdUGL.cjs} +1 -1
  15. package/dist/{getBaseUrl-D0G4GZmp.cjs.map → getBaseUrl-D2iJdUGL.cjs.map} +1 -1
  16. package/dist/index.cjs +14 -12
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index10.cjs +4 -2
  19. package/dist/index11.cjs +1 -1
  20. package/dist/index13.cjs +1 -1
  21. package/dist/index14.cjs +2 -329
  22. package/dist/index15.cjs +308 -172
  23. package/dist/index15.cjs.map +1 -1
  24. package/dist/index16.cjs +187 -56
  25. package/dist/index16.cjs.map +1 -1
  26. package/dist/index17.cjs +53 -523
  27. package/dist/index17.cjs.map +1 -1
  28. package/dist/index18.cjs +523 -187
  29. package/dist/index18.cjs.map +1 -1
  30. package/dist/index19.cjs +196 -0
  31. package/dist/index19.cjs.map +1 -0
  32. package/dist/index2.cjs +1 -1
  33. package/dist/index20.cjs +0 -25
  34. package/dist/index21.cjs +25 -0
  35. package/dist/{index20.cjs.map → index21.cjs.map} +1 -1
  36. package/dist/index23.cjs +0 -29
  37. package/dist/index24.cjs +24 -20
  38. package/dist/index24.cjs.map +1 -1
  39. package/dist/index25.cjs +25 -0
  40. package/dist/index25.cjs.map +1 -0
  41. package/dist/index26.cjs +0 -34
  42. package/dist/index27.cjs +25 -15
  43. package/dist/index27.cjs.map +1 -1
  44. package/dist/index28.cjs +24 -0
  45. package/dist/index28.cjs.map +1 -0
  46. package/dist/index3.cjs +2 -2
  47. package/dist/index31.cjs +0 -208
  48. package/dist/index32.cjs +203 -104
  49. package/dist/index32.cjs.map +1 -1
  50. package/dist/index33.cjs +104 -132
  51. package/dist/index33.cjs.map +1 -1
  52. package/dist/index34.cjs +132 -59
  53. package/dist/index34.cjs.map +1 -1
  54. package/dist/index35.cjs +59 -262
  55. package/dist/index35.cjs.map +1 -1
  56. package/dist/index36.cjs +262 -74
  57. package/dist/index36.cjs.map +1 -1
  58. package/dist/index37.cjs +74 -102
  59. package/dist/index37.cjs.map +1 -1
  60. package/dist/index38.cjs +102 -68
  61. package/dist/index38.cjs.map +1 -1
  62. package/dist/index39.cjs +68 -107
  63. package/dist/index39.cjs.map +1 -1
  64. package/dist/index4.cjs +1 -1
  65. package/dist/index40.cjs +107 -95
  66. package/dist/index40.cjs.map +1 -1
  67. package/dist/index41.cjs +95 -13
  68. package/dist/index41.cjs.map +1 -1
  69. package/dist/index42.cjs +11 -31
  70. package/dist/index42.cjs.map +1 -1
  71. package/dist/index43.cjs +31 -12
  72. package/dist/index43.cjs.map +1 -1
  73. package/dist/index44.cjs +12 -22
  74. package/dist/index44.cjs.map +1 -1
  75. package/dist/index45.cjs +22 -13
  76. package/dist/index45.cjs.map +1 -1
  77. package/dist/index46.cjs +13 -7
  78. package/dist/index46.cjs.map +1 -1
  79. package/dist/index47.cjs +7 -7
  80. package/dist/index47.cjs.map +1 -1
  81. package/dist/index48.cjs +7 -10
  82. package/dist/index48.cjs.map +1 -1
  83. package/dist/index49.cjs +10 -6
  84. package/dist/index49.cjs.map +1 -1
  85. package/dist/index5.cjs +1 -1
  86. package/dist/index50.cjs +6 -101
  87. package/dist/index50.cjs.map +1 -1
  88. package/dist/index51.cjs +101 -106
  89. package/dist/index51.cjs.map +1 -1
  90. package/dist/index52.cjs +106 -119
  91. package/dist/index52.cjs.map +1 -1
  92. package/dist/index53.cjs +119 -106
  93. package/dist/index53.cjs.map +1 -1
  94. package/dist/index54.cjs +106 -98
  95. package/dist/index54.cjs.map +1 -1
  96. package/dist/index55.cjs +98 -118
  97. package/dist/index55.cjs.map +1 -1
  98. package/dist/index56.cjs +118 -127
  99. package/dist/index56.cjs.map +1 -1
  100. package/dist/index57.cjs +127 -117
  101. package/dist/index57.cjs.map +1 -1
  102. package/dist/index58.cjs +117 -14
  103. package/dist/index58.cjs.map +1 -1
  104. package/dist/index59.cjs +14 -95
  105. package/dist/index59.cjs.map +1 -1
  106. package/dist/index6.cjs +1 -1
  107. package/dist/index60.cjs +95 -142
  108. package/dist/index60.cjs.map +1 -1
  109. package/dist/index61.cjs +142 -114
  110. package/dist/index61.cjs.map +1 -1
  111. package/dist/index62.cjs +114 -144
  112. package/dist/index62.cjs.map +1 -1
  113. package/dist/index63.cjs +144 -113
  114. package/dist/index63.cjs.map +1 -1
  115. package/dist/index64.cjs +113 -17
  116. package/dist/index64.cjs.map +1 -1
  117. package/dist/index65.cjs +17 -112
  118. package/dist/index65.cjs.map +1 -1
  119. package/dist/index66.cjs +112 -47
  120. package/dist/index66.cjs.map +1 -1
  121. package/dist/index67.cjs +47 -14
  122. package/dist/index67.cjs.map +1 -1
  123. package/dist/index68.cjs +14 -28
  124. package/dist/index68.cjs.map +1 -1
  125. package/dist/index69.cjs +28 -22
  126. package/dist/index69.cjs.map +1 -1
  127. package/dist/index7.cjs +1 -1
  128. package/dist/index70.cjs +22 -9
  129. package/dist/index70.cjs.map +1 -1
  130. package/dist/index71.cjs +9 -8
  131. package/dist/index71.cjs.map +1 -1
  132. package/dist/index72.cjs +8 -17
  133. package/dist/index72.cjs.map +1 -1
  134. package/dist/index73.cjs +17 -412
  135. package/dist/index73.cjs.map +1 -1
  136. package/dist/index74.cjs +412 -8
  137. package/dist/index74.cjs.map +1 -1
  138. package/dist/index75.cjs +8 -9
  139. package/dist/index75.cjs.map +1 -1
  140. package/dist/index76.cjs +16 -0
  141. package/dist/index76.cjs.map +1 -0
  142. package/dist/index8.cjs +1 -1
  143. package/dist/lineItems-C8iT0OL1.cjs +64 -0
  144. package/dist/lineItems-C8iT0OL1.cjs.map +1 -0
  145. package/dist/{notificationManagement-DLBDn77E.cjs → notificationManagement-C_qrFwWL.cjs} +1 -1
  146. package/dist/{notificationManagement-DLBDn77E.cjs.map → notificationManagement-C_qrFwWL.cjs.map} +1 -1
  147. package/dist/{platformLogin-Ch6hFKoU.cjs → platformLogin-DC4s6Qpv.cjs} +1 -1
  148. package/dist/{platformLogin-Ch6hFKoU.cjs.map → platformLogin-DC4s6Qpv.cjs.map} +1 -1
  149. package/dist/{taxpayerValidation-j8s6YGED.cjs → taxpayerValidation-DzCJROgP.cjs} +1 -1
  150. package/dist/{taxpayerValidation-j8s6YGED.cjs.map → taxpayerValidation-DzCJROgP.cjs.map} +1 -1
  151. package/package.json +1 -1
  152. package/dist/0X-Cr3M7hci.d.cts +0 -211
  153. package/dist/0X-qj3c_vAo.d.ts +0 -210
  154. package/dist/1X-B-lyAVC4.d.ts +0 -111
  155. package/dist/1X-C72Wa4pk.d.ts +0 -19
  156. package/dist/1X-CWwmfCzo.d.cts +0 -112
  157. package/dist/1X-DYw2tURz.d.cts +0 -20
  158. package/dist/2X-BfCK614i.d.ts +0 -139
  159. package/dist/2X-CH89y3Af.d.ts +0 -39
  160. package/dist/2X-CXtqiwRg.d.cts +0 -40
  161. package/dist/2X-DNtkJ0tj.d.cts +0 -140
  162. package/dist/3X-BOxfatu3.d.cts +0 -62
  163. package/dist/3X-Bk_fUIAk.d.cts +0 -21
  164. package/dist/3X-DryrwYRf.d.ts +0 -20
  165. package/dist/3X-Du10Ix_V.d.ts +0 -61
  166. package/dist/4X-BPMLRoDv.d.ts +0 -30
  167. package/dist/4X-C7fzDWJ_.d.cts +0 -265
  168. package/dist/4X-CK9rj5qd.d.cts +0 -31
  169. package/dist/4X-x3cRFuSM.d.ts +0 -264
  170. package/dist/5X-B52AKeTz.d.ts +0 -76
  171. package/dist/5X-Bv7M6KyG.d.ts +0 -21
  172. package/dist/5X-CNAFsDm2.d.cts +0 -77
  173. package/dist/5X-CpAvNxvd.d.cts +0 -22
  174. package/dist/6X-DBwpWPQ6.d.ts +0 -104
  175. package/dist/6X-ZeZ8OB57.d.ts +0 -15
  176. package/dist/6X-bXWr_7xY.d.cts +0 -16
  177. package/dist/6X-uObUP4VG.d.cts +0 -105
  178. package/dist/7X-BJBOlWhV.d.cts +0 -16
  179. package/dist/7X-BifJnY24.d.cts +0 -71
  180. package/dist/7X-C_XGDSpE.d.ts +0 -70
  181. package/dist/7X-Dvw2Z2VN.d.ts +0 -15
  182. package/dist/8X-BkgoX8dg.d.ts +0 -18
  183. package/dist/8X-Di_0wuRX.d.ts +0 -109
  184. package/dist/8X-DioBXCJ0.d.cts +0 -110
  185. package/dist/8X-dshwiOxU.d.cts +0 -19
  186. package/dist/9X-8ZnvvViY.d.ts +0 -97
  187. package/dist/9X-9j2Djy4W.d.cts +0 -15
  188. package/dist/9X-BjffnXuq.d.cts +0 -98
  189. package/dist/9X-Du0e44cq.d.ts +0 -14
  190. package/dist/AX-BSPLpkVT.d.ts +0 -110
  191. package/dist/AX-CWCopjCC.d.cts +0 -111
  192. package/dist/BX-Cq7WdhD3.d.cts +0 -115
  193. package/dist/BX-u4yMaIkz.d.ts +0 -114
  194. package/dist/CX-BKZG0pVE.d.ts +0 -127
  195. package/dist/CX-DlcVZfxx.d.cts +0 -128
  196. package/dist/DX-CwA9WJAf.d.ts +0 -114
  197. package/dist/DX-DLdv-Nxj.d.cts +0 -115
  198. package/dist/EX-BRNu1Ooi.d.ts +0 -106
  199. package/dist/EX-CIJv8-Lw.d.cts +0 -107
  200. package/dist/FX-DBxjq6xY.d.ts +0 -126
  201. package/dist/FX-DlDM_Zea.d.cts +0 -127
  202. package/dist/GX-B3CvWNrP.d.ts +0 -135
  203. package/dist/GX-BFGNX6Jy.d.cts +0 -136
  204. package/dist/HX-D7FABgTv.d.ts +0 -125
  205. package/dist/HX-D7Y9qRSm.d.cts +0 -126
  206. package/dist/IX-D3ZknsAB.d.ts +0 -22
  207. package/dist/IX-DPTrbhgX.d.cts +0 -23
  208. package/dist/JX-BRaZM3Gc.d.ts +0 -103
  209. package/dist/JX-D8JmtNpo.d.cts +0 -104
  210. package/dist/KX-B1K0OWoi.d.ts +0 -150
  211. package/dist/KX-B46KJZrH.d.cts +0 -151
  212. package/dist/LX-CKRefinL.d.ts +0 -122
  213. package/dist/LX-CfTKy8Sx.d.cts +0 -123
  214. package/dist/MX-BKJ4gNvV.d.cts +0 -153
  215. package/dist/MX-DKmaeO9r.d.ts +0 -152
  216. package/dist/NX-CJL2Gn1U.d.ts +0 -121
  217. package/dist/NX-CSdLIFqU.d.cts +0 -122
  218. package/dist/OX-BwqOsulT.d.cts +0 -26
  219. package/dist/OX-Do2ap5v_.d.ts +0 -25
  220. package/dist/PX-BTx0TXsJ.d.cts +0 -121
  221. package/dist/PX-_DOr_rm9.d.ts +0 -120
  222. package/dist/QX-BUXR8RJL.d.cts +0 -59
  223. package/dist/QX-HlXLkIki.d.ts +0 -58
  224. package/dist/RX-CZ8HiH37.d.cts +0 -23
  225. package/dist/RX-DVPGOVES.d.ts +0 -22
  226. package/dist/SX-CLxsqiQk.d.cts +0 -40
  227. package/dist/SX-OGT3qwlS.d.ts +0 -39
  228. package/dist/TX-DKc8hLc4.d.cts +0 -31
  229. package/dist/TX-cPDINmZ5.d.ts +0 -30
  230. package/dist/UX-Be3sqvPV.d.ts +0 -17
  231. package/dist/UX-bc7xDnZI.d.cts +0 -18
  232. package/dist/VX-CIHTFyoC.d.cts +0 -17
  233. package/dist/VX-CoEuBNDK.d.ts +0 -16
  234. package/dist/WX-BHvlq7Jx.d.cts +0 -26
  235. package/dist/WX-DMvw__jH.d.ts +0 -25
  236. package/dist/XX-DOA-10JW.d.ts +0 -827
  237. package/dist/XX-DztQxYHJ.d.cts +0 -828
  238. package/dist/YX-CkxLeFb4.d.cts +0 -20
  239. package/dist/YX-F34sJ7Ik.d.ts +0 -19
  240. package/dist/ZX-CDQOfsHh.d.ts +0 -21
  241. package/dist/ZX-DVb_buNI.d.cts +0 -22
  242. package/dist/api/documentManagement.d.ts +0 -89
  243. package/dist/api/documentManagement.js +0 -3
  244. package/dist/api/documentSubmission.d.ts +0 -92
  245. package/dist/api/documentSubmission.js +0 -5
  246. package/dist/api/documentTypeManagement.d.ts +0 -70
  247. package/dist/api/documentTypeManagement.js +0 -3
  248. package/dist/api/notificationManagement.d.ts +0 -68
  249. package/dist/api/notificationManagement.js +0 -3
  250. package/dist/api/platformLogin.d.ts +0 -68
  251. package/dist/api/platformLogin.js +0 -3
  252. package/dist/api/taxpayerValidation.d.ts +0 -71
  253. package/dist/api/taxpayerValidation.js +0 -4
  254. package/dist/apiQueue-B6Q644Bz.js +0 -201
  255. package/dist/certificate-COwqszxD.js +0 -71
  256. package/dist/certificate-CWmfCPdt.cjs.map +0 -1
  257. package/dist/chunk-CUT6urMc.cjs +0 -30
  258. package/dist/classification-codes-B15PbWxz.d.cts +0 -118
  259. package/dist/classification-codes-C2X4xW5-.d.ts +0 -117
  260. package/dist/country-code-DPeNFMMi.d.cts +0 -543
  261. package/dist/country-code-DsI8Mbzx.d.ts +0 -542
  262. package/dist/currencies-DKuDflOO.d.ts +0 -207
  263. package/dist/currencies-S5g1gzBU.d.cts +0 -208
  264. package/dist/document-B6ab06s1.cjs.map +0 -1
  265. package/dist/document-Bb5WkhRe.js +0 -626
  266. package/dist/documentManagement-BviJDtf2.cjs.map +0 -1
  267. package/dist/documentManagement-lPm8Gziu.js +0 -49
  268. package/dist/documentSubmission-igf605QK.js +0 -135
  269. package/dist/documentTypeManagement-cBtVCOY3.js +0 -22
  270. package/dist/documents-BYV12TVt.d.ts +0 -1196
  271. package/dist/documents-D_V38Q_U.d.cts +0 -1197
  272. package/dist/e-invoice-BuwtFnlI.d.cts +0 -44
  273. package/dist/e-invoice-C2TxhyrK.d.ts +0 -43
  274. package/dist/formatIdValue-qTxJqj9o.js +0 -7
  275. package/dist/getBaseUrl-D7nUmoYb.js +0 -7
  276. package/dist/index-CygwSf0x.d.ts +0 -15
  277. package/dist/index-Yr1QAbIF.d.cts +0 -16
  278. package/dist/index.d.ts +0 -614
  279. package/dist/index.js +0 -627
  280. package/dist/index14.cjs.map +0 -1
  281. package/dist/index23.cjs.map +0 -1
  282. package/dist/index26.cjs.map +0 -1
  283. package/dist/index31.cjs.map +0 -1
  284. package/dist/index61.cts.map +0 -1
  285. package/dist/index62.cts.map +0 -1
  286. package/dist/index63.cts.map +0 -1
  287. package/dist/index64.cts.map +0 -1
  288. package/dist/index65.cts.map +0 -1
  289. package/dist/index66.cts.map +0 -1
  290. package/dist/index67.cts.map +0 -1
  291. package/dist/index68.cts.map +0 -1
  292. package/dist/index69.cts.map +0 -1
  293. package/dist/index70.cts.map +0 -1
  294. package/dist/index71.cts.map +0 -1
  295. package/dist/index72.cts.map +0 -1
  296. package/dist/index73.cts.map +0 -1
  297. package/dist/index74.cts.map +0 -1
  298. package/dist/index75.cts.map +0 -1
  299. package/dist/msic-codes-CIKdPqag.d.cts +0 -26
  300. package/dist/msic-codes-CjrrJmzb.d.ts +0 -25
  301. package/dist/notificationManagement-n4Z5e-My.js +0 -19
  302. package/dist/notifications-DdlEkprb.d.cts +0 -63
  303. package/dist/notifications-sFhgh3rJ.d.ts +0 -62
  304. package/dist/payment-modes-7c1lWlIr.d.cts +0 -44
  305. package/dist/payment-modes-g3DzLmWb.d.ts +0 -43
  306. package/dist/platformLogin-CqI9OLYP.js +0 -39
  307. package/dist/signatures-CerHUrj3.d.ts +0 -172
  308. package/dist/signatures-CyDSZr_e.d.cts +0 -173
  309. package/dist/state-codes-Ow4oehYT.d.ts +0 -61
  310. package/dist/state-codes-u3ppueWo.d.cts +0 -62
  311. package/dist/tax-types-ClyLgydM.d.ts +0 -41
  312. package/dist/tax-types-fu5Q6dic.d.cts +0 -42
  313. package/dist/taxpayer-BAoT73gg.d.ts +0 -35
  314. package/dist/taxpayer-DwGzY1IL.d.cts +0 -36
  315. package/dist/taxpayerValidation-Xd_EHDvk.js +0 -47
  316. package/dist/types/classification-codes.d.ts +0 -2
  317. package/dist/types/country-code.d.ts +0 -2
  318. package/dist/types/currencies.d.ts +0 -2
  319. package/dist/types/documents.d.ts +0 -55
  320. package/dist/types/e-invoice.d.ts +0 -2
  321. package/dist/types/index.d.ts +0 -61
  322. package/dist/types/msic/0X.d.ts +0 -2
  323. package/dist/types/msic/1X.d.ts +0 -2
  324. package/dist/types/msic/2X.d.ts +0 -2
  325. package/dist/types/msic/3X.d.ts +0 -2
  326. package/dist/types/msic/4X.d.ts +0 -2
  327. package/dist/types/msic/5X.d.ts +0 -2
  328. package/dist/types/msic/6X.d.ts +0 -2
  329. package/dist/types/msic/7X.d.ts +0 -2
  330. package/dist/types/msic/8X.d.ts +0 -2
  331. package/dist/types/msic/9X.d.ts +0 -2
  332. package/dist/types/msic-codes.d.ts +0 -12
  333. package/dist/types/notifications.d.ts +0 -2
  334. package/dist/types/payment-modes.d.ts +0 -2
  335. package/dist/types/signatures.d.ts +0 -2
  336. package/dist/types/state-codes.d.ts +0 -2
  337. package/dist/types/tax-types.d.ts +0 -2
  338. package/dist/types/taxpayer.d.ts +0 -56
  339. package/dist/types/unit/1X.d.ts +0 -2
  340. package/dist/types/unit/2X.d.ts +0 -2
  341. package/dist/types/unit/3X.d.ts +0 -2
  342. package/dist/types/unit/4X.d.ts +0 -2
  343. package/dist/types/unit/5X.d.ts +0 -2
  344. package/dist/types/unit/6X.d.ts +0 -2
  345. package/dist/types/unit/7X.d.ts +0 -2
  346. package/dist/types/unit/8X.d.ts +0 -2
  347. package/dist/types/unit/9X.d.ts +0 -2
  348. package/dist/types/unit/AX.d.ts +0 -2
  349. package/dist/types/unit/BX.d.ts +0 -2
  350. package/dist/types/unit/CX.d.ts +0 -2
  351. package/dist/types/unit/DX.d.ts +0 -2
  352. package/dist/types/unit/EX.d.ts +0 -2
  353. package/dist/types/unit/FX.d.ts +0 -2
  354. package/dist/types/unit/GX.d.ts +0 -2
  355. package/dist/types/unit/HX.d.ts +0 -2
  356. package/dist/types/unit/IX.d.ts +0 -2
  357. package/dist/types/unit/JX.d.ts +0 -2
  358. package/dist/types/unit/KX.d.ts +0 -2
  359. package/dist/types/unit/LX.d.ts +0 -2
  360. package/dist/types/unit/MX.d.ts +0 -2
  361. package/dist/types/unit/NX.d.ts +0 -2
  362. package/dist/types/unit/OX.d.ts +0 -2
  363. package/dist/types/unit/PX.d.ts +0 -2
  364. package/dist/types/unit/QX.d.ts +0 -2
  365. package/dist/types/unit/RX.d.ts +0 -2
  366. package/dist/types/unit/SX.d.ts +0 -2
  367. package/dist/types/unit/TX.d.ts +0 -2
  368. package/dist/types/unit/UX.d.ts +0 -2
  369. package/dist/types/unit/VX.d.ts +0 -2
  370. package/dist/types/unit/WX.d.ts +0 -2
  371. package/dist/types/unit/XX.d.ts +0 -2
  372. package/dist/types/unit/YX.d.ts +0 -2
  373. package/dist/types/unit/ZX.d.ts +0 -2
  374. package/dist/types/unit-types.d.ts +0 -37
  375. package/dist/types/utils.d.ts +0 -2
  376. package/dist/unit-types-BXdufGWm.d.cts +0 -56
  377. package/dist/unit-types-VgYXIwTT.d.ts +0 -55
  378. package/dist/utils/apiQueue.d.ts +0 -45
  379. package/dist/utils/apiQueue.js +0 -3
  380. package/dist/utils/base64.d.ts +0 -5
  381. package/dist/utils/base64.js +0 -10
  382. package/dist/utils/certificate.d.ts +0 -26
  383. package/dist/utils/certificate.js +0 -3
  384. package/dist/utils/document.d.ts +0 -211
  385. package/dist/utils/document.js +0 -4
  386. package/dist/utils/formatIdValue.d.ts +0 -4
  387. package/dist/utils/formatIdValue.js +0 -3
  388. package/dist/utils/getBaseUrl.d.ts +0 -4
  389. package/dist/utils/getBaseUrl.js +0 -3
  390. package/dist/utils/signature-diagnostics.d.ts +0 -96
  391. package/dist/utils/signature-diagnostics.js +0 -327
  392. package/dist/utils/validation.d.ts +0 -108
  393. package/dist/utils/validation.js +0 -186
  394. package/dist/utils-C4FoVKLq.d.ts +0 -4
  395. package/dist/utils-Cdqbbzca.d.cts +0 -5
package/dist/index15.cjs CHANGED
@@ -1,193 +1,329 @@
1
+ const require_document = require('./document-B11B5lqd.cjs');
2
+ require('./formatIdValue-i67o4kyD.cjs');
3
+ const crypto = require_document.__toESM(require("crypto"));
1
4
 
2
- //#region src/utils/validation.ts
5
+ //#region src/utils/signature-diagnostics.ts
3
6
  /**
4
- * Validates TIN format based on registration type
7
+ * Analyzes certificate for MyInvois compatibility issues
5
8
  */
6
- const validateTIN = (tin, registrationType) => {
7
- const errors = [];
8
- if (!tin) {
9
- errors.push({
10
- field: "tin",
11
- code: "TIN_REQUIRED",
12
- message: "TIN is required",
13
- severity: "error"
9
+ function analyzeCertificateForDiagnostics(certificatePem) {
10
+ const issues = [];
11
+ const recommendations = [];
12
+ try {
13
+ const cert = new crypto.default.X509Certificate(certificatePem);
14
+ const certInfo = require_document.extractCertificateInfo(certificatePem);
15
+ const parseSubjectFields = (dn) => {
16
+ const fields = {};
17
+ dn.split("\n").forEach((line) => {
18
+ const trimmed = line.trim();
19
+ if (trimmed.includes("=")) {
20
+ const [key, ...valueParts] = trimmed.split("=");
21
+ if (key) fields[key.trim()] = valueParts.join("=").trim();
22
+ }
23
+ });
24
+ return fields;
25
+ };
26
+ const subjectFields = parseSubjectFields(cert.subject);
27
+ const organizationIdentifier = subjectFields["organizationIdentifier"] || subjectFields["2.5.4.97"];
28
+ const serialNumber = subjectFields["serialNumber"];
29
+ if (!organizationIdentifier) {
30
+ issues.push("DS311: Certificate missing organizationIdentifier field (TIN)");
31
+ recommendations.push("CRITICAL: Generate new certificate with organizationIdentifier matching your MyInvois TIN");
32
+ recommendations.push("Portal Error: \"Signer of invoice doesn't match the submitter of document. TIN doesn't match with the OI.\"");
33
+ } else if (organizationIdentifier.length < 10) {
34
+ issues.push("DS311: OrganizationIdentifier (TIN) appears too short - may cause submission rejection");
35
+ recommendations.push("Verify TIN format matches exactly what is registered in MyInvois");
36
+ }
37
+ if (!serialNumber) {
38
+ issues.push("DS312: Certificate missing serialNumber field (business registration)");
39
+ recommendations.push("CRITICAL: Generate new certificate with serialNumber matching your business registration");
40
+ recommendations.push("Portal Error: \"Submitter registration/identity number doesn't match with the certificate SERIALNUMBER.\"");
41
+ }
42
+ if (cert.issuer === cert.subject) {
43
+ issues.push("DS329: Self-signed certificate detected - will fail chain of trust validation");
44
+ recommendations.push("BLOCKING: Obtain certificate from MyInvois-approved CA:");
45
+ recommendations.push("• MSC Trustgate Sdn Bhd");
46
+ recommendations.push("• DigiCert Sdn Bhd");
47
+ recommendations.push("• Cybersign Asia Sdn Bhd");
48
+ recommendations.push("Portal Error: \"Certificate is not valid according to the chain of trust validation or has been issued by an untrusted certificate authority.\"");
49
+ } else {
50
+ const issuerName = cert.issuer.toLowerCase();
51
+ const approvedCAs = [
52
+ "msc trustgate",
53
+ "digicert",
54
+ "cybersign"
55
+ ];
56
+ const isFromApprovedCA = approvedCAs.some((ca) => issuerName.includes(ca));
57
+ if (!isFromApprovedCA) {
58
+ issues.push("DS329: Certificate may not be from MyInvois-approved CA");
59
+ recommendations.push("Verify certificate was issued by an approved CA for MyInvois");
60
+ }
61
+ }
62
+ const rawIssuer = cert.issuer;
63
+ const normalizedIssuer = certInfo.issuerName;
64
+ const normalizedIssuerIssues = [
65
+ {
66
+ check: normalizedIssuer.includes("\n"),
67
+ issue: "Normalized issuer still contains newlines"
68
+ },
69
+ {
70
+ check: normalizedIssuer.includes(" "),
71
+ issue: "Normalized issuer contains double spaces"
72
+ },
73
+ {
74
+ check: /=\s+/.test(normalizedIssuer),
75
+ issue: "Normalized issuer has spaces after equals"
76
+ },
77
+ {
78
+ check: /\s+=/.test(normalizedIssuer),
79
+ issue: "Normalized issuer has spaces before equals"
80
+ },
81
+ {
82
+ check: normalizedIssuer.includes("\r"),
83
+ issue: "Normalized issuer contains carriage returns"
84
+ }
85
+ ];
86
+ const hasActualFormatIssues = normalizedIssuerIssues.some(({ check, issue }) => {
87
+ if (check) {
88
+ issues.push(`DS326: ${issue} - will cause X509IssuerName mismatch`);
89
+ return true;
90
+ }
91
+ return false;
14
92
  });
15
- return errors;
93
+ const hasRawIssuesButNormalizedOk = rawIssuer.includes("\n") && !normalizedIssuer.includes("\n");
94
+ if (hasActualFormatIssues) {
95
+ recommendations.push("CRITICAL: Fix issuer name normalization in signature generation");
96
+ recommendations.push("Portal Error: \"Certificate X509IssuerName doesn't match the X509IssuerName value provided in the signed properties section.\"");
97
+ recommendations.push("The normalization function is not properly formatting the issuer name");
98
+ recommendations.push("Debug: Check document.ts extractCertificateInfo() normalization logic");
99
+ } else if (hasRawIssuesButNormalizedOk) console.log("ℹ️ Note: Raw certificate issuer has newlines but normalization is handling them correctly");
100
+ const now = /* @__PURE__ */ new Date();
101
+ const validFrom = new Date(cert.validFrom);
102
+ const validTo = new Date(cert.validTo);
103
+ if (now < validFrom) {
104
+ issues.push("DS329: Certificate not yet valid (future start date)");
105
+ recommendations.push("Wait until certificate validity period begins");
106
+ }
107
+ if (now > validTo) {
108
+ issues.push("DS329: Certificate has expired");
109
+ recommendations.push("BLOCKING: Renew certificate - expired certificates are rejected");
110
+ }
111
+ try {
112
+ if (cert.keyUsage && !cert.keyUsage.includes("digital signature")) {
113
+ issues.push("DS333: Certificate lacks digitalSignature key usage");
114
+ recommendations.push("Generate new certificate with digitalSignature key usage enabled");
115
+ }
116
+ } catch {
117
+ console.log("Note: Could not check key usage extensions");
118
+ }
119
+ return {
120
+ organizationIdentifier,
121
+ serialNumber,
122
+ issuerName: certInfo.issuerName,
123
+ subjectName: certInfo.subjectName,
124
+ issues,
125
+ recommendations
126
+ };
127
+ } catch (error) {
128
+ issues.push(`Certificate parsing failed: ${error}`);
129
+ recommendations.push("Verify certificate format and validity");
130
+ return {
131
+ issuerName: "",
132
+ subjectName: "",
133
+ issues,
134
+ recommendations
135
+ };
16
136
  }
17
- if (registrationType === "BRN" && !tin.startsWith("C")) errors.push({
18
- field: "tin",
19
- code: "TIN_FORMAT_INVALID",
20
- message: "Company TIN should start with \"C\" for BRN registration",
21
- severity: "warning"
22
- });
23
- if (registrationType === "NRIC" && !tin.startsWith("IG")) errors.push({
24
- field: "tin",
25
- code: "TIN_FORMAT_INVALID",
26
- message: "Individual TIN should start with \"IG\" for NRIC registration",
27
- severity: "warning"
28
- });
29
- if (tin.length > 14) errors.push({
30
- field: "tin",
31
- code: "TIN_LENGTH_INVALID",
32
- message: "TIN cannot exceed 14 characters",
33
- severity: "error"
34
- });
35
- return errors;
36
- };
137
+ }
37
138
  /**
38
- * Validates contact number format (E.164 standard)
139
+ * Analyzes signature generation for potential issues
39
140
  */
40
- const validateContactNumber = (contactNumber) => {
41
- const errors = [];
42
- if (!contactNumber || contactNumber === "NA") return errors;
43
- const e164Regex = /^\+[1-9]\d{1,14}$/;
44
- if (!e164Regex.test(contactNumber)) errors.push({
45
- field: "contactNumber",
46
- code: "CONTACT_FORMAT_INVALID",
47
- message: "Contact number must be in E.164 format (e.g., +60123456789)",
48
- severity: "error"
49
- });
50
- if (contactNumber.length < 8) errors.push({
51
- field: "contactNumber",
52
- code: "CONTACT_LENGTH_INVALID",
53
- message: "Contact number must be at least 8 characters",
54
- severity: "error"
55
- });
56
- return errors;
57
- };
141
+ function analyzeSignatureForDiagnostics(invoices, certificatePem) {
142
+ const issues = [];
143
+ const recommendations = [];
144
+ try {
145
+ const documentDigest = require_document.calculateDocumentDigest(invoices);
146
+ const certificateDigest = require_document.calculateCertificateDigest(certificatePem);
147
+ const certInfo = require_document.extractCertificateInfo(certificatePem);
148
+ const signingTime = (/* @__PURE__ */ new Date()).toISOString();
149
+ const signedProperties = require_document.createSignedProperties(certificateDigest, signingTime, certInfo.issuerName, certInfo.serialNumber);
150
+ const signedPropertiesDigest = require_document.calculateSignedPropertiesDigest(signedProperties);
151
+ if (documentDigest.length === 0) {
152
+ issues.push("DS333: Document digest generation failed");
153
+ recommendations.push("CRITICAL: Verify document serialization excludes UBLExtensions/Signature");
154
+ recommendations.push("Portal Error: \"Document signature value is not a valid signature of the document digest using the public key of the certificate provided.\"");
155
+ }
156
+ if (certificateDigest.length === 0) {
157
+ issues.push("DS333: Certificate digest generation failed");
158
+ recommendations.push("CRITICAL: Verify certificate format and encoding");
159
+ recommendations.push("Certificate must be properly base64 encoded without headers/footers");
160
+ }
161
+ if (signedPropertiesDigest.length === 0) {
162
+ issues.push("DS333: Signed properties digest generation failed");
163
+ recommendations.push("CRITICAL: Verify signed properties structure and canonicalization");
164
+ recommendations.push("Check XML canonicalization (C14N) is applied correctly");
165
+ }
166
+ try {
167
+ const cert = new crypto.default.X509Certificate(certificatePem);
168
+ const publicKey = cert.publicKey;
169
+ const keyDetails = publicKey.asymmetricKeyDetails;
170
+ if (keyDetails) {
171
+ if (publicKey.asymmetricKeyType === "rsa" && keyDetails.modulusLength && keyDetails.modulusLength < 2048) {
172
+ issues.push("DS333: RSA key size too small (minimum 2048 bits required)");
173
+ recommendations.push("CRITICAL: Generate new certificate with RSA 2048+ bits");
174
+ }
175
+ const supportedKeyTypes = ["rsa", "ec"];
176
+ if (!supportedKeyTypes.includes(publicKey.asymmetricKeyType || "")) {
177
+ issues.push(`DS333: Unsupported key type: ${publicKey.asymmetricKeyType}`);
178
+ recommendations.push("CRITICAL: Use RSA or EC key types for MyInvois compatibility");
179
+ }
180
+ }
181
+ const certBuffer = Buffer.from(certificatePem.replace(/-----[^-]+-----/g, "").replace(/\s/g, ""), "base64");
182
+ if (certBuffer.length === 0) {
183
+ issues.push("DS333: Certificate encoding appears invalid");
184
+ recommendations.push("CRITICAL: Verify certificate is properly PEM encoded");
185
+ }
186
+ } catch (error) {
187
+ issues.push(`DS333: Certificate validation failed - ${error}`);
188
+ recommendations.push("CRITICAL: Verify certificate format and structure are valid");
189
+ }
190
+ const isValidBase64 = (str) => {
191
+ try {
192
+ return Buffer.from(str, "base64").toString("base64") === str;
193
+ } catch {
194
+ return false;
195
+ }
196
+ };
197
+ if (documentDigest && !isValidBase64(documentDigest)) {
198
+ issues.push("DS333: Document digest is not valid base64 format");
199
+ recommendations.push("Ensure digest is properly base64 encoded");
200
+ }
201
+ if (certificateDigest && !isValidBase64(certificateDigest)) {
202
+ issues.push("DS333: Certificate digest is not valid base64 format");
203
+ recommendations.push("Ensure certificate digest is properly base64 encoded");
204
+ }
205
+ if (signedPropertiesDigest && !isValidBase64(signedPropertiesDigest)) {
206
+ issues.push("DS333: Signed properties digest is not valid base64 format");
207
+ recommendations.push("Ensure signed properties digest is properly base64 encoded");
208
+ }
209
+ return {
210
+ documentDigest,
211
+ certificateDigest,
212
+ signedPropertiesDigest,
213
+ issues,
214
+ recommendations
215
+ };
216
+ } catch (error) {
217
+ issues.push(`Signature analysis failed: ${error}`);
218
+ recommendations.push("Review signature generation implementation");
219
+ return {
220
+ documentDigest: "",
221
+ certificateDigest: "",
222
+ signedPropertiesDigest: "",
223
+ issues,
224
+ recommendations
225
+ };
226
+ }
227
+ }
58
228
  /**
59
- * Validates monetary amounts
229
+ * Comprehensive signature diagnostics
60
230
  */
61
- const validateMonetaryAmount = (amount, fieldName, maxDigits = 18, maxDecimals = 2) => {
62
- const errors = [];
63
- if (amount < 0) errors.push({
64
- field: fieldName,
65
- code: "AMOUNT_NEGATIVE",
66
- message: `${fieldName} cannot be negative`,
67
- severity: "error"
68
- });
69
- const amountStr = amount.toString();
70
- const [integerPart, decimalPart] = amountStr.split(".");
71
- if (integerPart && integerPart.length > maxDigits - maxDecimals) errors.push({
72
- field: fieldName,
73
- code: "AMOUNT_DIGITS_EXCEEDED",
74
- message: `${fieldName} exceeds maximum ${maxDigits} digits`,
75
- severity: "error"
76
- });
77
- if (decimalPart && decimalPart.length > maxDecimals) errors.push({
78
- field: fieldName,
79
- code: "AMOUNT_DECIMALS_EXCEEDED",
80
- message: `${fieldName} exceeds maximum ${maxDecimals} decimal places`,
81
- severity: "error"
82
- });
83
- return errors;
84
- };
231
+ function diagnoseSignatureIssues(invoices, certificatePem) {
232
+ const certificateAnalysis = analyzeCertificateForDiagnostics(certificatePem);
233
+ const signatureAnalysis = analyzeSignatureForDiagnostics(invoices, certificatePem);
234
+ const certificateIssues = certificateAnalysis.issues.length;
235
+ const signatureIssues = signatureAnalysis.issues.length;
236
+ return {
237
+ certificateAnalysis,
238
+ signatureAnalysis,
239
+ summary: {
240
+ totalIssues: certificateIssues + signatureIssues,
241
+ certificateIssues,
242
+ signatureIssues
243
+ }
244
+ };
245
+ }
85
246
  /**
86
- * Validates line item tax calculation consistency for both fixed rate and percentage taxation
247
+ * Prints diagnostic results in a formatted way
87
248
  */
88
- const validateLineItemTax = (item, index) => {
89
- const errors = [];
90
- const tolerance = .01;
91
- const hasFixedRate = item.taxPerUnitAmount !== void 0 && item.baseUnitMeasure !== void 0;
92
- const hasPercentageRate = item.taxRate !== void 0;
93
- if (!hasFixedRate && !hasPercentageRate) {
94
- errors.push({
95
- field: `lineItem[${index}]`,
96
- code: "TAX_METHOD_MISSING",
97
- message: `Line item ${index + 1} must specify either taxRate (for percentage) or taxPerUnitAmount + baseUnitMeasure (for fixed rate)`,
98
- severity: "error"
249
+ function printDiagnostics(result) {
250
+ console.log("\n🔍 MyInvois Signature Diagnostics Report");
251
+ console.log("=".repeat(60));
252
+ console.log("\n📜 CERTIFICATE ANALYSIS");
253
+ console.log("-".repeat(30));
254
+ console.log(` Issuer: ${result.certificateAnalysis.issuerName}`);
255
+ console.log(` Subject: ${result.certificateAnalysis.subjectName}`);
256
+ if (result.certificateAnalysis.organizationIdentifier) console.log(` Organization ID (TIN): ${result.certificateAnalysis.organizationIdentifier}`);
257
+ if (result.certificateAnalysis.serialNumber) console.log(` Serial Number: ${result.certificateAnalysis.serialNumber}`);
258
+ if (result.certificateAnalysis.issues.length > 0) {
259
+ console.log("\n 🚨 Certificate Issues:");
260
+ result.certificateAnalysis.issues.forEach((issue, index) => {
261
+ console.log(` ${index + 1}. ${issue}`);
99
262
  });
100
- return errors;
101
263
  }
102
- if (hasFixedRate && hasPercentageRate) errors.push({
103
- field: `lineItem[${index}]`,
104
- code: "TAX_METHOD_CONFLICT",
105
- message: `Line item ${index + 1} cannot have both percentage and fixed rate tax methods`,
106
- severity: "error"
107
- });
108
- if (hasFixedRate) {
109
- if (item.baseUnitMeasureCode === void 0) errors.push({
110
- field: `lineItem[${index}].baseUnitMeasureCode`,
111
- code: "UNIT_CODE_MISSING",
112
- message: `Line item ${index + 1} with fixed rate tax must specify baseUnitMeasureCode`,
113
- severity: "error"
264
+ if (result.certificateAnalysis.recommendations.length > 0) {
265
+ console.log("\n 💡 Certificate Recommendations:");
266
+ result.certificateAnalysis.recommendations.forEach((rec, index) => {
267
+ console.log(` ${index + 1}. ${rec}`);
114
268
  });
115
- const expectedTaxAmount = item.taxPerUnitAmount * item.baseUnitMeasure;
116
- if (Math.abs(item.taxAmount - expectedTaxAmount) > tolerance) errors.push({
117
- field: `lineItem[${index}].taxAmount`,
118
- code: "FIXED_TAX_CALCULATION_MISMATCH",
119
- message: `Line item ${index + 1} tax amount (${item.taxAmount}) doesn't match fixed rate calculation (${item.taxPerUnitAmount} × ${item.baseUnitMeasure} = ${expectedTaxAmount})`,
120
- severity: "error"
269
+ }
270
+ console.log("\n🔐 SIGNATURE ANALYSIS");
271
+ console.log("-".repeat(30));
272
+ console.log(` Document Digest: ${result.signatureAnalysis.documentDigest.substring(0, 32)}...`);
273
+ console.log(` Certificate Digest: ${result.signatureAnalysis.certificateDigest.substring(0, 32)}...`);
274
+ console.log(` Signed Properties Digest: ${result.signatureAnalysis.signedPropertiesDigest.substring(0, 32)}...`);
275
+ if (result.signatureAnalysis.issues.length > 0) {
276
+ console.log("\n 🚨 Signature Issues:");
277
+ result.signatureAnalysis.issues.forEach((issue, index) => {
278
+ console.log(` ${index + 1}. ${issue}`);
121
279
  });
122
280
  }
123
- if (hasPercentageRate && !hasFixedRate) {
124
- const expectedTaxAmount = item.totalTaxableAmountPerLine * item.taxRate / 100;
125
- if (Math.abs(item.taxAmount - expectedTaxAmount) > tolerance) errors.push({
126
- field: `lineItem[${index}].taxAmount`,
127
- code: "PERCENTAGE_TAX_CALCULATION_MISMATCH",
128
- message: `Line item ${index + 1} tax amount (${item.taxAmount}) doesn't match percentage calculation (${item.totalTaxableAmountPerLine} × ${item.taxRate}% = ${expectedTaxAmount})`,
129
- severity: "error"
281
+ if (result.signatureAnalysis.recommendations.length > 0) {
282
+ console.log("\n 💡 Signature Recommendations:");
283
+ result.signatureAnalysis.recommendations.forEach((rec, index) => {
284
+ console.log(` ${index + 1}. ${rec}`);
130
285
  });
131
286
  }
132
- return errors;
133
- };
134
- /**
135
- * Validates tax calculation consistency
136
- */
137
- const validateTaxCalculations = (invoice) => {
138
- const errors = [];
139
- invoice.invoiceLineItems.forEach((item, index) => {
140
- errors.push(...validateLineItemTax(item, index));
141
- });
142
- const expectedTaxExclusive = invoice.invoiceLineItems.reduce((sum, item) => sum + item.totalTaxableAmountPerLine, 0);
143
- const expectedTaxAmount = invoice.invoiceLineItems.reduce((sum, item) => sum + item.taxAmount, 0);
144
- const tolerance = .01;
145
- if (Math.abs(invoice.legalMonetaryTotal.taxExclusiveAmount - expectedTaxExclusive) > tolerance) errors.push({
146
- field: "legalMonetaryTotal.taxExclusiveAmount",
147
- code: "TAX_EXCLUSIVE_MISMATCH",
148
- message: `Tax exclusive amount (${invoice.legalMonetaryTotal.taxExclusiveAmount}) doesn't match sum of line items (${expectedTaxExclusive})`,
149
- severity: "error"
150
- });
151
- if (Math.abs(invoice.taxTotal.taxAmount - expectedTaxAmount) > tolerance) errors.push({
152
- field: "taxTotal.taxAmount",
153
- code: "TAX_AMOUNT_MISMATCH",
154
- message: `Tax amount (${invoice.taxTotal.taxAmount}) doesn't match sum of line item taxes (${expectedTaxAmount})`,
155
- severity: "error"
156
- });
157
- return errors;
158
- };
159
- /**
160
- * Main validation function for complete invoice
161
- */
162
- const validateInvoice = (invoice) => {
163
- const allErrors = [];
164
- allErrors.push(...validateTIN(invoice.supplier.tin, invoice.supplier.registrationType));
165
- allErrors.push(...validateTIN(invoice.buyer.tin, invoice.buyer.registrationType));
166
- allErrors.push(...validateContactNumber(invoice.supplier.contactNumber));
167
- allErrors.push(...validateContactNumber(invoice.buyer.contactNumber));
168
- allErrors.push(...validateMonetaryAmount(invoice.legalMonetaryTotal.taxExclusiveAmount, "taxExclusiveAmount"));
169
- allErrors.push(...validateMonetaryAmount(invoice.legalMonetaryTotal.payableAmount, "payableAmount"));
170
- allErrors.push(...validateMonetaryAmount(invoice.taxTotal.taxAmount, "taxAmount"));
171
- invoice.invoiceLineItems.forEach((item, index) => {
172
- allErrors.push(...validateMonetaryAmount(item.unitPrice, `lineItem[${index}].unitPrice`));
173
- allErrors.push(...validateMonetaryAmount(item.taxAmount, `lineItem[${index}].taxAmount`));
174
- allErrors.push(...validateMonetaryAmount(item.totalTaxableAmountPerLine, `lineItem[${index}].totalTaxableAmountPerLine`));
175
- });
176
- allErrors.push(...validateTaxCalculations(invoice));
177
- const errors = allErrors.filter((e) => e.severity === "error");
178
- const warnings = allErrors.filter((e) => e.severity === "warning");
179
- return {
180
- isValid: errors.length === 0,
181
- errors,
182
- warnings
183
- };
184
- };
287
+ console.log("\n📊 SUMMARY");
288
+ console.log("-".repeat(30));
289
+ console.log(` Total Issues Found: ${result.summary.totalIssues}`);
290
+ console.log(` Certificate Issues: ${result.summary.certificateIssues}`);
291
+ console.log(` Signature Issues: ${result.summary.signatureIssues}`);
292
+ if (result.summary.totalIssues === 0) {
293
+ console.log("\n ✅ No issues detected in current analysis");
294
+ console.log(" 🎉 Certificate and signature implementation appear valid");
295
+ } else {
296
+ console.log("\n ⚠️ Issues detected - review recommendations above");
297
+ const hasDS311 = result.certificateAnalysis.issues.some((issue) => issue.includes("DS311"));
298
+ const hasDS312 = result.certificateAnalysis.issues.some((issue) => issue.includes("DS312"));
299
+ const hasDS326 = result.certificateAnalysis.issues.some((issue) => issue.includes("DS326"));
300
+ const hasDS329 = result.certificateAnalysis.issues.some((issue) => issue.includes("DS329"));
301
+ const hasDS333 = result.signatureAnalysis.issues.some((issue) => issue.includes("DS333"));
302
+ console.log("\n 🎯 MYINVOIS PORTAL ERROR ANALYSIS:");
303
+ if (hasDS311) console.log(" ❌ DS311 - TIN mismatch between certificate and submitter");
304
+ if (hasDS312) console.log(" ❌ DS312 - Registration number mismatch with certificate");
305
+ if (hasDS326) console.log(" ❌ DS326 - X509IssuerName format inconsistency");
306
+ if (hasDS329) console.log(" ❌ DS329 - Certificate trust chain validation failure");
307
+ if (hasDS333) console.log(" ❌ DS333 - Document signature validation failure");
308
+ if (result.summary.certificateIssues > 0) {
309
+ console.log("\n 🚨 PRIMARY ACTION REQUIRED:");
310
+ console.log(" Certificate issues must be resolved first");
311
+ console.log(" Self-generated certificates cannot pass MyInvois validation");
312
+ }
313
+ if (result.summary.signatureIssues > 0) {
314
+ console.log("\n ⚙️ SECONDARY ACTION:");
315
+ console.log(" Review and optimize signature implementation");
316
+ }
317
+ console.log("\n 📋 NEXT STEPS:");
318
+ console.log(" 1. Address BLOCKING/CRITICAL issues first");
319
+ console.log(" 2. Test with updated certificate/implementation");
320
+ console.log(" 3. Re-run diagnostics to verify fixes");
321
+ console.log(" 4. Submit test document to MyInvois portal");
322
+ }
323
+ console.log("\n" + "=".repeat(60));
324
+ }
185
325
 
186
326
  //#endregion
187
- exports.validateContactNumber = validateContactNumber;
188
- exports.validateInvoice = validateInvoice;
189
- exports.validateLineItemTax = validateLineItemTax;
190
- exports.validateMonetaryAmount = validateMonetaryAmount;
191
- exports.validateTIN = validateTIN;
192
- exports.validateTaxCalculations = validateTaxCalculations;
327
+ exports.diagnoseSignatureIssues = diagnoseSignatureIssues;
328
+ exports.printDiagnostics = printDiagnostics;
193
329
  //# sourceMappingURL=index15.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index15.cjs","names":["tin: string","registrationType?: string","errors: ValidationError[]","contactNumber: string","amount: number","fieldName: string","item: InvoiceLineItem","index: number","invoice: InvoiceV1_1","allErrors: ValidationError[]"],"sources":["../src/utils/validation.ts"],"sourcesContent":["import type { InvoiceV1_1, InvoiceLineItem } from '../types'\n\n/**\n * MyInvois Invoice Validation Utilities\n *\n * Provides comprehensive validation for invoice data before document generation\n * and submission to ensure compliance with MyInvois business rules and format requirements.\n */\n\nexport interface ValidationResult {\n isValid: boolean\n errors: ValidationError[]\n warnings: ValidationWarning[]\n}\n\nexport interface ValidationError {\n field: string\n code: string\n message: string\n severity: 'error' | 'warning'\n}\n\nexport interface ValidationWarning extends ValidationError {\n severity: 'warning'\n}\n\n/**\n * Validates TIN format based on registration type\n */\nexport const validateTIN = (\n tin: string,\n registrationType?: string,\n): ValidationError[] => {\n const errors: ValidationError[] = []\n\n if (!tin) {\n errors.push({\n field: 'tin',\n code: 'TIN_REQUIRED',\n message: 'TIN is required',\n severity: 'error',\n })\n return errors\n }\n\n // TIN format validation based on type\n if (registrationType === 'BRN' && !tin.startsWith('C')) {\n errors.push({\n field: 'tin',\n code: 'TIN_FORMAT_INVALID',\n message: 'Company TIN should start with \"C\" for BRN registration',\n severity: 'warning',\n })\n }\n\n if (registrationType === 'NRIC' && !tin.startsWith('IG')) {\n errors.push({\n field: 'tin',\n code: 'TIN_FORMAT_INVALID',\n message: 'Individual TIN should start with \"IG\" for NRIC registration',\n severity: 'warning',\n })\n }\n\n // Length validation\n if (tin.length > 14) {\n errors.push({\n field: 'tin',\n code: 'TIN_LENGTH_INVALID',\n message: 'TIN cannot exceed 14 characters',\n severity: 'error',\n })\n }\n\n return errors\n}\n\n/**\n * Validates contact number format (E.164 standard)\n */\nexport const validateContactNumber = (\n contactNumber: string,\n): ValidationError[] => {\n const errors: ValidationError[] = []\n\n if (!contactNumber || contactNumber === 'NA') {\n return errors // Allow NA for consolidated e-invoices\n }\n\n // E.164 format validation\n const e164Regex = /^\\+[1-9]\\d{1,14}$/\n if (!e164Regex.test(contactNumber)) {\n errors.push({\n field: 'contactNumber',\n code: 'CONTACT_FORMAT_INVALID',\n message: 'Contact number must be in E.164 format (e.g., +60123456789)',\n severity: 'error',\n })\n }\n\n if (contactNumber.length < 8) {\n errors.push({\n field: 'contactNumber',\n code: 'CONTACT_LENGTH_INVALID',\n message: 'Contact number must be at least 8 characters',\n severity: 'error',\n })\n }\n\n return errors\n}\n\n/**\n * Validates monetary amounts\n */\nexport const validateMonetaryAmount = (\n amount: number,\n fieldName: string,\n maxDigits = 18,\n maxDecimals = 2,\n): ValidationError[] => {\n const errors: ValidationError[] = []\n\n if (amount < 0) {\n errors.push({\n field: fieldName,\n code: 'AMOUNT_NEGATIVE',\n message: `${fieldName} cannot be negative`,\n severity: 'error',\n })\n }\n\n // Check total digits\n const amountStr = amount.toString()\n const [integerPart, decimalPart] = amountStr.split('.')\n\n if (integerPart && integerPart.length > maxDigits - maxDecimals) {\n errors.push({\n field: fieldName,\n code: 'AMOUNT_DIGITS_EXCEEDED',\n message: `${fieldName} exceeds maximum ${maxDigits} digits`,\n severity: 'error',\n })\n }\n\n if (decimalPart && decimalPart.length > maxDecimals) {\n errors.push({\n field: fieldName,\n code: 'AMOUNT_DECIMALS_EXCEEDED',\n message: `${fieldName} exceeds maximum ${maxDecimals} decimal places`,\n severity: 'error',\n })\n }\n\n return errors\n}\n\n/**\n * Validates line item tax calculation consistency for both fixed rate and percentage taxation\n */\nexport const validateLineItemTax = (\n item: InvoiceLineItem,\n index: number,\n): ValidationError[] => {\n const errors: ValidationError[] = []\n const tolerance = 0.01\n\n // Check if tax calculation method is specified\n const hasFixedRate =\n item.taxPerUnitAmount !== undefined && item.baseUnitMeasure !== undefined\n const hasPercentageRate = item.taxRate !== undefined\n\n if (!hasFixedRate && !hasPercentageRate) {\n errors.push({\n field: `lineItem[${index}]`,\n code: 'TAX_METHOD_MISSING',\n message: `Line item ${index + 1} must specify either taxRate (for percentage) or taxPerUnitAmount + baseUnitMeasure (for fixed rate)`,\n severity: 'error',\n })\n return errors\n }\n\n if (hasFixedRate && hasPercentageRate) {\n errors.push({\n field: `lineItem[${index}]`,\n code: 'TAX_METHOD_CONFLICT',\n message: `Line item ${index + 1} cannot have both percentage and fixed rate tax methods`,\n severity: 'error',\n })\n }\n\n // Validate fixed rate tax calculation\n if (hasFixedRate) {\n if (item.baseUnitMeasureCode === undefined) {\n errors.push({\n field: `lineItem[${index}].baseUnitMeasureCode`,\n code: 'UNIT_CODE_MISSING',\n message: `Line item ${index + 1} with fixed rate tax must specify baseUnitMeasureCode`,\n severity: 'error',\n })\n }\n\n const expectedTaxAmount = item.taxPerUnitAmount! * item.baseUnitMeasure!\n if (Math.abs(item.taxAmount - expectedTaxAmount) > tolerance) {\n errors.push({\n field: `lineItem[${index}].taxAmount`,\n code: 'FIXED_TAX_CALCULATION_MISMATCH',\n message: `Line item ${index + 1} tax amount (${item.taxAmount}) doesn't match fixed rate calculation (${item.taxPerUnitAmount} × ${item.baseUnitMeasure} = ${expectedTaxAmount})`,\n severity: 'error',\n })\n }\n }\n\n // Validate percentage tax calculation\n if (hasPercentageRate && !hasFixedRate) {\n const expectedTaxAmount =\n (item.totalTaxableAmountPerLine * item.taxRate!) / 100\n if (Math.abs(item.taxAmount - expectedTaxAmount) > tolerance) {\n errors.push({\n field: `lineItem[${index}].taxAmount`,\n code: 'PERCENTAGE_TAX_CALCULATION_MISMATCH',\n message: `Line item ${index + 1} tax amount (${item.taxAmount}) doesn't match percentage calculation (${item.totalTaxableAmountPerLine} × ${item.taxRate}% = ${expectedTaxAmount})`,\n severity: 'error',\n })\n }\n }\n\n return errors\n}\n\n/**\n * Validates tax calculation consistency\n */\nexport const validateTaxCalculations = (\n invoice: InvoiceV1_1,\n): ValidationError[] => {\n const errors: ValidationError[] = []\n\n // Validate individual line item tax calculations\n invoice.invoiceLineItems.forEach((item, index) => {\n errors.push(...validateLineItemTax(item, index))\n })\n\n // Calculate expected totals from line items\n const expectedTaxExclusive = invoice.invoiceLineItems.reduce(\n (sum, item) => sum + item.totalTaxableAmountPerLine,\n 0,\n )\n const expectedTaxAmount = invoice.invoiceLineItems.reduce(\n (sum, item) => sum + item.taxAmount,\n 0,\n )\n\n // Allow small rounding differences (0.01)\n const tolerance = 0.01\n\n if (\n Math.abs(\n invoice.legalMonetaryTotal.taxExclusiveAmount - expectedTaxExclusive,\n ) > tolerance\n ) {\n errors.push({\n field: 'legalMonetaryTotal.taxExclusiveAmount',\n code: 'TAX_EXCLUSIVE_MISMATCH',\n message: `Tax exclusive amount (${invoice.legalMonetaryTotal.taxExclusiveAmount}) doesn't match sum of line items (${expectedTaxExclusive})`,\n severity: 'error',\n })\n }\n\n if (Math.abs(invoice.taxTotal.taxAmount - expectedTaxAmount) > tolerance) {\n errors.push({\n field: 'taxTotal.taxAmount',\n code: 'TAX_AMOUNT_MISMATCH',\n message: `Tax amount (${invoice.taxTotal.taxAmount}) doesn't match sum of line item taxes (${expectedTaxAmount})`,\n severity: 'error',\n })\n }\n\n return errors\n}\n\n/**\n * Main validation function for complete invoice\n */\nexport const validateInvoice = (invoice: InvoiceV1_1): ValidationResult => {\n const allErrors: ValidationError[] = []\n\n // Core field validations\n allErrors.push(\n ...validateTIN(invoice.supplier.tin, invoice.supplier.registrationType),\n )\n allErrors.push(\n ...validateTIN(invoice.buyer.tin, invoice.buyer.registrationType),\n )\n\n allErrors.push(...validateContactNumber(invoice.supplier.contactNumber))\n allErrors.push(...validateContactNumber(invoice.buyer.contactNumber))\n\n // Monetary validations\n allErrors.push(\n ...validateMonetaryAmount(\n invoice.legalMonetaryTotal.taxExclusiveAmount,\n 'taxExclusiveAmount',\n ),\n )\n allErrors.push(\n ...validateMonetaryAmount(\n invoice.legalMonetaryTotal.payableAmount,\n 'payableAmount',\n ),\n )\n allErrors.push(\n ...validateMonetaryAmount(invoice.taxTotal.taxAmount, 'taxAmount'),\n )\n\n // Line item validations\n invoice.invoiceLineItems.forEach((item, index) => {\n allErrors.push(\n ...validateMonetaryAmount(item.unitPrice, `lineItem[${index}].unitPrice`),\n )\n allErrors.push(\n ...validateMonetaryAmount(item.taxAmount, `lineItem[${index}].taxAmount`),\n )\n allErrors.push(\n ...validateMonetaryAmount(\n item.totalTaxableAmountPerLine,\n `lineItem[${index}].totalTaxableAmountPerLine`,\n ),\n )\n })\n\n // Business rule validations\n allErrors.push(...validateTaxCalculations(invoice))\n\n // Separate errors and warnings\n const errors = allErrors.filter(e => e.severity === 'error')\n const warnings = allErrors.filter(\n e => e.severity === 'warning',\n ) as ValidationWarning[]\n\n return {\n isValid: errors.length === 0,\n errors,\n warnings,\n }\n}\n"],"mappings":";;;;;AA6BA,MAAa,cAAc,CACzBA,KACAC,qBACsB;CACtB,MAAMC,SAA4B,CAAE;AAEpC,MAAK,KAAK;AACR,SAAO,KAAK;GACV,OAAO;GACP,MAAM;GACN,SAAS;GACT,UAAU;EACX,EAAC;AACF,SAAO;CACR;AAGD,KAAI,qBAAqB,UAAU,IAAI,WAAW,IAAI,CACpD,QAAO,KAAK;EACV,OAAO;EACP,MAAM;EACN,SAAS;EACT,UAAU;CACX,EAAC;AAGJ,KAAI,qBAAqB,WAAW,IAAI,WAAW,KAAK,CACtD,QAAO,KAAK;EACV,OAAO;EACP,MAAM;EACN,SAAS;EACT,UAAU;CACX,EAAC;AAIJ,KAAI,IAAI,SAAS,GACf,QAAO,KAAK;EACV,OAAO;EACP,MAAM;EACN,SAAS;EACT,UAAU;CACX,EAAC;AAGJ,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AAO,OAAK,EAAE,aAAa,QAAQ;CAC5D,MAAM,WAAW,UAAU,OACzB,OAAK,EAAE,aAAa,UACrB;AAED,QAAO;EACL,SAAS,OAAO,WAAW;EAC3B;EACA;CACD;AACF"}
1
+ {"version":3,"file":"index15.cjs","names":["certificatePem: string","issues: string[]","recommendations: string[]","dn: string","fields: Record<string, string>","invoices: InvoiceV1_1[]","str: string","result: DiagnosticResult"],"sources":["../src/utils/signature-diagnostics.ts"],"sourcesContent":["import crypto from 'crypto'\nimport type { InvoiceV1_1 } from '../types'\nimport {\n extractCertificateInfo,\n calculateDocumentDigest,\n calculateSignedPropertiesDigest,\n createSignedProperties,\n calculateCertificateDigest,\n} from './document'\n\nexport interface CertificateAnalysisResult {\n organizationIdentifier?: string\n serialNumber?: string\n issuerName: string\n subjectName: string\n issues: string[]\n recommendations: string[]\n}\n\nexport interface SignatureAnalysisResult {\n documentDigest: string\n certificateDigest: string\n signedPropertiesDigest: string\n issues: string[]\n recommendations: string[]\n}\n\nexport interface DiagnosticResult {\n certificateAnalysis: CertificateAnalysisResult\n signatureAnalysis: SignatureAnalysisResult\n summary: {\n totalIssues: number\n certificateIssues: number\n signatureIssues: number\n }\n}\n\n/**\n * Analyzes certificate for MyInvois compatibility issues\n */\nfunction analyzeCertificateForDiagnostics(\n certificatePem: string,\n): CertificateAnalysisResult {\n const issues: string[] = []\n const recommendations: string[] = []\n\n try {\n const cert = new crypto.X509Certificate(certificatePem)\n const certInfo = extractCertificateInfo(certificatePem)\n\n // Parse subject fields for MyInvois analysis\n const parseSubjectFields = (dn: string) => {\n const fields: Record<string, string> = {}\n dn.split('\\n').forEach(line => {\n const trimmed = line.trim()\n if (trimmed.includes('=')) {\n const [key, ...valueParts] = trimmed.split('=')\n if (key) {\n fields[key.trim()] = valueParts.join('=').trim()\n }\n }\n })\n return fields\n }\n\n const subjectFields = parseSubjectFields(cert.subject)\n const organizationIdentifier =\n subjectFields['organizationIdentifier'] || subjectFields['2.5.4.97']\n const serialNumber = subjectFields['serialNumber']\n\n // DS311 - TIN Mismatch Analysis\n if (!organizationIdentifier) {\n issues.push(\n 'DS311: Certificate missing organizationIdentifier field (TIN)',\n )\n recommendations.push(\n 'CRITICAL: Generate new certificate with organizationIdentifier matching your MyInvois TIN',\n )\n recommendations.push(\n 'Portal Error: \"Signer of invoice doesn\\'t match the submitter of document. TIN doesn\\'t match with the OI.\"',\n )\n } else {\n // Additional TIN format validation\n if (organizationIdentifier.length < 10) {\n issues.push(\n 'DS311: OrganizationIdentifier (TIN) appears too short - may cause submission rejection',\n )\n recommendations.push(\n 'Verify TIN format matches exactly what is registered in MyInvois',\n )\n }\n }\n\n // DS312 - Registration Number Analysis\n if (!serialNumber) {\n issues.push(\n 'DS312: Certificate missing serialNumber field (business registration)',\n )\n recommendations.push(\n 'CRITICAL: Generate new certificate with serialNumber matching your business registration',\n )\n recommendations.push(\n 'Portal Error: \"Submitter registration/identity number doesn\\'t match with the certificate SERIALNUMBER.\"',\n )\n }\n\n // DS329 - Certificate Trust Analysis\n if (cert.issuer === cert.subject) {\n issues.push(\n 'DS329: Self-signed certificate detected - will fail chain of trust validation',\n )\n recommendations.push(\n 'BLOCKING: Obtain certificate from MyInvois-approved CA:',\n )\n recommendations.push('• MSC Trustgate Sdn Bhd')\n recommendations.push('• DigiCert Sdn Bhd')\n recommendations.push('• Cybersign Asia Sdn Bhd')\n recommendations.push(\n 'Portal Error: \"Certificate is not valid according to the chain of trust validation or has been issued by an untrusted certificate authority.\"',\n )\n } else {\n // Check if issuer looks like a known CA\n const issuerName = cert.issuer.toLowerCase()\n const approvedCAs = ['msc trustgate', 'digicert', 'cybersign']\n const isFromApprovedCA = approvedCAs.some(ca => issuerName.includes(ca))\n\n if (!isFromApprovedCA) {\n issues.push('DS329: Certificate may not be from MyInvois-approved CA')\n recommendations.push(\n 'Verify certificate was issued by an approved CA for MyInvois',\n )\n }\n }\n\n // DS326 - Issuer Name Format Analysis (Enhanced)\n const rawIssuer = cert.issuer\n const normalizedIssuer = certInfo.issuerName\n\n // Check for issues in the NORMALIZED issuer (these are actual problems)\n const normalizedIssuerIssues = [\n {\n check: normalizedIssuer.includes('\\n'),\n issue: 'Normalized issuer still contains newlines',\n },\n {\n check: normalizedIssuer.includes(' '),\n issue: 'Normalized issuer contains double spaces',\n },\n {\n check: /=\\s+/.test(normalizedIssuer),\n issue: 'Normalized issuer has spaces after equals',\n },\n {\n check: /\\s+=/.test(normalizedIssuer),\n issue: 'Normalized issuer has spaces before equals',\n },\n {\n check: normalizedIssuer.includes('\\r'),\n issue: 'Normalized issuer contains carriage returns',\n },\n ]\n\n // Only report actual issues in the normalized version that will cause portal errors\n const hasActualFormatIssues = normalizedIssuerIssues.some(\n ({ check, issue }) => {\n if (check) {\n issues.push(`DS326: ${issue} - will cause X509IssuerName mismatch`)\n return true\n }\n return false\n },\n )\n\n // Check if raw issuer has issues but normalized version is OK (informational)\n const hasRawIssuesButNormalizedOk =\n rawIssuer.includes('\\n') && !normalizedIssuer.includes('\\n')\n\n if (hasActualFormatIssues) {\n recommendations.push(\n 'CRITICAL: Fix issuer name normalization in signature generation',\n )\n recommendations.push(\n 'Portal Error: \"Certificate X509IssuerName doesn\\'t match the X509IssuerName value provided in the signed properties section.\"',\n )\n recommendations.push(\n 'The normalization function is not properly formatting the issuer name',\n )\n recommendations.push(\n 'Debug: Check document.ts extractCertificateInfo() normalization logic',\n )\n } else if (hasRawIssuesButNormalizedOk) {\n // This is informational - normalization is working correctly\n console.log(\n 'ℹ️ Note: Raw certificate issuer has newlines but normalization is handling them correctly',\n )\n }\n\n // Additional certificate validity checks\n const now = new Date()\n const validFrom = new Date(cert.validFrom)\n const validTo = new Date(cert.validTo)\n\n if (now < validFrom) {\n issues.push('DS329: Certificate not yet valid (future start date)')\n recommendations.push('Wait until certificate validity period begins')\n }\n\n if (now > validTo) {\n issues.push('DS329: Certificate has expired')\n recommendations.push(\n 'BLOCKING: Renew certificate - expired certificates are rejected',\n )\n }\n\n // Check certificate key usage (if available)\n try {\n if (cert.keyUsage && !cert.keyUsage.includes('digital signature')) {\n issues.push('DS333: Certificate lacks digitalSignature key usage')\n recommendations.push(\n 'Generate new certificate with digitalSignature key usage enabled',\n )\n }\n } catch {\n // Key usage might not be available in all certificates\n console.log('Note: Could not check key usage extensions')\n }\n\n return {\n organizationIdentifier,\n serialNumber,\n issuerName: certInfo.issuerName,\n subjectName: certInfo.subjectName,\n issues,\n recommendations,\n }\n } catch (error) {\n issues.push(`Certificate parsing failed: ${error}`)\n recommendations.push('Verify certificate format and validity')\n\n return {\n issuerName: '',\n subjectName: '',\n issues,\n recommendations,\n }\n }\n}\n\n/**\n * Analyzes signature generation for potential issues\n */\nfunction analyzeSignatureForDiagnostics(\n invoices: InvoiceV1_1[],\n certificatePem: string,\n): SignatureAnalysisResult {\n const issues: string[] = []\n const recommendations: string[] = []\n\n try {\n // Step 1: Document digest\n const documentDigest = calculateDocumentDigest(invoices)\n\n // Step 2: Certificate digest\n const certificateDigest = calculateCertificateDigest(certificatePem)\n\n // Step 3: Extract certificate info\n const certInfo = extractCertificateInfo(certificatePem)\n const signingTime = new Date().toISOString()\n\n // Step 4: Create signed properties\n const signedProperties = createSignedProperties(\n certificateDigest,\n signingTime,\n certInfo.issuerName,\n certInfo.serialNumber,\n )\n\n // Step 5: Signed properties digest\n const signedPropertiesDigest =\n calculateSignedPropertiesDigest(signedProperties)\n\n // DS333 - Document Signature Validation\n if (documentDigest.length === 0) {\n issues.push('DS333: Document digest generation failed')\n recommendations.push(\n 'CRITICAL: Verify document serialization excludes UBLExtensions/Signature',\n )\n recommendations.push(\n 'Portal Error: \"Document signature value is not a valid signature of the document digest using the public key of the certificate provided.\"',\n )\n }\n\n if (certificateDigest.length === 0) {\n issues.push('DS333: Certificate digest generation failed')\n recommendations.push('CRITICAL: Verify certificate format and encoding')\n recommendations.push(\n 'Certificate must be properly base64 encoded without headers/footers',\n )\n }\n\n if (signedPropertiesDigest.length === 0) {\n issues.push('DS333: Signed properties digest generation failed')\n recommendations.push(\n 'CRITICAL: Verify signed properties structure and canonicalization',\n )\n recommendations.push(\n 'Check XML canonicalization (C14N) is applied correctly',\n )\n }\n\n // Additional DS333 checks\n try {\n const cert = new crypto.X509Certificate(certificatePem)\n\n // Verify the certificate has the required algorithms for MyInvois\n const publicKey = cert.publicKey\n const keyDetails = publicKey.asymmetricKeyDetails\n\n if (keyDetails) {\n // Check if key size is adequate for RSA (minimum 2048 bits)\n if (\n publicKey.asymmetricKeyType === 'rsa' &&\n keyDetails.modulusLength &&\n keyDetails.modulusLength < 2048\n ) {\n issues.push(\n 'DS333: RSA key size too small (minimum 2048 bits required)',\n )\n recommendations.push(\n 'CRITICAL: Generate new certificate with RSA 2048+ bits',\n )\n }\n\n // Check supported key types\n const supportedKeyTypes = ['rsa', 'ec']\n if (!supportedKeyTypes.includes(publicKey.asymmetricKeyType || '')) {\n issues.push(\n `DS333: Unsupported key type: ${publicKey.asymmetricKeyType}`,\n )\n recommendations.push(\n 'CRITICAL: Use RSA or EC key types for MyInvois compatibility',\n )\n }\n }\n\n // Test certificate format validity\n const certBuffer = Buffer.from(\n certificatePem.replace(/-----[^-]+-----/g, '').replace(/\\s/g, ''),\n 'base64',\n )\n if (certBuffer.length === 0) {\n issues.push('DS333: Certificate encoding appears invalid')\n recommendations.push(\n 'CRITICAL: Verify certificate is properly PEM encoded',\n )\n }\n } catch (error) {\n issues.push(`DS333: Certificate validation failed - ${error}`)\n recommendations.push(\n 'CRITICAL: Verify certificate format and structure are valid',\n )\n }\n\n // Validate digest formats (should be base64)\n const isValidBase64 = (str: string) => {\n try {\n return Buffer.from(str, 'base64').toString('base64') === str\n } catch {\n return false\n }\n }\n\n if (documentDigest && !isValidBase64(documentDigest)) {\n issues.push('DS333: Document digest is not valid base64 format')\n recommendations.push('Ensure digest is properly base64 encoded')\n }\n\n if (certificateDigest && !isValidBase64(certificateDigest)) {\n issues.push('DS333: Certificate digest is not valid base64 format')\n recommendations.push(\n 'Ensure certificate digest is properly base64 encoded',\n )\n }\n\n if (signedPropertiesDigest && !isValidBase64(signedPropertiesDigest)) {\n issues.push('DS333: Signed properties digest is not valid base64 format')\n recommendations.push(\n 'Ensure signed properties digest is properly base64 encoded',\n )\n }\n\n return {\n documentDigest,\n certificateDigest,\n signedPropertiesDigest,\n issues,\n recommendations,\n }\n } catch (error) {\n issues.push(`Signature analysis failed: ${error}`)\n recommendations.push('Review signature generation implementation')\n\n return {\n documentDigest: '',\n certificateDigest: '',\n signedPropertiesDigest: '',\n issues,\n recommendations,\n }\n }\n}\n\n/**\n * Comprehensive signature diagnostics\n */\nexport function diagnoseSignatureIssues(\n invoices: InvoiceV1_1[],\n certificatePem: string,\n): DiagnosticResult {\n const certificateAnalysis = analyzeCertificateForDiagnostics(certificatePem)\n const signatureAnalysis = analyzeSignatureForDiagnostics(\n invoices,\n certificatePem,\n )\n\n const certificateIssues = certificateAnalysis.issues.length\n const signatureIssues = signatureAnalysis.issues.length\n\n return {\n certificateAnalysis,\n signatureAnalysis,\n summary: {\n totalIssues: certificateIssues + signatureIssues,\n certificateIssues,\n signatureIssues,\n },\n }\n}\n\n/**\n * Prints diagnostic results in a formatted way\n */\nexport function printDiagnostics(result: DiagnosticResult): void {\n console.log('\\n🔍 MyInvois Signature Diagnostics Report')\n console.log('='.repeat(60))\n\n // Certificate Analysis\n console.log('\\n📜 CERTIFICATE ANALYSIS')\n console.log('-'.repeat(30))\n\n console.log(` Issuer: ${result.certificateAnalysis.issuerName}`)\n console.log(` Subject: ${result.certificateAnalysis.subjectName}`)\n\n if (result.certificateAnalysis.organizationIdentifier) {\n console.log(\n ` Organization ID (TIN): ${result.certificateAnalysis.organizationIdentifier}`,\n )\n }\n\n if (result.certificateAnalysis.serialNumber) {\n console.log(` Serial Number: ${result.certificateAnalysis.serialNumber}`)\n }\n\n if (result.certificateAnalysis.issues.length > 0) {\n console.log('\\n 🚨 Certificate Issues:')\n result.certificateAnalysis.issues.forEach((issue, index) => {\n console.log(` ${index + 1}. ${issue}`)\n })\n }\n\n if (result.certificateAnalysis.recommendations.length > 0) {\n console.log('\\n 💡 Certificate Recommendations:')\n result.certificateAnalysis.recommendations.forEach((rec, index) => {\n console.log(` ${index + 1}. ${rec}`)\n })\n }\n\n // Signature Analysis\n console.log('\\n🔐 SIGNATURE ANALYSIS')\n console.log('-'.repeat(30))\n\n console.log(\n ` Document Digest: ${result.signatureAnalysis.documentDigest.substring(0, 32)}...`,\n )\n console.log(\n ` Certificate Digest: ${result.signatureAnalysis.certificateDigest.substring(0, 32)}...`,\n )\n console.log(\n ` Signed Properties Digest: ${result.signatureAnalysis.signedPropertiesDigest.substring(0, 32)}...`,\n )\n\n if (result.signatureAnalysis.issues.length > 0) {\n console.log('\\n 🚨 Signature Issues:')\n result.signatureAnalysis.issues.forEach((issue, index) => {\n console.log(` ${index + 1}. ${issue}`)\n })\n }\n\n if (result.signatureAnalysis.recommendations.length > 0) {\n console.log('\\n 💡 Signature Recommendations:')\n result.signatureAnalysis.recommendations.forEach((rec, index) => {\n console.log(` ${index + 1}. ${rec}`)\n })\n }\n\n // Summary\n console.log('\\n📊 SUMMARY')\n console.log('-'.repeat(30))\n console.log(` Total Issues Found: ${result.summary.totalIssues}`)\n console.log(` Certificate Issues: ${result.summary.certificateIssues}`)\n console.log(` Signature Issues: ${result.summary.signatureIssues}`)\n\n if (result.summary.totalIssues === 0) {\n console.log('\\n ✅ No issues detected in current analysis')\n console.log(' 🎉 Certificate and signature implementation appear valid')\n } else {\n console.log('\\n ⚠️ Issues detected - review recommendations above')\n\n // Check for specific portal errors\n const hasDS311 = result.certificateAnalysis.issues.some(issue =>\n issue.includes('DS311'),\n )\n const hasDS312 = result.certificateAnalysis.issues.some(issue =>\n issue.includes('DS312'),\n )\n const hasDS326 = result.certificateAnalysis.issues.some(issue =>\n issue.includes('DS326'),\n )\n const hasDS329 = result.certificateAnalysis.issues.some(issue =>\n issue.includes('DS329'),\n )\n const hasDS333 = result.signatureAnalysis.issues.some(issue =>\n issue.includes('DS333'),\n )\n\n console.log('\\n 🎯 MYINVOIS PORTAL ERROR ANALYSIS:')\n\n if (hasDS311) {\n console.log(\n ' ❌ DS311 - TIN mismatch between certificate and submitter',\n )\n }\n\n if (hasDS312) {\n console.log(\n ' ❌ DS312 - Registration number mismatch with certificate',\n )\n }\n\n if (hasDS326) {\n console.log(' ❌ DS326 - X509IssuerName format inconsistency')\n }\n\n if (hasDS329) {\n console.log(' ❌ DS329 - Certificate trust chain validation failure')\n }\n\n if (hasDS333) {\n console.log(' ❌ DS333 - Document signature validation failure')\n }\n\n if (result.summary.certificateIssues > 0) {\n console.log('\\n 🚨 PRIMARY ACTION REQUIRED:')\n console.log(' Certificate issues must be resolved first')\n console.log(\n ' Self-generated certificates cannot pass MyInvois validation',\n )\n }\n\n if (result.summary.signatureIssues > 0) {\n console.log('\\n ⚙️ SECONDARY ACTION:')\n console.log(' Review and optimize signature implementation')\n }\n\n console.log('\\n 📋 NEXT STEPS:')\n console.log(' 1. Address BLOCKING/CRITICAL issues first')\n console.log(' 2. Test with updated certificate/implementation')\n console.log(' 3. Re-run diagnostics to verify fixes')\n console.log(' 4. Submit test document to MyInvois portal')\n }\n\n console.log('\\n' + '='.repeat(60))\n}\n"],"mappings":";;;;;;;;AAwCA,SAAS,iCACPA,gBAC2B;CAC3B,MAAMC,SAAmB,CAAE;CAC3B,MAAMC,kBAA4B,CAAE;AAEpC,KAAI;EACF,MAAM,OAAO,IAAI,eAAO,gBAAgB;EACxC,MAAM,WAAW,wCAAuB,eAAe;EAGvD,MAAM,qBAAqB,CAACC,OAAe;GACzC,MAAMC,SAAiC,CAAE;AACzC,MAAG,MAAM,KAAK,CAAC,QAAQ,UAAQ;IAC7B,MAAM,UAAU,KAAK,MAAM;AAC3B,QAAI,QAAQ,SAAS,IAAI,EAAE;KACzB,MAAM,CAAC,KAAK,GAAG,WAAW,GAAG,QAAQ,MAAM,IAAI;AAC/C,SAAI,IACF,QAAO,IAAI,MAAM,IAAI,WAAW,KAAK,IAAI,CAAC,MAA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