@ripwords/myinvois-client 0.2.3 → 0.2.5
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.
- package/dist/api/documentManagement.d.ts +2 -2
- package/dist/api/documentSubmission.d.ts +2 -2
- package/dist/api/documentSubmission.js +2 -2
- package/dist/api/documentTypeManagement.d.ts +4 -4
- package/dist/api/notificationManagement.d.ts +3 -3
- package/dist/api/platformLogin.d.ts +2 -2
- package/dist/api/taxpayerValidation.d.ts +4 -4
- package/dist/api/taxpayerValidation.js +1 -1
- package/dist/{document-BSuYbfXR.js → document-BvyYSCPx.js} +85 -1
- package/dist/{document-vDphtJTv.cjs → document-djvnrrZo.cjs} +121 -1
- package/dist/document-djvnrrZo.cjs.map +1 -0
- package/dist/{documentSubmission-BdJxIB_I.js → documentSubmission-695VhFA8.js} +1 -1
- package/dist/{documentSubmission-D5TC0MPC.cjs → documentSubmission-CK1zOsSV.cjs} +2 -2
- package/dist/{documentSubmission-D5TC0MPC.cjs.map → documentSubmission-CK1zOsSV.cjs.map} +1 -1
- package/dist/documentTypeManagement-DXRLfTsW.cjs.map +1 -1
- package/dist/{documents-zzL50wnG.d.ts → documents-Br8I8SvT.d.ts} +37 -2
- package/dist/{documents-DCOYxz61.d.cts → documents-BuH9ULyn.d.cts} +38 -3
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.js +3 -3
- package/dist/index10.cjs +16 -187
- package/dist/index10.cjs.map +1 -1
- package/dist/index12.cjs +25 -16
- package/dist/index12.cjs.map +1 -1
- package/dist/index13.cjs +24 -0
- package/dist/{index19.cjs.map → index13.cjs.map} +1 -1
- package/dist/index15.cjs +0 -29
- package/dist/index16.cjs +0 -25
- package/dist/index17.cjs +5 -0
- package/dist/index18.cjs +5 -33
- package/dist/index19.cjs +4 -23
- package/dist/index2.cjs +61 -4
- package/dist/{index8.cjs.map → index2.cjs.map} +1 -1
- package/dist/index20.cjs +3 -0
- package/dist/index21.cjs +3 -0
- package/dist/index22.cjs +5 -0
- package/dist/index25.cjs +7 -1
- package/dist/index27.cjs +1 -1
- package/dist/index28.cjs +53 -0
- package/dist/index28.cjs.map +1 -1
- package/dist/index3.cjs +531 -5
- package/dist/index3.cjs.map +1 -0
- package/dist/index4.cjs +195 -4
- package/dist/index4.cjs.map +1 -0
- package/dist/index5.cjs +0 -3
- package/dist/index6.cjs +24 -2
- package/dist/index6.cjs.map +1 -0
- package/dist/index63.cts.map +1 -1
- package/dist/index64.cts.map +1 -1
- package/dist/index66.cts.map +1 -1
- package/dist/index67.cts.map +1 -1
- package/dist/index7.cjs +0 -5
- package/dist/index70.cts.map +1 -1
- package/dist/index73.cts.map +1 -1
- package/dist/index8.cjs +0 -62
- package/dist/index9.cjs +23 -526
- package/dist/index9.cjs.map +1 -1
- package/dist/notificationManagement-C_qrFwWL.cjs.map +1 -1
- package/dist/{taxpayer-CxAVm7lJ.d.ts → taxpayer-5MlboTnW.d.ts} +1 -1
- package/dist/{taxpayer-aaXyVf7B.d.cts → taxpayer-DVjaFzJw.d.cts} +2 -2
- package/dist/{taxpayerValidation-DdeXCvPT.cjs → taxpayerValidation-CSuifcY1.cjs} +2 -15
- package/dist/taxpayerValidation-CSuifcY1.cjs.map +1 -0
- package/dist/{taxpayerValidation-DI4B6kWx.js → taxpayerValidation-DiLGJg1l.js} +1 -14
- package/dist/types/documents.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/taxpayer.d.ts +2 -2
- package/dist/utils/document.d.ts +54 -3
- package/dist/utils/document.js +2 -2
- package/dist/utils/signature-diagnostics.d.ts +2 -2
- package/dist/utils/signature-diagnostics.js +1 -1
- package/dist/utils/validation.d.ts +65 -3
- package/dist/utils/validation.js +53 -1
- package/package.json +1 -1
- package/dist/document-vDphtJTv.cjs.map +0 -1
- package/dist/index15.cjs.map +0 -1
- package/dist/index16.cjs.map +0 -1
- package/dist/index18.cjs.map +0 -1
- package/dist/taxpayerValidation-DdeXCvPT.cjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MSICCode } from "./msic-codes-CIKdPqag.cjs";
|
|
2
|
-
import { RegistrationType } from "./documents-
|
|
2
|
+
import { RegistrationType } from "./documents-BuH9ULyn.cjs";
|
|
3
3
|
|
|
4
4
|
//#region src/types/taxpayer.d.ts
|
|
5
5
|
interface TaxpayerQRCodeResponse {
|
|
@@ -32,4 +32,4 @@ interface TinSearchResponse {
|
|
|
32
32
|
}
|
|
33
33
|
//#endregion
|
|
34
34
|
export { TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse };
|
|
35
|
-
//# sourceMappingURL=taxpayer-
|
|
35
|
+
//# sourceMappingURL=taxpayer-DVjaFzJw.d.cts.map
|
|
@@ -14,20 +14,7 @@ async function tinSearch(context, params) {
|
|
|
14
14
|
const queryString = queryParams.toString();
|
|
15
15
|
try {
|
|
16
16
|
const response = await fetch(`/api/v1.0/taxpayer/search/tin?${queryString}`, { method: "GET" });
|
|
17
|
-
|
|
18
|
-
if (response.status === 400) {
|
|
19
|
-
const errorData$1 = await response.json();
|
|
20
|
-
if (debug) console.error("TIN search failed - search criteria not conclusive or invalid parameters:", errorData$1);
|
|
21
|
-
return errorData$1;
|
|
22
|
-
}
|
|
23
|
-
if (response.status === 404) {
|
|
24
|
-
const errorData$1 = await response.json();
|
|
25
|
-
if (debug) console.error("TIN search failed - no TIN found for given search criteria:", errorData$1);
|
|
26
|
-
return errorData$1;
|
|
27
|
-
}
|
|
28
|
-
const errorData = await response.json();
|
|
29
|
-
if (debug) console.error("TIN search failed with status:", response.status, errorData);
|
|
30
|
-
return errorData;
|
|
17
|
+
return await response.json();
|
|
31
18
|
} catch (error) {
|
|
32
19
|
if (debug) console.error("TIN search error:", error);
|
|
33
20
|
throw error;
|
|
@@ -70,4 +57,4 @@ Object.defineProperty(exports, 'verifyTin', {
|
|
|
70
57
|
return verifyTin;
|
|
71
58
|
}
|
|
72
59
|
});
|
|
73
|
-
//# sourceMappingURL=taxpayerValidation-
|
|
60
|
+
//# sourceMappingURL=taxpayerValidation-CSuifcY1.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taxpayerValidation-CSuifcY1.cjs","names":["context: TaxpayerContext","params: TinSearchParams","tin: string","idType: RegistrationType","idValue: string","qrCodeText: string"],"sources":["../src/api/taxpayerValidation.ts"],"sourcesContent":["import type {\n Fetch,\n RegistrationType,\n TaxpayerQRCodeResponse,\n TinSearchParams,\n TinSearchResponse,\n} from '../types'\n\ninterface TaxpayerContext {\n fetch: Fetch\n debug: boolean\n}\n\nexport async function tinSearch(\n context: TaxpayerContext,\n params: TinSearchParams,\n): Promise<TinSearchResponse> {\n const { fetch, debug } = context\n const { taxpayerName, idType, idValue } = params\n\n // Validate input parameters according to API requirements\n if (!taxpayerName && (!idType || !idValue)) {\n throw new Error(\n 'Either taxpayerName must be provided, or both idType and idValue must be provided',\n )\n }\n\n if ((idType && !idValue) || (!idType && idValue)) {\n throw new Error('idType and idValue must be provided together')\n }\n\n // Build query parameters\n const queryParams = new URLSearchParams()\n\n if (taxpayerName) {\n queryParams.append('taxpayerName', taxpayerName)\n }\n\n if (idType && idValue) {\n queryParams.append('idType', idType)\n queryParams.append('idValue', idValue)\n }\n\n const queryString = queryParams.toString()\n\n try {\n const response = await fetch(\n `/api/v1.0/taxpayer/search/tin?${queryString}`,\n {\n method: 'GET',\n },\n )\n return (await response.json()) as TinSearchResponse\n } catch (error) {\n if (debug) {\n console.error('TIN search error:', error)\n }\n throw error\n }\n}\n\nexport async function verifyTin(\n context: TaxpayerContext,\n tin: string,\n idType: RegistrationType,\n idValue: string,\n): Promise<boolean> {\n const { fetch, debug } = context\n\n try {\n const response = await fetch(\n `/api/v1.0/taxpayer/validate/${tin}?idType=${idType}&idValue=${idValue}`,\n {\n method: 'GET',\n },\n )\n\n if (response.status === 200) {\n return true\n }\n\n return false\n } catch (error) {\n if (debug) {\n console.error(error)\n }\n return false\n }\n}\n\nexport async function taxpayerQRCode(\n context: TaxpayerContext,\n qrCodeText: string,\n): Promise<TaxpayerQRCodeResponse> {\n const { fetch } = context\n\n const base64EncodedQRCodeText = Buffer.from(qrCodeText).toString('base64')\n\n const response = await fetch(\n `/api/v1.0/taxpayer/qrcodeinfo/${base64EncodedQRCodeText}`,\n )\n\n return response.json()\n}\n"],"mappings":";;AAaA,eAAsB,UACpBA,SACAC,QAC4B;CAC5B,MAAM,EAAE,OAAO,OAAO,GAAG;CACzB,MAAM,EAAE,cAAc,QAAQ,SAAS,GAAG;AAG1C,MAAK,kBAAkB,WAAW,SAChC,OAAM,IAAI,MACR;AAIJ,KAAK,WAAW,YAAc,UAAU,QACtC,OAAM,IAAI,MAAM;CAIlB,MAAM,cAAc,IAAI;AAExB,KAAI,aACF,aAAY,OAAO,gBAAgB,aAAa;AAGlD,KAAI,UAAU,SAAS;AACrB,cAAY,OAAO,UAAU,OAAO;AACpC,cAAY,OAAO,WAAW,QAAQ;CACvC;CAED,MAAM,cAAc,YAAY,UAAU;AAE1C,KAAI;EACF,MAAM,WAAW,MAAM,OACpB,gCAAgC,YAAY,GAC7C,EACE,QAAQ,MACT,EACF;AACD,SAAQ,MAAM,SAAS,MAAM;CAC9B,SAAQ,OAAO;AACd,MAAI,MACF,SAAQ,MAAM,qBAAqB,MAAM;AAE3C,QAAM;CACP;AACF;AAED,eAAsB,UACpBD,SACAE,KACAC,QACAC,SACkB;CAClB,MAAM,EAAE,OAAO,OAAO,GAAG;AAEzB,KAAI;EACF,MAAM,WAAW,MAAM,OACpB,8BAA8B,IAAI,UAAU,OAAO,WAAW,QAAQ,GACvE,EACE,QAAQ,MACT,EACF;AAED,MAAI,SAAS,WAAW,IACtB,QAAO;AAGT,SAAO;CACR,SAAQ,OAAO;AACd,MAAI,MACF,SAAQ,MAAM,MAAM;AAEtB,SAAO;CACR;AACF;AAED,eAAsB,eACpBJ,SACAK,YACiC;CACjC,MAAM,EAAE,OAAO,GAAG;CAElB,MAAM,0BAA0B,OAAO,KAAK,WAAW,CAAC,SAAS,SAAS;CAE1E,MAAM,WAAW,MAAM,OACpB,gCAAgC,wBAAwB,EAC1D;AAED,QAAO,SAAS,MAAM;AACvB"}
|
|
@@ -13,20 +13,7 @@ async function tinSearch(context, params) {
|
|
|
13
13
|
const queryString = queryParams.toString();
|
|
14
14
|
try {
|
|
15
15
|
const response = await fetch(`/api/v1.0/taxpayer/search/tin?${queryString}`, { method: "GET" });
|
|
16
|
-
|
|
17
|
-
if (response.status === 400) {
|
|
18
|
-
const errorData$1 = await response.json();
|
|
19
|
-
if (debug) console.error("TIN search failed - search criteria not conclusive or invalid parameters:", errorData$1);
|
|
20
|
-
return errorData$1;
|
|
21
|
-
}
|
|
22
|
-
if (response.status === 404) {
|
|
23
|
-
const errorData$1 = await response.json();
|
|
24
|
-
if (debug) console.error("TIN search failed - no TIN found for given search criteria:", errorData$1);
|
|
25
|
-
return errorData$1;
|
|
26
|
-
}
|
|
27
|
-
const errorData = await response.json();
|
|
28
|
-
if (debug) console.error("TIN search failed with status:", response.status, errorData);
|
|
29
|
-
return errorData;
|
|
16
|
+
return await response.json();
|
|
30
17
|
} catch (error) {
|
|
31
18
|
if (debug) console.error("TIN search error:", error);
|
|
32
19
|
throw error;
|
|
@@ -15,5 +15,5 @@ import "../9X-_XRgT2-_.js";
|
|
|
15
15
|
import "../msic-codes-CiPeemFK.js";
|
|
16
16
|
import "../tax-types-BskcyNBv.js";
|
|
17
17
|
import "../state-codes-BaGjZcA8.js";
|
|
18
|
-
import { Address, Buyer, CompleteInvoice, DocumentStatus, DocumentSummary, DocumentTypeResponse, DocumentTypeVersion, DocumentTypeVersionResponse, DocumentTypesResponse, DocumentValidationResult, DocumentValidationStepResult, FinalDocumentData, GetSubmissionResponse, InvoiceLineItem, InvoiceSubmission, InvoiceV1_1, LegalMonetaryTotal, RegistrationType, ResponseDocument, SignedInfoObject, SignedInvoiceSubmission, SignedPropertiesData, SignedPropertiesObject, SigningCredentials, StandardError, SubmissionResponse, SubmissionStatus, Supplier, TaxCategory, TaxSubtotal, TaxTotal, UBLDocument, WorkflowParameter } from "../documents-
|
|
18
|
+
import { Address, Buyer, CompleteInvoice, DocumentStatus, DocumentSummary, DocumentTypeResponse, DocumentTypeVersion, DocumentTypeVersionResponse, DocumentTypesResponse, DocumentValidationResult, DocumentValidationStepResult, FinalDocumentData, GetSubmissionResponse, InvoiceLineItem, InvoiceSubmission, InvoiceV1_1, LegalMonetaryTotal, RegistrationType, ResponseDocument, SignedInfoObject, SignedInvoiceSubmission, SignedPropertiesData, SignedPropertiesObject, SigningCredentials, StandardError, SubmissionResponse, SubmissionStatus, Supplier, TaxCategory, TaxSubtotal, TaxTotal, UBLDocument, WorkflowParameter } from "../documents-Br8I8SvT.js";
|
|
19
19
|
export { Address, Buyer, CompleteInvoice, DocumentStatus, DocumentSummary, DocumentTypeResponse, DocumentTypeVersion, DocumentTypeVersionResponse, DocumentTypesResponse, DocumentValidationResult, DocumentValidationStepResult, FinalDocumentData, GetSubmissionResponse, InvoiceLineItem, InvoiceSubmission, InvoiceV1_1, LegalMonetaryTotal, RegistrationType, ResponseDocument, SignedInfoObject, SignedInvoiceSubmission, SignedPropertiesData, SignedPropertiesObject, SigningCredentials, StandardError, SubmissionResponse, SubmissionStatus, Supplier, TaxCategory, TaxSubtotal, TaxTotal, UBLDocument, WorkflowParameter };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ import "../9X-_XRgT2-_.js";
|
|
|
15
15
|
import { MSICCode } from "../msic-codes-CiPeemFK.js";
|
|
16
16
|
import { TaxType, TaxTypeCode, TaxTypeCodeEnum } from "../tax-types-BskcyNBv.js";
|
|
17
17
|
import { State, StateCode, StateCodeEnum } from "../state-codes-BaGjZcA8.js";
|
|
18
|
-
import { Address, Buyer, CompleteInvoice, DocumentStatus, DocumentSummary, DocumentTypeResponse, DocumentTypeVersion, DocumentTypeVersionResponse, DocumentTypesResponse, DocumentValidationResult, DocumentValidationStepResult, FinalDocumentData, GetSubmissionResponse, InvoiceLineItem, InvoiceSubmission, InvoiceV1_1, LegalMonetaryTotal, RegistrationType, ResponseDocument, SignedInfoObject, SignedInvoiceSubmission, SignedPropertiesData, SignedPropertiesObject, SigningCredentials, StandardError, SubmissionResponse, SubmissionStatus, Supplier, TaxCategory, TaxSubtotal, TaxTotal, UBLDocument, WorkflowParameter } from "../documents-
|
|
18
|
+
import { Address, Buyer, CompleteInvoice, DocumentStatus, DocumentSummary, DocumentTypeResponse, DocumentTypeVersion, DocumentTypeVersionResponse, DocumentTypesResponse, DocumentValidationResult, DocumentValidationStepResult, FinalDocumentData, GetSubmissionResponse, InvoiceLineItem, InvoiceSubmission, InvoiceV1_1, LegalMonetaryTotal, RegistrationType, ResponseDocument, SignedInfoObject, SignedInvoiceSubmission, SignedPropertiesData, SignedPropertiesObject, SigningCredentials, StandardError, SubmissionResponse, SubmissionStatus, Supplier, TaxCategory, TaxSubtotal, TaxTotal, UBLDocument, WorkflowParameter } from "../documents-Br8I8SvT.js";
|
|
19
19
|
import { PaymentMode, PaymentModeCode, PaymentModeCodeEnum } from "../payment-modes-NpE3OcCV.js";
|
|
20
20
|
import "../1X-C72Wa4pk.js";
|
|
21
21
|
import "../2X-CH89y3Af.js";
|
|
@@ -55,7 +55,7 @@ import "../XX-DOA-10JW.js";
|
|
|
55
55
|
import { UnitType, UnitTypeCode } from "../unit-types-VgYXIwTT.js";
|
|
56
56
|
import { CanonicalizationMethod, Cert, CertDigest, DigestMethod, IssuerDigitalSignature, IssuerSerial, KeyInfo, QualifyingProperties, Reference, SignatureMethod, SignedInfo, SignedProperties, SignedSignatureProperties, SigningCertificate, Transform, X509Data } from "../signatures-C-nCPDqt.js";
|
|
57
57
|
import { Notification, NotificationDeliveryAttempt, NotificationMetadata, NotificationResponse, NotificationSearchParams, NotificationStatus, NotificationStatusEnum, NotificationType, NotificationTypeEnum } from "../notifications-B4l_qRj7.js";
|
|
58
|
-
import { TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse } from "../taxpayer-
|
|
58
|
+
import { TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse } from "../taxpayer-5MlboTnW.js";
|
|
59
59
|
import { Fetch } from "../utils-B3mo51Zp.js";
|
|
60
60
|
import { ClientCredentials, TokenResponse } from "../index-FTgB2nM6.js";
|
|
61
61
|
export { Address, Buyer, CanonicalizationMethod, Cert, CertDigest, Classification, ClassificationCode, ClassificationCodeEnum, ClientCredentials, CompleteInvoice, Country, CountryCode, CountryCodeEnum, CountryNameEnum, Currency, CurrencyCode, CurrencyCodeEnum, DigestMethod, DocumentStatus, DocumentSummary, DocumentTypeResponse, DocumentTypeVersion, DocumentTypeVersionResponse, DocumentTypesResponse, DocumentValidationResult, DocumentValidationStepResult, EInvoiceType, EInvoiceTypeCode, EInvoiceTypeCodeEnum, Fetch, FinalDocumentData, GetSubmissionResponse, InvoiceLineItem, InvoiceSubmission, InvoiceV1_1, IssuerDigitalSignature, IssuerSerial, KeyInfo, LegalMonetaryTotal, MSICCode, Notification, NotificationDeliveryAttempt, NotificationMetadata, NotificationResponse, NotificationSearchParams, NotificationStatus, NotificationStatusEnum, NotificationType, NotificationTypeEnum, PaymentMode, PaymentModeCode, PaymentModeCodeEnum, QualifyingProperties, Reference, RegistrationType, ResponseDocument, SignatureMethod, SignedInfo, SignedInfoObject, SignedInvoiceSubmission, SignedProperties, SignedPropertiesData, SignedPropertiesObject, SignedSignatureProperties, SigningCertificate, SigningCredentials, StandardError, State, StateCode, StateCodeEnum, SubmissionResponse, SubmissionStatus, Supplier, TaxCategory, TaxSubtotal, TaxTotal, TaxType, TaxTypeCode, TaxTypeCodeEnum, TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse, TokenResponse, Transform, UBLDocument, UnitType, UnitTypeCode, WorkflowParameter, X509Data };
|
package/dist/types/taxpayer.d.ts
CHANGED
|
@@ -15,6 +15,6 @@ import "../9X-_XRgT2-_.js";
|
|
|
15
15
|
import "../msic-codes-CiPeemFK.js";
|
|
16
16
|
import "../tax-types-BskcyNBv.js";
|
|
17
17
|
import "../state-codes-BaGjZcA8.js";
|
|
18
|
-
import "../documents-
|
|
19
|
-
import { TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse } from "../taxpayer-
|
|
18
|
+
import "../documents-Br8I8SvT.js";
|
|
19
|
+
import { TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse } from "../taxpayer-5MlboTnW.js";
|
|
20
20
|
export { TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse };
|
package/dist/utils/document.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ import "../9X-_XRgT2-_.js";
|
|
|
15
15
|
import "../msic-codes-CiPeemFK.js";
|
|
16
16
|
import "../tax-types-BskcyNBv.js";
|
|
17
17
|
import "../state-codes-BaGjZcA8.js";
|
|
18
|
-
import { CompleteInvoice, InvoiceSubmission, InvoiceV1_1, SignedInfoObject, SignedPropertiesObject, SigningCredentials, UBLDocument } from "../documents-
|
|
18
|
+
import { CompleteInvoice, InvoiceSubmission, InvoiceV1_1, SignedInfoObject, SignedPropertiesObject, SigningCredentials, UBLDocument } from "../documents-Br8I8SvT.js";
|
|
19
19
|
import "../payment-modes-NpE3OcCV.js";
|
|
20
20
|
import "../1X-C72Wa4pk.js";
|
|
21
21
|
import "../2X-CH89y3Af.js";
|
|
@@ -55,7 +55,7 @@ import "../XX-DOA-10JW.js";
|
|
|
55
55
|
import "../unit-types-VgYXIwTT.js";
|
|
56
56
|
import "../signatures-C-nCPDqt.js";
|
|
57
57
|
import "../notifications-B4l_qRj7.js";
|
|
58
|
-
import "../taxpayer-
|
|
58
|
+
import "../taxpayer-5MlboTnW.js";
|
|
59
59
|
import "../utils-B3mo51Zp.js";
|
|
60
60
|
import "../index-FTgB2nM6.js";
|
|
61
61
|
|
|
@@ -66,6 +66,18 @@ import "../index-FTgB2nM6.js";
|
|
|
66
66
|
* JSON Signature Guide: https://sdk.myinvois.hasil.gov.my/signature-creation-json/
|
|
67
67
|
*/
|
|
68
68
|
/**
|
|
69
|
+
* Determines if a line item uses fixed rate taxation
|
|
70
|
+
*/
|
|
71
|
+
declare const isFixedRateTax: (item: InvoiceV1_1["invoiceLineItems"][0]) => boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Determines if a line item uses percentage taxation
|
|
74
|
+
*/
|
|
75
|
+
declare const isPercentageTax: (item: InvoiceV1_1["invoiceLineItems"][0]) => boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Calculates expected tax amount for a line item based on its tax type
|
|
78
|
+
*/
|
|
79
|
+
declare const calculateExpectedTaxAmount: (item: InvoiceV1_1["invoiceLineItems"][0]) => number;
|
|
80
|
+
/**
|
|
69
81
|
* Helper function to recursively sort object keys for JSON canonicalization
|
|
70
82
|
*/
|
|
71
83
|
declare function sortObjectKeys(obj: unknown): unknown;
|
|
@@ -134,5 +146,44 @@ declare const createSignedInfoAndSign: (docDigest: string, propsDigest: string,
|
|
|
134
146
|
* Follows the complete MyInvois JSON signature creation process (Steps 1-7)
|
|
135
147
|
*/
|
|
136
148
|
declare const generateCompleteDocument: (invoices: InvoiceV1_1[], signingCredentials: SigningCredentials) => CompleteInvoice;
|
|
149
|
+
/**
|
|
150
|
+
* Creates a line item with percentage-based taxation (e.g., SST, GST)
|
|
151
|
+
*/
|
|
152
|
+
declare const createPercentageTaxLineItem: (params: {
|
|
153
|
+
itemClassificationCode: string;
|
|
154
|
+
itemDescription: string;
|
|
155
|
+
unitPrice: number;
|
|
156
|
+
quantity?: number;
|
|
157
|
+
taxType: string;
|
|
158
|
+
taxRate: number;
|
|
159
|
+
totalTaxableAmountPerLine?: number;
|
|
160
|
+
}) => InvoiceV1_1["invoiceLineItems"][0];
|
|
161
|
+
/**
|
|
162
|
+
* Creates a line item with fixed rate taxation (e.g., Tourism Tax)
|
|
163
|
+
*/
|
|
164
|
+
declare const createFixedRateTaxLineItem: (params: {
|
|
165
|
+
itemClassificationCode: string;
|
|
166
|
+
itemDescription: string;
|
|
167
|
+
unitPrice: number;
|
|
168
|
+
quantity?: number;
|
|
169
|
+
taxType: string;
|
|
170
|
+
taxPerUnitAmount: number;
|
|
171
|
+
baseUnitMeasure: number;
|
|
172
|
+
baseUnitMeasureCode: string;
|
|
173
|
+
totalTaxableAmountPerLine?: number;
|
|
174
|
+
}) => InvoiceV1_1["invoiceLineItems"][0];
|
|
175
|
+
/**
|
|
176
|
+
* Calculates invoice totals from line items
|
|
177
|
+
*/
|
|
178
|
+
declare const calculateInvoiceTotals: (lineItems: InvoiceV1_1["invoiceLineItems"]) => {
|
|
179
|
+
legalMonetaryTotal: {
|
|
180
|
+
taxExclusiveAmount: number;
|
|
181
|
+
taxInclusiveAmount: number;
|
|
182
|
+
payableAmount: number;
|
|
183
|
+
};
|
|
184
|
+
taxTotal: {
|
|
185
|
+
taxAmount: number;
|
|
186
|
+
};
|
|
187
|
+
};
|
|
137
188
|
//#endregion
|
|
138
|
-
export { calculateCertificateDigest, calculateDocumentDigest, calculateSignedPropertiesDigest, canonicalizeJSON, createSignedInfoAndSign, createSignedProperties, extractCertificateInfo, generateCleanInvoiceObject, generateCleanUBLDocument, generateCompleteDocument, sortObjectKeys };
|
|
189
|
+
export { calculateCertificateDigest, calculateDocumentDigest, calculateExpectedTaxAmount, calculateInvoiceTotals, calculateSignedPropertiesDigest, canonicalizeJSON, createFixedRateTaxLineItem, createPercentageTaxLineItem, createSignedInfoAndSign, createSignedProperties, extractCertificateInfo, generateCleanInvoiceObject, generateCleanUBLDocument, generateCompleteDocument, isFixedRateTax, isPercentageTax, sortObjectKeys };
|
package/dist/utils/document.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { calculateCertificateDigest, calculateDocumentDigest, calculateSignedPropertiesDigest, canonicalizeJSON, createSignedInfoAndSign, createSignedProperties, extractCertificateInfo, generateCleanInvoiceObject, generateCleanUBLDocument, generateCompleteDocument, sortObjectKeys } from "../document-
|
|
1
|
+
import { calculateCertificateDigest, calculateDocumentDigest, calculateExpectedTaxAmount, calculateInvoiceTotals, calculateSignedPropertiesDigest, canonicalizeJSON, createFixedRateTaxLineItem, createPercentageTaxLineItem, createSignedInfoAndSign, createSignedProperties, extractCertificateInfo, generateCleanInvoiceObject, generateCleanUBLDocument, generateCompleteDocument, isFixedRateTax, isPercentageTax, sortObjectKeys } from "../document-BvyYSCPx.js";
|
|
2
2
|
|
|
3
|
-
export { calculateCertificateDigest, calculateDocumentDigest, calculateSignedPropertiesDigest, canonicalizeJSON, createSignedInfoAndSign, createSignedProperties, extractCertificateInfo, generateCleanInvoiceObject, generateCleanUBLDocument, generateCompleteDocument, sortObjectKeys };
|
|
3
|
+
export { calculateCertificateDigest, calculateDocumentDigest, calculateExpectedTaxAmount, calculateInvoiceTotals, calculateSignedPropertiesDigest, canonicalizeJSON, createFixedRateTaxLineItem, createPercentageTaxLineItem, createSignedInfoAndSign, createSignedProperties, extractCertificateInfo, generateCleanInvoiceObject, generateCleanUBLDocument, generateCompleteDocument, isFixedRateTax, isPercentageTax, sortObjectKeys };
|
|
@@ -15,7 +15,7 @@ import "../9X-_XRgT2-_.js";
|
|
|
15
15
|
import "../msic-codes-CiPeemFK.js";
|
|
16
16
|
import "../tax-types-BskcyNBv.js";
|
|
17
17
|
import "../state-codes-BaGjZcA8.js";
|
|
18
|
-
import { InvoiceV1_1 } from "../documents-
|
|
18
|
+
import { InvoiceV1_1 } from "../documents-Br8I8SvT.js";
|
|
19
19
|
import "../payment-modes-NpE3OcCV.js";
|
|
20
20
|
import "../1X-C72Wa4pk.js";
|
|
21
21
|
import "../2X-CH89y3Af.js";
|
|
@@ -55,7 +55,7 @@ import "../XX-DOA-10JW.js";
|
|
|
55
55
|
import "../unit-types-VgYXIwTT.js";
|
|
56
56
|
import "../signatures-C-nCPDqt.js";
|
|
57
57
|
import "../notifications-B4l_qRj7.js";
|
|
58
|
-
import "../taxpayer-
|
|
58
|
+
import "../taxpayer-5MlboTnW.js";
|
|
59
59
|
import "../utils-B3mo51Zp.js";
|
|
60
60
|
import "../index-FTgB2nM6.js";
|
|
61
61
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { calculateCertificateDigest, calculateDocumentDigest, calculateSignedPropertiesDigest, createSignedProperties, extractCertificateInfo } from "../document-
|
|
1
|
+
import { calculateCertificateDigest, calculateDocumentDigest, calculateSignedPropertiesDigest, createSignedProperties, extractCertificateInfo } from "../document-BvyYSCPx.js";
|
|
2
2
|
import crypto from "crypto";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/signature-diagnostics.ts
|
|
@@ -1,7 +1,65 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "../classification-codes-B1D5xbq5.js";
|
|
2
|
+
import "../country-code-D42kAyNH.js";
|
|
3
|
+
import "../currencies-CDveO_yz.js";
|
|
4
|
+
import "../e-invoice-BxNC6V_j.js";
|
|
5
|
+
import "../0X-DZnB0al0.js";
|
|
6
|
+
import "../1X-Dg5J6Bfg.js";
|
|
7
|
+
import "../2X-D_qwTeDT.js";
|
|
8
|
+
import "../3X-BJHYxgxa.js";
|
|
9
|
+
import "../4X-BbZgoRHO.js";
|
|
10
|
+
import "../5X-oQRBnO0f.js";
|
|
11
|
+
import "../6X-B9I2XJa4.js";
|
|
12
|
+
import "../7X-Ckv9bbzG.js";
|
|
13
|
+
import "../8X-C37BJTl6.js";
|
|
14
|
+
import "../9X-_XRgT2-_.js";
|
|
15
|
+
import "../msic-codes-CiPeemFK.js";
|
|
16
|
+
import "../tax-types-BskcyNBv.js";
|
|
17
|
+
import "../state-codes-BaGjZcA8.js";
|
|
18
|
+
import { InvoiceLineItem, InvoiceV1_1 } from "../documents-Br8I8SvT.js";
|
|
19
|
+
import "../payment-modes-NpE3OcCV.js";
|
|
20
|
+
import "../1X-C72Wa4pk.js";
|
|
21
|
+
import "../2X-CH89y3Af.js";
|
|
22
|
+
import "../3X-DryrwYRf.js";
|
|
23
|
+
import "../4X-BPMLRoDv.js";
|
|
24
|
+
import "../5X-Bv7M6KyG.js";
|
|
25
|
+
import "../6X-ZeZ8OB57.js";
|
|
26
|
+
import "../7X-Dvw2Z2VN.js";
|
|
27
|
+
import "../8X-BkgoX8dg.js";
|
|
28
|
+
import "../9X-Du0e44cq.js";
|
|
29
|
+
import "../AX-BSPLpkVT.js";
|
|
30
|
+
import "../BX-u4yMaIkz.js";
|
|
31
|
+
import "../CX-BKZG0pVE.js";
|
|
32
|
+
import "../DX-CwA9WJAf.js";
|
|
33
|
+
import "../EX-BRNu1Ooi.js";
|
|
34
|
+
import "../FX-DBxjq6xY.js";
|
|
35
|
+
import "../GX-B3CvWNrP.js";
|
|
36
|
+
import "../HX-D7FABgTv.js";
|
|
37
|
+
import "../IX-D3ZknsAB.js";
|
|
38
|
+
import "../JX-BRaZM3Gc.js";
|
|
39
|
+
import "../KX-B1K0OWoi.js";
|
|
40
|
+
import "../LX-CKRefinL.js";
|
|
41
|
+
import "../MX-DKmaeO9r.js";
|
|
42
|
+
import "../NX-CJL2Gn1U.js";
|
|
43
|
+
import "../OX-Do2ap5v_.js";
|
|
44
|
+
import "../PX-_DOr_rm9.js";
|
|
45
|
+
import "../QX-HlXLkIki.js";
|
|
46
|
+
import "../RX-DVPGOVES.js";
|
|
47
|
+
import "../SX-OGT3qwlS.js";
|
|
48
|
+
import "../TX-cPDINmZ5.js";
|
|
49
|
+
import "../UX-Be3sqvPV.js";
|
|
50
|
+
import "../VX-CoEuBNDK.js";
|
|
51
|
+
import "../WX-DMvw__jH.js";
|
|
52
|
+
import "../YX-F34sJ7Ik.js";
|
|
53
|
+
import "../ZX-CDQOfsHh.js";
|
|
54
|
+
import "../XX-DOA-10JW.js";
|
|
55
|
+
import "../unit-types-VgYXIwTT.js";
|
|
56
|
+
import "../signatures-C-nCPDqt.js";
|
|
57
|
+
import "../notifications-B4l_qRj7.js";
|
|
58
|
+
import "../taxpayer-5MlboTnW.js";
|
|
59
|
+
import "../utils-B3mo51Zp.js";
|
|
60
|
+
import "../index-FTgB2nM6.js";
|
|
2
61
|
|
|
3
62
|
//#region src/utils/validation.d.ts
|
|
4
|
-
|
|
5
63
|
/**
|
|
6
64
|
* MyInvois Invoice Validation Utilities
|
|
7
65
|
*
|
|
@@ -35,6 +93,10 @@ declare const validateContactNumber: (contactNumber: string) => ValidationError[
|
|
|
35
93
|
*/
|
|
36
94
|
declare const validateMonetaryAmount: (amount: number, fieldName: string, maxDigits?: number, maxDecimals?: number) => ValidationError[];
|
|
37
95
|
/**
|
|
96
|
+
* Validates line item tax calculation consistency for both fixed rate and percentage taxation
|
|
97
|
+
*/
|
|
98
|
+
declare const validateLineItemTax: (item: InvoiceLineItem, index: number) => ValidationError[];
|
|
99
|
+
/**
|
|
38
100
|
* Validates tax calculation consistency
|
|
39
101
|
*/
|
|
40
102
|
declare const validateTaxCalculations: (invoice: InvoiceV1_1) => ValidationError[];
|
|
@@ -43,4 +105,4 @@ declare const validateTaxCalculations: (invoice: InvoiceV1_1) => ValidationError
|
|
|
43
105
|
*/
|
|
44
106
|
declare const validateInvoice: (invoice: InvoiceV1_1) => ValidationResult;
|
|
45
107
|
//#endregion
|
|
46
|
-
export { ValidationError, ValidationResult, ValidationWarning, validateContactNumber, validateInvoice, validateMonetaryAmount, validateTIN, validateTaxCalculations };
|
|
108
|
+
export { ValidationError, ValidationResult, ValidationWarning, validateContactNumber, validateInvoice, validateLineItemTax, validateMonetaryAmount, validateTIN, validateTaxCalculations };
|
package/dist/utils/validation.js
CHANGED
|
@@ -82,10 +82,62 @@ const validateMonetaryAmount = (amount, fieldName, maxDigits = 18, maxDecimals =
|
|
|
82
82
|
return errors;
|
|
83
83
|
};
|
|
84
84
|
/**
|
|
85
|
+
* Validates line item tax calculation consistency for both fixed rate and percentage taxation
|
|
86
|
+
*/
|
|
87
|
+
const validateLineItemTax = (item, index) => {
|
|
88
|
+
const errors = [];
|
|
89
|
+
const tolerance = .01;
|
|
90
|
+
const hasFixedRate = item.taxPerUnitAmount !== void 0 && item.baseUnitMeasure !== void 0;
|
|
91
|
+
const hasPercentageRate = item.taxRate !== void 0;
|
|
92
|
+
if (!hasFixedRate && !hasPercentageRate) {
|
|
93
|
+
errors.push({
|
|
94
|
+
field: `lineItem[${index}]`,
|
|
95
|
+
code: "TAX_METHOD_MISSING",
|
|
96
|
+
message: `Line item ${index + 1} must specify either taxRate (for percentage) or taxPerUnitAmount + baseUnitMeasure (for fixed rate)`,
|
|
97
|
+
severity: "error"
|
|
98
|
+
});
|
|
99
|
+
return errors;
|
|
100
|
+
}
|
|
101
|
+
if (hasFixedRate && hasPercentageRate) errors.push({
|
|
102
|
+
field: `lineItem[${index}]`,
|
|
103
|
+
code: "TAX_METHOD_CONFLICT",
|
|
104
|
+
message: `Line item ${index + 1} cannot have both percentage and fixed rate tax methods`,
|
|
105
|
+
severity: "error"
|
|
106
|
+
});
|
|
107
|
+
if (hasFixedRate) {
|
|
108
|
+
if (item.baseUnitMeasureCode === void 0) errors.push({
|
|
109
|
+
field: `lineItem[${index}].baseUnitMeasureCode`,
|
|
110
|
+
code: "UNIT_CODE_MISSING",
|
|
111
|
+
message: `Line item ${index + 1} with fixed rate tax must specify baseUnitMeasureCode`,
|
|
112
|
+
severity: "error"
|
|
113
|
+
});
|
|
114
|
+
const expectedTaxAmount = item.taxPerUnitAmount * item.baseUnitMeasure;
|
|
115
|
+
if (Math.abs(item.taxAmount - expectedTaxAmount) > tolerance) errors.push({
|
|
116
|
+
field: `lineItem[${index}].taxAmount`,
|
|
117
|
+
code: "FIXED_TAX_CALCULATION_MISMATCH",
|
|
118
|
+
message: `Line item ${index + 1} tax amount (${item.taxAmount}) doesn't match fixed rate calculation (${item.taxPerUnitAmount} × ${item.baseUnitMeasure} = ${expectedTaxAmount})`,
|
|
119
|
+
severity: "error"
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
if (hasPercentageRate && !hasFixedRate) {
|
|
123
|
+
const expectedTaxAmount = item.totalTaxableAmountPerLine * item.taxRate / 100;
|
|
124
|
+
if (Math.abs(item.taxAmount - expectedTaxAmount) > tolerance) errors.push({
|
|
125
|
+
field: `lineItem[${index}].taxAmount`,
|
|
126
|
+
code: "PERCENTAGE_TAX_CALCULATION_MISMATCH",
|
|
127
|
+
message: `Line item ${index + 1} tax amount (${item.taxAmount}) doesn't match percentage calculation (${item.totalTaxableAmountPerLine} × ${item.taxRate}% = ${expectedTaxAmount})`,
|
|
128
|
+
severity: "error"
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
return errors;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
85
134
|
* Validates tax calculation consistency
|
|
86
135
|
*/
|
|
87
136
|
const validateTaxCalculations = (invoice) => {
|
|
88
137
|
const errors = [];
|
|
138
|
+
invoice.invoiceLineItems.forEach((item, index) => {
|
|
139
|
+
errors.push(...validateLineItemTax(item, index));
|
|
140
|
+
});
|
|
89
141
|
const expectedTaxExclusive = invoice.invoiceLineItems.reduce((sum, item) => sum + item.totalTaxableAmountPerLine, 0);
|
|
90
142
|
const expectedTaxAmount = invoice.invoiceLineItems.reduce((sum, item) => sum + item.taxAmount, 0);
|
|
91
143
|
const tolerance = .01;
|
|
@@ -131,4 +183,4 @@ const validateInvoice = (invoice) => {
|
|
|
131
183
|
};
|
|
132
184
|
|
|
133
185
|
//#endregion
|
|
134
|
-
export { validateContactNumber, validateInvoice, validateMonetaryAmount, validateTIN, validateTaxCalculations };
|
|
186
|
+
export { validateContactNumber, validateInvoice, validateLineItemTax, validateMonetaryAmount, validateTIN, validateTaxCalculations };
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"document-vDphtJTv.cjs","names":["obj: unknown","sortedObj: Record<string, unknown>","invoice: InvoiceV1_1","invoices: InvoiceV1_1[]","invoice: any","certificatePem: string","X509Certificate","dn: string","serialHex: string","error: unknown","certificateDigest: string","signingTime: string","issuerName: string","serialNumber: string","signedProperties: SignedPropertiesObject","docDigest: string","propsDigest: string","privateKeyPem: string","signingCredentials: SigningCredentials"],"sources":["../src/utils/document.ts"],"sourcesContent":["import crypto, { X509Certificate } from 'crypto'\nimport {\n InvoiceSubmission,\n InvoiceV1_1,\n SigningCredentials,\n SignedPropertiesObject,\n UBLDocument,\n CompleteInvoice,\n SignedInfoObject,\n} from '../types'\n\n/**\n * MyInvois v1.1 Document Generation and Signing Utilities\n * Strictly follows: https://sdk.myinvois.hasil.gov.my/documents/invoice-v1-1\n * JSON Signature Guide: https://sdk.myinvois.hasil.gov.my/signature-creation-json/\n */\n\n/**\n * Helper function to recursively sort object keys for JSON canonicalization\n */\nexport function sortObjectKeys(obj: unknown): unknown {\n if (obj === null || typeof obj !== 'object') {\n return obj\n }\n\n if (Array.isArray(obj)) {\n return obj.map(sortObjectKeys)\n }\n\n const sortedObj: Record<string, unknown> = {}\n const keys = Object.keys(obj as Record<string, unknown>).sort()\n\n for (const key of keys) {\n sortedObj[key] = sortObjectKeys((obj as Record<string, unknown>)[key])\n }\n\n return sortedObj\n}\n\n/**\n * Enhanced canonicalization following MyInvois specification exactly\n * Key changes: ensure consistent ordering and formatting\n */\nexport const canonicalizeJSON = (obj: unknown): string => {\n const sortedObj = sortObjectKeys(obj)\n // Use compact JSON with no extra whitespace\n return JSON.stringify(sortedObj, null, 0)\n}\n\n/**\n * Generates a clean invoice object following MyInvois v1.1 specification exactly\n * This is the base invoice structure WITHOUT signature elements (for hash calculation)\n *\n * Key requirements from working documents:\n * - All mandatory fields must be present\n * - Many optional fields must be present even if empty\n * - Specific field ordering and structure\n * - Correct listID values (e.g., \"3166-1\" not \"ISO3166-1\")\n */\nexport const generateCleanInvoiceObject = (\n invoice: InvoiceV1_1,\n): InvoiceSubmission => {\n return {\n // === MANDATORY CORE FIELDS ===\n ID: [{ _: invoice.eInvoiceCodeOrNumber }],\n IssueDate: [{ _: invoice.eInvoiceDate }],\n IssueTime: [{ _: invoice.eInvoiceTime }],\n InvoiceTypeCode: [\n {\n _: invoice.eInvoiceTypeCode,\n listVersionID: invoice.eInvoiceVersion || '1.1',\n },\n ],\n DocumentCurrencyCode: [{ _: invoice.invoiceCurrencyCode }],\n\n // === SUPPLIER PARTY (AccountingSupplierParty) ===\n AccountingSupplierParty: [\n {\n Party: [\n {\n // Industry Classification - required field\n IndustryClassificationCode: [\n {\n _: invoice.supplier.industryClassificationCode,\n name: invoice.supplier.industryClassificationDescription,\n },\n ],\n\n // Party Identifications\n PartyIdentification: [\n {\n ID: [\n {\n _: invoice.supplier.tin,\n schemeID: 'TIN',\n },\n ],\n },\n {\n ID: [\n {\n _: invoice.supplier.registrationNumber,\n schemeID: invoice.supplier.registrationType || 'NRIC',\n },\n ],\n },\n ],\n\n // Postal Address - FIXED listID format\n PostalAddress: [\n {\n CityName: [{ _: invoice.supplier.address.cityName }],\n CountrySubentityCode: [{ _: invoice.supplier.address.state }],\n AddressLine: [\n {\n Line: [{ _: invoice.supplier.address.addressLine0 }],\n },\n ],\n Country: [\n {\n IdentificationCode: [\n {\n _: invoice.supplier.address.country || 'MYS',\n listID: '3166-1', // FIXED: was \"ISO3166-1\"\n listAgencyID: 'ISO',\n },\n ],\n },\n ],\n },\n ],\n\n // Party Legal Entity\n PartyLegalEntity: [\n {\n RegistrationName: [{ _: invoice.supplier.name }],\n },\n ],\n\n // Contact Information\n Contact: [\n {\n Telephone: [{ _: invoice.supplier.contactNumber || '' }],\n },\n ],\n },\n ],\n },\n ],\n\n // === BUYER PARTY (AccountingCustomerParty) ===\n AccountingCustomerParty: [\n {\n Party: [\n {\n // Party Identifications\n PartyIdentification: [\n {\n ID: [\n {\n _: invoice.buyer.tin,\n schemeID: 'TIN',\n },\n ],\n },\n {\n ID: [\n {\n _: invoice.buyer.registrationNumber,\n schemeID: invoice.buyer.registrationType || 'NRIC',\n },\n ],\n },\n {\n ID: [\n {\n _: invoice.buyer.sstRegistrationNumber || 'NA',\n schemeID: 'SST',\n },\n ],\n },\n ],\n\n // Postal Address - FIXED listID format\n PostalAddress: [\n {\n CityName: [{ _: invoice.buyer.address.cityName }],\n CountrySubentityCode: [{ _: invoice.buyer.address.state }],\n AddressLine: [\n {\n Line: [{ _: invoice.buyer.address.addressLine0 }],\n },\n ],\n Country: [\n {\n IdentificationCode: [\n {\n _: invoice.buyer.address.country || 'MYS',\n listID: '3166-1', // FIXED: was \"ISO3166-1\"\n listAgencyID: 'ISO',\n },\n ],\n },\n ],\n },\n ],\n\n // Party Legal Entity\n PartyLegalEntity: [\n {\n RegistrationName: [{ _: invoice.buyer.name }],\n },\n ],\n\n // Contact Information\n Contact: [\n {\n Telephone: [{ _: invoice.buyer.contactNumber || '' }],\n },\n ],\n },\n ],\n },\n ],\n\n // === TAX TOTAL ===\n TaxTotal: [\n {\n TaxAmount: [\n {\n _: invoice.taxTotal.taxAmount,\n currencyID: invoice.invoiceCurrencyCode,\n },\n ],\n TaxSubtotal: [\n // Generate basic tax subtotal from invoice line items\n {\n TaxableAmount: [\n {\n _: invoice.legalMonetaryTotal.taxExclusiveAmount,\n currencyID: invoice.invoiceCurrencyCode,\n },\n ],\n TaxAmount: [\n {\n _: invoice.taxTotal.taxAmount,\n currencyID: invoice.invoiceCurrencyCode,\n },\n ],\n TaxCategory: [\n {\n ID: [{ _: invoice.invoiceLineItems[0]?.taxType || '01' }],\n TaxScheme: [\n {\n ID: [\n {\n _: 'OTH',\n schemeAgencyID: '6',\n schemeID: 'UN/ECE 5153',\n },\n ],\n },\n ],\n },\n ],\n },\n ],\n },\n ],\n\n // === LEGAL MONETARY TOTAL ===\n LegalMonetaryTotal: [\n {\n LineExtensionAmount: [\n {\n _: invoice.legalMonetaryTotal.taxExclusiveAmount,\n currencyID: invoice.invoiceCurrencyCode,\n },\n ],\n TaxExclusiveAmount: [\n {\n _: invoice.legalMonetaryTotal.taxExclusiveAmount,\n currencyID: invoice.invoiceCurrencyCode,\n },\n ],\n TaxInclusiveAmount: [\n {\n _: invoice.legalMonetaryTotal.taxInclusiveAmount,\n currencyID: invoice.invoiceCurrencyCode,\n },\n ],\n PayableAmount: [\n {\n _: invoice.legalMonetaryTotal.payableAmount,\n currencyID: invoice.invoiceCurrencyCode,\n },\n ],\n },\n ],\n\n // === INVOICE LINES ===\n InvoiceLine: invoice.invoiceLineItems.map((item, index) => ({\n ID: [{ _: (index + 1).toString() }],\n\n // Item Information\n Item: [\n {\n CommodityClassification: [\n {\n ItemClassificationCode: [\n {\n _: item.itemClassificationCode,\n listID: 'CLASS',\n },\n ],\n },\n ],\n Description: [{ _: item.itemDescription }],\n },\n ],\n\n ItemPriceExtension: [\n {\n Amount: [\n {\n _: item.totalTaxableAmountPerLine,\n currencyID: invoice.invoiceCurrencyCode,\n },\n ],\n },\n ],\n\n LineExtensionAmount: [\n {\n _: item.totalTaxableAmountPerLine,\n currencyID: invoice.invoiceCurrencyCode,\n },\n ],\n\n // Price Information\n Price: [\n {\n PriceAmount: [\n {\n _: item.unitPrice,\n currencyID: invoice.invoiceCurrencyCode,\n },\n ],\n },\n ],\n\n // Tax Information for line\n TaxTotal: [\n {\n TaxAmount: [\n {\n _: item.taxAmount,\n currencyID: invoice.invoiceCurrencyCode,\n },\n ],\n TaxSubtotal: [\n {\n TaxableAmount: [\n {\n _: item.totalTaxableAmountPerLine,\n currencyID: invoice.invoiceCurrencyCode,\n },\n ],\n TaxAmount: [\n {\n _: item.taxAmount,\n currencyID: invoice.invoiceCurrencyCode,\n },\n ],\n TaxCategory: [\n {\n ID: [{ _: item.taxType }],\n TaxScheme: [\n {\n ID: [\n {\n _: 'OTH',\n schemeAgencyID: '6',\n schemeID: 'UN/ECE 5153',\n },\n ],\n },\n ],\n },\n ],\n },\n ],\n },\n ],\n })),\n\n // === TAX EXCHANGE RATE (mandatory where applicable) ===\n TaxExchangeRate: invoice.currencyExchangeRate\n ? [\n {\n SourceCurrencyCode: [\n {\n _: invoice.invoiceCurrencyCode,\n },\n ],\n TargetCurrencyCode: [\n {\n _: 'MYR',\n },\n ],\n CalculationRate: [\n {\n _: invoice.currencyExchangeRate,\n },\n ],\n },\n ]\n : undefined,\n }\n}\n\n/**\n * Generates the complete UBL document structure with namespace declarations\n */\nexport const generateCleanUBLDocument = (\n invoices: InvoiceV1_1[],\n): UBLDocument => {\n return {\n _D: 'urn:oasis:names:specification:ubl:schema:xsd:Invoice-2',\n _A: 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2',\n _B: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2',\n Invoice: invoices.map(generateCleanInvoiceObject),\n }\n}\n\n/**\n * Step 2: Calculate Document Digest\n * FIXED: Remove UBLExtensions and Signature before hashing (DS322)\n * Based on working implementation pattern\n */\nexport const calculateDocumentDigest = (invoices: InvoiceV1_1[]): string => {\n // Generate clean UBL document structure\n const cleanDocument = generateCleanUBLDocument(invoices)\n\n // CRITICAL FIX: Remove UBLExtensions and Signature from each invoice before hashing\n const documentForHashing = JSON.parse(JSON.stringify(cleanDocument))\n if (documentForHashing.Invoice && Array.isArray(documentForHashing.Invoice)) {\n documentForHashing.Invoice.forEach((invoice: any) => {\n delete invoice.UBLExtensions\n delete invoice.Signature\n })\n }\n\n // Convert to string for hashing (no canonicalization - use direct JSON.stringify)\n const documentString = JSON.stringify(documentForHashing)\n\n // Calculate SHA-256 hash\n const hash = crypto.createHash('sha256')\n hash.update(documentString, 'utf8')\n\n // Return as Base64 (DocDigest)\n return hash.digest('base64')\n}\n\n/**\n * Step 4: Calculate Certificate Digest\n * Enhanced to handle certificate content properly\n */\nexport const calculateCertificateDigest = (certificatePem: string): string => {\n // Extract certificate content (Base64 without PEM headers/footers)\n const certificateContent = certificatePem\n .replace(/-----BEGIN CERTIFICATE-----/g, '')\n .replace(/-----END CERTIFICATE-----/g, '')\n .replace(/\\s+/g, '') // Remove all whitespace\n\n // Convert Base64 to binary\n const certificateBinary = Buffer.from(certificateContent, 'base64')\n\n // Calculate SHA-256 hash of binary content\n const hash = crypto.createHash('sha256')\n hash.update(certificateBinary)\n\n // Return as Base64\n return hash.digest('base64')\n}\n\n/**\n * Enhanced certificate info extraction with better error handling\n * FIXED: Normalize issuer name format to match MyInvois expectations (DS326)\n */\nexport const extractCertificateInfo = (\n certificatePem: string,\n): {\n issuerName: string\n serialNumber: string\n subjectName: string\n} => {\n try {\n const cert = new X509Certificate(certificatePem)\n\n // Extract serial number and convert to decimal string\n const serialNumberHex = cert.serialNumber\n\n // ENHANCED: Normalize distinguished name format (DS326)\n // Ensures MyInvois portal compatibility for X509IssuerName matching\n const normalizeDistinguishedName = (dn: string): string => {\n // Convert multi-line format to comma-separated RFC2253 format\n const normalized = dn\n .split('\\n')\n .map(line => line.trim())\n .filter(line => line.length > 0)\n .join(', ')\n\n // MyInvois-specific normalization to prevent DS326 errors\n return normalized\n .replace(/\\s*=\\s*/g, '=') // Remove spaces around equals (CRITICAL for portal)\n .replace(/,\\s+/g, ', ') // Ensure single space after commas\n .replace(/\\r/g, '') // Remove any carriage returns\n .replace(/\\s{2,}/g, ' ') // Replace multiple spaces with single space\n .trim() // Remove leading/trailing whitespace\n }\n\n // Enhanced serial number formatting\n const formatSerialNumber = (serialHex: string): string => {\n // Convert hex to decimal and ensure it's a string\n const decimal = BigInt('0x' + serialHex).toString()\n return decimal\n }\n\n return {\n issuerName: normalizeDistinguishedName(cert.issuer),\n serialNumber: formatSerialNumber(serialNumberHex),\n subjectName: normalizeDistinguishedName(cert.subject),\n }\n } catch (error: unknown) {\n throw new Error(\n `Failed to extract certificate info: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n}\n\n/**\n * Step 5: Create SignedProperties with enhanced structure\n * FIXED: Simplified structure to match MyInvois expectations (DS320)\n * Following MyInvois JSON signature specification exactly\n */\nexport const createSignedProperties = (\n certificateDigest: string,\n signingTime: string,\n issuerName: string,\n serialNumber: string,\n): SignedPropertiesObject => {\n return {\n SignedProperties: [\n {\n Id: 'id-xades-signed-props',\n SignedSignatureProperties: [\n {\n SigningTime: [{ _: signingTime }],\n SigningCertificate: [\n {\n Cert: [\n {\n CertDigest: [\n {\n DigestMethod: [\n {\n Algorithm:\n 'http://www.w3.org/2001/04/xmlenc#sha256',\n },\n ],\n DigestValue: [{ _: certificateDigest }],\n },\n ],\n IssuerSerial: [\n {\n X509IssuerName: [{ _: issuerName }],\n X509SerialNumber: [{ _: serialNumber }],\n },\n ],\n },\n ],\n },\n ],\n },\n ],\n },\n ],\n }\n}\n\n/**\n * Step 6: Calculate SignedProperties Digest\n * FIXED: Add Target wrapper and use direct JSON stringify (DS320)\n * Based on working implementation pattern\n */\nexport const calculateSignedPropertiesDigest = (\n signedProperties: SignedPropertiesObject,\n): string => {\n // CRITICAL FIX: Wrap with Target as per working implementation\n const signedPropertiesWithTarget = {\n Target: 'signature',\n SignedProperties: signedProperties.SignedProperties,\n }\n\n // Convert to string for hashing (no canonicalization - use direct JSON.stringify)\n const signedPropertiesString = JSON.stringify(signedPropertiesWithTarget)\n\n // Calculate SHA-256 hash\n const hash = crypto.createHash('sha256')\n hash.update(signedPropertiesString, 'utf8')\n\n // Return as Base64 (PropsDigest)\n return hash.digest('base64')\n}\n\n/**\n * Step 3: Create SignedInfo and calculate signature\n * Enhanced with better structure and signature generation\n */\nexport const createSignedInfoAndSign = (\n docDigest: string,\n propsDigest: string,\n privateKeyPem: string,\n): { signedInfo: SignedInfoObject; signatureValue: string } => {\n // Create SignedInfo structure following specification exactly\n const signedInfo = {\n CanonicalizationMethod: [\n {\n _: '',\n Algorithm: 'http://www.w3.org/2006/12/xml-c14n11',\n },\n ],\n SignatureMethod: [\n {\n _: '',\n Algorithm: 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256',\n },\n ],\n Reference: [\n {\n Id: 'id-doc-signed-data',\n Type: '',\n URI: '',\n DigestMethod: [\n {\n _: '',\n Algorithm: 'http://www.w3.org/2001/04/xmlenc#sha256',\n },\n ],\n DigestValue: [{ _: docDigest }],\n },\n {\n Id: 'id-xades-signed-props',\n Type: 'http://uri.etsi.org/01903/v1.3.2#SignedProperties',\n URI: '#id-xades-signed-props',\n DigestMethod: [\n {\n _: '',\n Algorithm: 'http://www.w3.org/2001/04/xmlenc#sha256',\n },\n ],\n DigestValue: [{ _: propsDigest }],\n },\n ],\n }\n\n // FIXED: Use direct JSON.stringify instead of canonicalization (DS333)\n // Based on working implementation pattern\n const signedInfoString = JSON.stringify(signedInfo)\n\n // Sign with RSA-SHA256 directly (RSA-SHA256 handles hashing internally)\n // FIXED: Removed double-hashing bug that was causing DS333 errors\n try {\n const signer = crypto.createSign('RSA-SHA256')\n signer.update(signedInfoString, 'utf8')\n const signatureValue = signer.sign(privateKeyPem, 'base64')\n\n return { signedInfo, signatureValue }\n } catch (error) {\n throw new Error(\n `Signature generation failed: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n}\n\n/**\n * Complete document generation with signatures\n * Follows the complete MyInvois JSON signature creation process (Steps 1-7)\n */\nexport const generateCompleteDocument = (\n invoices: InvoiceV1_1[],\n signingCredentials: SigningCredentials,\n): CompleteInvoice => {\n try {\n // Step 1: Generate clean document (done in calculateDocumentDigest)\n // Step 2: Calculate document digest\n const docDigest = calculateDocumentDigest(invoices)\n\n // Generate signing time in proper ISO format\n const signingTime = new Date().toISOString()\n\n // Extract certificate information (enhanced)\n const certInfo = extractCertificateInfo(signingCredentials.certificatePem)\n\n // Step 4: Calculate certificate digest\n const certificateDigest = calculateCertificateDigest(\n signingCredentials.certificatePem,\n )\n\n // Step 5: Create SignedProperties using extracted cert info\n const signedProperties = createSignedProperties(\n certificateDigest,\n signingTime,\n certInfo.issuerName,\n certInfo.serialNumber,\n )\n\n // Step 6: Calculate SignedProperties digest\n const propsDigest = calculateSignedPropertiesDigest(signedProperties)\n\n // Step 3: Create SignedInfo and generate signature\n const { signedInfo, signatureValue } = createSignedInfoAndSign(\n docDigest,\n propsDigest,\n signingCredentials.privateKeyPem,\n )\n\n // Extract certificate content (Base64 without PEM headers)\n const certificate = signingCredentials.certificatePem\n .replace(/-----BEGIN CERTIFICATE-----/g, '')\n .replace(/-----END CERTIFICATE-----/g, '')\n .replace(/\\s+/g, '')\n\n // Step 7: Create final signed document\n const signedInvoices = invoices.map(invoice => {\n const cleanInvoice = generateCleanInvoiceObject(invoice)\n\n return {\n ...cleanInvoice,\n\n // Add UBLExtensions with complete signature structure\n UBLExtensions: [\n {\n UBLExtension: [\n {\n ExtensionURI: [\n {\n _: 'urn:oasis:names:specification:ubl:dsig:enveloped:xades',\n },\n ],\n ExtensionContent: [\n {\n UBLDocumentSignatures: [\n {\n SignatureInformation: [\n {\n ID: [\n {\n _: 'urn:oasis:names:specification:ubl:signature:1',\n },\n ],\n ReferencedSignatureID: [\n {\n _: 'urn:oasis:names:specification:ubl:signature:Invoice',\n },\n ],\n Signature: [\n {\n Id: 'signature',\n Object: [\n {\n QualifyingProperties: [\n {\n Target: 'signature',\n SignedProperties:\n signedProperties.SignedProperties,\n },\n ],\n },\n ],\n KeyInfo: [\n {\n X509Data: [\n {\n X509Certificate: [{ _: certificate }],\n X509SubjectName: [\n { _: certInfo.subjectName },\n ],\n X509IssuerSerial: [\n {\n X509IssuerName: [\n {\n _: certInfo.issuerName,\n },\n ],\n X509SerialNumber: [\n {\n _: certInfo.serialNumber,\n },\n ],\n },\n ],\n },\n ],\n },\n ],\n SignatureValue: [{ _: signatureValue }],\n SignedInfo: [signedInfo],\n },\n ],\n },\n ],\n },\n ],\n },\n ],\n },\n ],\n },\n ],\n\n // Add simple Signature reference\n Signature: [\n {\n ID: [\n {\n _: 'urn:oasis:names:specification:ubl:signature:Invoice',\n },\n ],\n SignatureMethod: [\n {\n _: 'urn:oasis:names:specification:ubl:dsig:enveloped:xades',\n },\n ],\n },\n ],\n }\n })\n\n return {\n _D: 'urn:oasis:names:specification:ubl:schema:xsd:Invoice-2',\n _A: 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2',\n _B: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2',\n Invoice: signedInvoices,\n }\n } catch (error) {\n throw new Error(\n `Document generation failed: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n}\n"],"mappings":";;;;;;;;;;;;AAoBA,SAAgB,eAAeA,KAAuB;AACpD,K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,eAAgB,CAAC;OACvC,YAAY,CAAC,UAAW;MACzB,CACF;KACF,CACF,EACF,CACF,EACF,CACF;IACF,CACF,EACF,CACF;IAGD,WAAW,CACT;KACE,IAAI,CACF,EACE,GAAG,sDACJ,CACF;KACD,iBAAiB,CACf,EACE,GAAG,yDACJ,CACF;IACF,CACF;GACF;EACF,EAAC;AAEF,SAAO;GACL,IAAI;GACJ,IAAI;GACJ,IAAI;GACJ,SAAS;EACV;CACF,SAAQ,OAAO;AACd,QAAM,IAAI,OACP,8BAA8B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,CAAC;CAEzF;AACF"}
|
package/dist/index15.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index15.cjs","names":[],"sources":["../src/types/notifications.d.ts"],"sourcesContent":["export type NotificationType = 3 | 6 | 7 | 8 | 10 | 11 | 15 | 26 | 33 | 34 | 35\n\nexport enum NotificationTypeEnum {\n 'Profile data validation' = 3,\n 'Document received' = 6,\n 'Document validated' = 7,\n 'Document cancelled' = 8,\n 'User profile changed' = 10,\n 'Taxpayer profile changed' = 11,\n 'Document rejection initiated' = 15,\n 'ERP data validation' = 26,\n 'Documents processing summary' = 33,\n 'Document Template Published' = 34,\n 'Document Template Deletion' = 35,\n}\n\nexport type NotificationStatus = 1 | 2 | 3 | 4 | 5\n\nexport enum NotificationStatusEnum {\n 'New' = 1,\n 'Pending' = 2,\n 'Batched' = 3,\n 'Delivered' = 4,\n 'Error' = 5,\n}\n\nexport type NotificationDeliveryAttempt = {\n attemptDateTime: string\n status: string\n statusDetails: string\n}\n\nexport type NotificationMetadata = {\n hasNext: boolean\n}\n\nexport type Notification = {\n notificationId: string\n receiverNName: string\n notificationDeliveryId: string\n creationDateTime: string\n receivedDateTime: string\n notificationSubject: string\n deliveredDateTime: string\n typeId: string\n typeName: string\n finalMessage: string\n address: string\n language: string\n status: string\n deliveryAttempts: NotificationDeliveryAttempt[]\n}\n\nexport type NotificationResponse = {\n notifications: Notification[]\n metadata: NotificationMetadata\n}\n\nexport type NotificationSearchParams = {\n dateFrom?: string\n dateTo?: string\n type?: NotificationType\n language?: string\n status?: NotificationStatus\n pageNo?: number\n pageSize?: number\n}\n"],"mappings":";;AAEA,IAAY,wEAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACD;AAID,IAAY,4EAAL;AACL;AACA;AACA;AACA;AACA;;AACD"}
|
package/dist/index16.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index16.cjs","names":[],"sources":["../src/types/payment-modes.d.ts"],"sourcesContent":["/**\n * Represents the allowed codes for payment modes.\n * Based on the documentation: https://sdk.myinvois.hasil.gov.my/codes/payment-methods/\n */\nexport type PaymentModeCode =\n | '01' // Cash\n | '02' // Cheque\n | '03' // Bank Transfer\n | '04' // Credit Card\n | '05' // Debit Card\n | '06' // e-Wallet / Digital Wallet\n | '07' // Digital Bank\n | '08' // Others\n\n/**\n * Enum representing the allowed payment mode codes with descriptive names.\n * Provides a more readable way to reference payment modes.\n *\n * @example\n * const mode = PaymentModeCodeEnum.Cash;\n * console.log(mode); // Output: \"01\"\n */\nexport enum PaymentModeCodeEnum {\n Cash = '01',\n Cheque = '02',\n BankTransfer = '03',\n CreditCard = '04',\n DebitCard = '05',\n EWalletDigitalWallet = '06',\n DigitalBank = '07',\n Others = '08',\n}\n\n/**\n * Interface representing a payment mode entry.\n * Contains the code and its corresponding description.\n */\nexport interface PaymentMode {\n code: PaymentModeCode\n description: string\n}\n"],"mappings":";;;;;;;;;;AAsBA,IAAY,sEAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACD"}
|
package/dist/index18.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index18.cjs","names":[],"sources":["../src/types/state-codes.d.ts"],"sourcesContent":["/**\n * Represents the allowed codes for Malaysian states and federal territories.\n * Based on the documentation: https://sdk.myinvois.hasil.gov.my/codes/state-codes/\n */\nexport type StateCode =\n | '01' // Johor\n | '02' // Kedah\n | '03' // Kelantan\n | '04' // Melaka\n | '05' // Negeri Sembilan\n | '06' // Pahang\n | '07' // Pulau Pinang\n | '08' // Perak\n | '09' // Perlis\n | '10' // Selangor\n | '11' // Terengganu\n | '12' // Sabah\n | '13' // Sarawak\n | '14' // Wilayah Persekutuan Kuala Lumpur\n | '15' // Wilayah Persekutuan Labuan\n | '16' // Wilayah Persekutuan Putrajaya\n | '17' // Not Applicable\n\n/**\n * Enum representing the allowed state codes with descriptive names.\n * Provides a more readable way to reference states.\n *\n * @example\n * const code = StateCodeEnum.Selangor;\n * console.log(code); // Output: \"10\"\n */\nexport enum StateCodeEnum {\n Johor = '01',\n Kedah = '02',\n Kelantan = '03',\n Melaka = '04',\n NegeriSembilan = '05',\n Pahang = '06',\n PulauPinang = '07',\n Perak = '08',\n Perlis = '09',\n Selangor = '10',\n Terengganu = '11',\n Sabah = '12',\n Sarawak = '13',\n WPKualaLumpur = '14',\n WPLabuan = '15',\n WPPutrajaya = '16',\n NotApplicable = '17',\n}\n\n/**\n * Interface representing a state code entry.\n * Contains the code and its corresponding name.\n */\nexport interface State {\n code: StateCode\n name: string\n}\n"],"mappings":";;;;;;;;;;AA+BA,IAAY,0DAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"taxpayerValidation-DdeXCvPT.cjs","names":["context: TaxpayerContext","params: TinSearchParams","errorData","tin: string","idType: RegistrationType","idValue: string","qrCodeText: string"],"sources":["../src/api/taxpayerValidation.ts"],"sourcesContent":["import type {\n Fetch,\n RegistrationType,\n StandardError,\n TaxpayerQRCodeResponse,\n TinSearchParams,\n TinSearchResponse,\n} from '../types'\n\ninterface TaxpayerContext {\n fetch: Fetch\n debug: boolean\n}\n\nexport async function tinSearch(\n context: TaxpayerContext,\n params: TinSearchParams,\n): Promise<TinSearchResponse | StandardError> {\n const { fetch, debug } = context\n const { taxpayerName, idType, idValue } = params\n\n // Validate input parameters according to API requirements\n if (!taxpayerName && (!idType || !idValue)) {\n throw new Error(\n 'Either taxpayerName must be provided, or both idType and idValue must be provided',\n )\n }\n\n if ((idType && !idValue) || (!idType && idValue)) {\n throw new Error('idType and idValue must be provided together')\n }\n\n // Build query parameters\n const queryParams = new URLSearchParams()\n\n if (taxpayerName) {\n queryParams.append('taxpayerName', taxpayerName)\n }\n\n if (idType && idValue) {\n queryParams.append('idType', idType)\n queryParams.append('idValue', idValue)\n }\n\n const queryString = queryParams.toString()\n\n try {\n const response = await fetch(\n `/api/v1.0/taxpayer/search/tin?${queryString}`,\n {\n method: 'GET',\n },\n )\n\n if (response.status === 200) {\n return (await response.json()) as TinSearchResponse\n }\n\n // Handle specific error cases mentioned in the API documentation\n if (response.status === 400) {\n const errorData = (await response.json()) as StandardError\n if (debug) {\n console.error(\n 'TIN search failed - search criteria not conclusive or invalid parameters:',\n errorData,\n )\n }\n return errorData\n }\n\n if (response.status === 404) {\n const errorData = (await response.json()) as StandardError\n if (debug) {\n console.error(\n 'TIN search failed - no TIN found for given search criteria:',\n errorData,\n )\n }\n return errorData\n }\n\n // Handle other error status codes\n const errorData = (await response.json()) as StandardError\n if (debug) {\n console.error(\n 'TIN search failed with status:',\n response.status,\n errorData,\n )\n }\n return errorData\n } catch (error) {\n if (debug) {\n console.error('TIN search error:', error)\n }\n throw error\n }\n}\n\nexport async function verifyTin(\n context: TaxpayerContext,\n tin: string,\n idType: RegistrationType,\n idValue: string,\n): Promise<boolean> {\n const { fetch, debug } = context\n\n try {\n const response = await fetch(\n `/api/v1.0/taxpayer/validate/${tin}?idType=${idType}&idValue=${idValue}`,\n {\n method: 'GET',\n },\n )\n\n if (response.status === 200) {\n return true\n }\n\n return false\n } catch (error) {\n if (debug) {\n console.error(error)\n }\n return false\n }\n}\n\nexport async function taxpayerQRCode(\n context: TaxpayerContext,\n qrCodeText: string,\n): Promise<TaxpayerQRCodeResponse | StandardError> {\n const { fetch } = context\n\n const base64EncodedQRCodeText = Buffer.from(qrCodeText).toString('base64')\n\n const response = await fetch(\n `/api/v1.0/taxpayer/qrcodeinfo/${base64EncodedQRCodeText}`,\n )\n\n return response.json()\n}\n"],"mappings":";;AAcA,eAAsB,UACpBA,SACAC,QAC4C;CAC5C,MAAM,EAAE,OAAO,OAAO,GAAG;CACzB,MAAM,EAAE,cAAc,QAAQ,SAAS,GAAG;AAG1C,MAAK,kBAAkB,WAAW,SAChC,OAAM,IAAI,MACR;AAIJ,KAAK,WAAW,YAAc,UAAU,QACtC,OAAM,IAAI,MAAM;CAIlB,MAAM,cAAc,IAAI;AAExB,KAAI,aACF,aAAY,OAAO,gBAAgB,aAAa;AAGlD,KAAI,UAAU,SAAS;AACrB,cAAY,OAAO,UAAU,OAAO;AACpC,cAAY,OAAO,WAAW,QAAQ;CACvC;CAED,MAAM,cAAc,YAAY,UAAU;AAE1C,KAAI;EACF,MAAM,WAAW,MAAM,OACpB,gCAAgC,YAAY,GAC7C,EACE,QAAQ,MACT,EACF;AAED,MAAI,SAAS,WAAW,IACtB,QAAQ,MAAM,SAAS,MAAM;AAI/B,MAAI,SAAS,WAAW,KAAK;GAC3B,MAAMC,cAAa,MAAM,SAAS,MAAM;AACxC,OAAI,MACF,SAAQ,MACN,6EACAA,YACD;AAEH,UAAOA;EACR;AAED,MAAI,SAAS,WAAW,KAAK;GAC3B,MAAMA,cAAa,MAAM,SAAS,MAAM;AACxC,OAAI,MACF,SAAQ,MACN,+DACAA,YACD;AAEH,UAAOA;EACR;EAGD,MAAM,YAAa,MAAM,SAAS,MAAM;AACxC,MAAI,MACF,SAAQ,MACN,kCACA,SAAS,QACT,UACD;AAEH,SAAO;CACR,SAAQ,OAAO;AACd,MAAI,MACF,SAAQ,MAAM,qBAAqB,MAAM;AAE3C,QAAM;CACP;AACF;AAED,eAAsB,UACpBF,SACA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