@ripwords/myinvois-client 0.1.3 → 0.1.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/CHANGELOG.md +29 -0
- package/dist/api/platform/platformLogin.d.ts +1 -1
- package/dist/{documents-MGs0EvXh.d.cts → documents-CQy_uB6C.d.cts} +6 -7
- package/dist/{documents-CJ8hqIGH.d.ts → documents-i5EV868Y.d.ts} +5 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index21.cjs +2 -207
- package/dist/index22.cjs +203 -104
- package/dist/index22.cjs.map +1 -1
- package/dist/index23.cjs +104 -132
- package/dist/index23.cjs.map +1 -1
- package/dist/index24.cjs +132 -59
- package/dist/index24.cjs.map +1 -1
- package/dist/index25.cjs +59 -262
- package/dist/index25.cjs.map +1 -1
- package/dist/index26.cjs +262 -74
- package/dist/index26.cjs.map +1 -1
- package/dist/index27.cjs +74 -102
- package/dist/index27.cjs.map +1 -1
- package/dist/index28.cjs +102 -68
- package/dist/index28.cjs.map +1 -1
- package/dist/index29.cjs +68 -107
- package/dist/index29.cjs.map +1 -1
- package/dist/index30.cjs +107 -95
- package/dist/index30.cjs.map +1 -1
- package/dist/index31.cjs +95 -13
- package/dist/index31.cjs.map +1 -1
- package/dist/index32.cjs +11 -31
- package/dist/index32.cjs.map +1 -1
- package/dist/index33.cjs +31 -12
- package/dist/index33.cjs.map +1 -1
- package/dist/index34.cjs +12 -22
- package/dist/index34.cjs.map +1 -1
- package/dist/index35.cjs +22 -13
- package/dist/index35.cjs.map +1 -1
- package/dist/index36.cjs +13 -7
- package/dist/index36.cjs.map +1 -1
- package/dist/index37.cjs +7 -7
- package/dist/index37.cjs.map +1 -1
- package/dist/index38.cjs +7 -10
- package/dist/index38.cjs.map +1 -1
- package/dist/index39.cjs +10 -6
- package/dist/index39.cjs.map +1 -1
- package/dist/index40.cjs +6 -101
- package/dist/index40.cjs.map +1 -1
- package/dist/index41.cjs +101 -106
- package/dist/index41.cjs.map +1 -1
- package/dist/index42.cjs +106 -119
- package/dist/index42.cjs.map +1 -1
- package/dist/index43.cjs +119 -106
- package/dist/index43.cjs.map +1 -1
- package/dist/index44.cjs +106 -98
- package/dist/index44.cjs.map +1 -1
- package/dist/index45.cjs +98 -118
- package/dist/index45.cjs.map +1 -1
- package/dist/index46.cjs +118 -127
- package/dist/index46.cjs.map +1 -1
- package/dist/index47.cjs +127 -117
- package/dist/index47.cjs.map +1 -1
- package/dist/index48.cjs +117 -14
- package/dist/index48.cjs.map +1 -1
- package/dist/index49.cjs +14 -95
- package/dist/index49.cjs.map +1 -1
- package/dist/index50.cjs +95 -142
- package/dist/index50.cjs.map +1 -1
- package/dist/index51.cjs +142 -114
- package/dist/index51.cjs.map +1 -1
- package/dist/index52.cjs +114 -144
- package/dist/index52.cjs.map +1 -1
- package/dist/index53.cjs +144 -113
- package/dist/index53.cjs.map +1 -1
- package/dist/index54.cjs +113 -17
- package/dist/index54.cjs.map +1 -1
- package/dist/index55.cjs +17 -112
- package/dist/index55.cjs.map +1 -1
- package/dist/index56.cjs +112 -47
- package/dist/index56.cjs.map +1 -1
- package/dist/index57.cjs +47 -14
- package/dist/index57.cjs.map +1 -1
- package/dist/index58.cjs +14 -28
- package/dist/index58.cjs.map +1 -1
- package/dist/index59.cjs +28 -22
- package/dist/index59.cjs.map +1 -1
- package/dist/index59.cts.map +1 -1
- package/dist/index60.cjs +22 -9
- package/dist/index60.cjs.map +1 -1
- package/dist/index61.cjs +9 -8
- package/dist/index61.cjs.map +1 -1
- package/dist/index62.cjs +8 -17
- package/dist/index62.cjs.map +1 -1
- package/dist/index63.cjs +17 -412
- package/dist/index63.cjs.map +1 -1
- package/dist/index64.cjs +412 -8
- package/dist/index64.cjs.map +1 -1
- package/dist/index65.cjs +8 -9
- package/dist/index65.cjs.map +1 -1
- package/dist/index66.cjs +15 -2
- package/dist/index66.cjs.map +1 -0
- package/dist/types/documents.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/document.d.ts +1 -1
- package/dist/utils/signature-diagnostics.d.ts +1 -1
- package/package.json +4 -5
- package/src/index.ts +2 -1
- package/src/types/documents.d.ts +5 -6
- package/dist/index21.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## v0.1.5
|
|
5
|
+
|
|
6
|
+
[compare changes](https://github.com/Ripwords/MyInvoisClient/compare/v0.1.4...v0.1.5)
|
|
7
|
+
|
|
8
|
+
### 🏡 Chore
|
|
9
|
+
|
|
10
|
+
- Update release scripts to include 'bun publish' for public access after changelog generation ([3ace843](https://github.com/Ripwords/MyInvoisClient/commit/3ace843))
|
|
11
|
+
- Update release scripts to use 'npm publish' instead of 'bun publish' for public access after changelog generation ([cd6854f](https://github.com/Ripwords/MyInvoisClient/commit/cd6854f))
|
|
12
|
+
|
|
13
|
+
### ❤️ Contributors
|
|
14
|
+
|
|
15
|
+
- JJ <teohjjteoh@gmail.com>
|
|
16
|
+
|
|
17
|
+
## v0.1.4
|
|
18
|
+
|
|
19
|
+
[compare changes](https://github.com/Ripwords/MyInvoisClient/compare/v0.1.3...v0.1.4)
|
|
20
|
+
|
|
21
|
+
### 💅 Refactors
|
|
22
|
+
|
|
23
|
+
- Extend RegistrationType to include 'ARMY' and update related interfaces in documents.d.ts and index.ts for improved type safety ([955ccee](https://github.com/Ripwords/MyInvoisClient/commit/955ccee))
|
|
24
|
+
|
|
25
|
+
### 🏡 Chore
|
|
26
|
+
|
|
27
|
+
- Update release scripts to remove npm publish command and ensure git push follows changelog generation ([ba56b4a](https://github.com/Ripwords/MyInvoisClient/commit/ba56b4a))
|
|
28
|
+
|
|
29
|
+
### ❤️ Contributors
|
|
30
|
+
|
|
31
|
+
- JJ <teohjjteoh@gmail.com>
|
|
32
|
+
|
|
4
33
|
## v0.1.3
|
|
5
34
|
|
|
6
35
|
[compare changes](https://github.com/Ripwords/MyInvoisClient/compare/v0.1.2...v0.1.3)
|
|
@@ -15,7 +15,7 @@ import "../../9X-Cpb6V4JC.js";
|
|
|
15
15
|
import "../../msic-codes-C8PJVOaA.js";
|
|
16
16
|
import "../../signatures-W-_brwdb.js";
|
|
17
17
|
import "../../tax-types-CsQ76JMf.js";
|
|
18
|
-
import "../../documents-
|
|
18
|
+
import "../../documents-i5EV868Y.js";
|
|
19
19
|
import "../../payment-modes-BOTSRC_X.js";
|
|
20
20
|
import "../../1X-BywXCqtn.js";
|
|
21
21
|
import "../../2X-3fSEGIuE.js";
|
|
@@ -4,10 +4,9 @@ import { EInvoiceTypeCode } from "./e-invoice-BuwtFnlI.cjs";
|
|
|
4
4
|
import { MSICCode } from "./msic-codes-CIKdPqag.cjs";
|
|
5
5
|
import { IssuerDigitalSignature } from "./signatures-hFbt_std.cjs";
|
|
6
6
|
import { TaxTypeCode } from "./tax-types-B5sQ8UyN.cjs";
|
|
7
|
-
import { Suggested } from "./utils.js";
|
|
8
7
|
|
|
9
8
|
//#region src/types/documents.d.ts
|
|
10
|
-
type RegistrationType = 'BRN' | 'NRIC' | 'PASSPORT';
|
|
9
|
+
type RegistrationType = 'BRN' | 'NRIC' | 'PASSPORT' | 'ARMY';
|
|
11
10
|
|
|
12
11
|
// Based on https://sdk.myinvois.hasil.gov.my/documents/invoice-v1-1/
|
|
13
12
|
|
|
@@ -48,7 +47,7 @@ interface Supplier {
|
|
|
48
47
|
registrationType: RegistrationType;
|
|
49
48
|
/**
|
|
50
49
|
* Supplier's Registration / Identification Number / Passport Number.
|
|
51
|
-
* Format depends on schemeID: NRIC (12), BRN (20), PASSPORT (12)
|
|
50
|
+
* Format depends on schemeID: NRIC (12), BRN (20), PASSPORT (12)
|
|
52
51
|
* @example BRN: 202001234567
|
|
53
52
|
*/
|
|
54
53
|
registrationNumber: string;
|
|
@@ -67,7 +66,7 @@ interface Supplier {
|
|
|
67
66
|
* Supplier's industry classification description. Max 300 chars.
|
|
68
67
|
* @example Other retail sale in non-specialised stores
|
|
69
68
|
*/
|
|
70
|
-
industryClassificationDescription:
|
|
69
|
+
industryClassificationDescription: MSICCode['description'];
|
|
71
70
|
}
|
|
72
71
|
|
|
73
72
|
/**
|
|
@@ -84,13 +83,13 @@ interface Buyer {
|
|
|
84
83
|
*/
|
|
85
84
|
tin: string;
|
|
86
85
|
/**
|
|
87
|
-
* Buyer's Registration Type. NRIC, BRN, PASSPORT
|
|
86
|
+
* Buyer's Registration Type. NRIC, BRN, PASSPORT
|
|
88
87
|
* @example BRN
|
|
89
88
|
*/
|
|
90
89
|
registrationType: RegistrationType;
|
|
91
90
|
/**
|
|
92
91
|
* Buyer's Registration / Identification Number / Passport Number.
|
|
93
|
-
* Format depends on schemeID: NRIC (12), BRN (20), PASSPORT (12)
|
|
92
|
+
* Format depends on schemeID: NRIC (12), BRN (20), PASSPORT (12).
|
|
94
93
|
* @example BRN: 202001234567
|
|
95
94
|
*/
|
|
96
95
|
registrationNumber: string;
|
|
@@ -856,4 +855,4 @@ interface CompleteInvoice {
|
|
|
856
855
|
}
|
|
857
856
|
//#endregion
|
|
858
857
|
export { Address, Buyer, CompleteInvoice, DocumentStatus, DocumentSummary, DocumentValidationResult, DocumentValidationStepResult, FinalDocumentData, GetSubmissionResponse, InvoiceLineItem, InvoiceSubmission, InvoiceV1_1, LegalMonetaryTotal, RegistrationType, ResponseDocument, SignedInfoObject, SignedInvoiceSubmission, SignedPropertiesData, SignedPropertiesObject, SigningCredentials, StandardError, SubmissionResponse, SubmissionStatus, Supplier, TaxCategory, TaxSubtotal, TaxTotal, UBLDocument };
|
|
859
|
-
//# sourceMappingURL=documents-
|
|
858
|
+
//# sourceMappingURL=documents-CQy_uB6C.d.cts.map
|
|
@@ -4,10 +4,9 @@ import { EInvoiceTypeCode } from "./e-invoice-CmbLQkHw.js";
|
|
|
4
4
|
import { MSICCode } from "./msic-codes-C8PJVOaA.js";
|
|
5
5
|
import { IssuerDigitalSignature } from "./signatures-W-_brwdb.js";
|
|
6
6
|
import { TaxTypeCode } from "./tax-types-CsQ76JMf.js";
|
|
7
|
-
import { Suggested } from "./utils.js";
|
|
8
7
|
|
|
9
8
|
//#region src/types/documents.d.ts
|
|
10
|
-
type RegistrationType = 'BRN' | 'NRIC' | 'PASSPORT';
|
|
9
|
+
type RegistrationType = 'BRN' | 'NRIC' | 'PASSPORT' | 'ARMY';
|
|
11
10
|
|
|
12
11
|
// Based on https://sdk.myinvois.hasil.gov.my/documents/invoice-v1-1/
|
|
13
12
|
|
|
@@ -48,7 +47,7 @@ interface Supplier {
|
|
|
48
47
|
registrationType: RegistrationType;
|
|
49
48
|
/**
|
|
50
49
|
* Supplier's Registration / Identification Number / Passport Number.
|
|
51
|
-
* Format depends on schemeID: NRIC (12), BRN (20), PASSPORT (12)
|
|
50
|
+
* Format depends on schemeID: NRIC (12), BRN (20), PASSPORT (12)
|
|
52
51
|
* @example BRN: 202001234567
|
|
53
52
|
*/
|
|
54
53
|
registrationNumber: string;
|
|
@@ -67,7 +66,7 @@ interface Supplier {
|
|
|
67
66
|
* Supplier's industry classification description. Max 300 chars.
|
|
68
67
|
* @example Other retail sale in non-specialised stores
|
|
69
68
|
*/
|
|
70
|
-
industryClassificationDescription:
|
|
69
|
+
industryClassificationDescription: MSICCode['description'];
|
|
71
70
|
}
|
|
72
71
|
|
|
73
72
|
/**
|
|
@@ -84,13 +83,13 @@ interface Buyer {
|
|
|
84
83
|
*/
|
|
85
84
|
tin: string;
|
|
86
85
|
/**
|
|
87
|
-
* Buyer's Registration Type. NRIC, BRN, PASSPORT
|
|
86
|
+
* Buyer's Registration Type. NRIC, BRN, PASSPORT
|
|
88
87
|
* @example BRN
|
|
89
88
|
*/
|
|
90
89
|
registrationType: RegistrationType;
|
|
91
90
|
/**
|
|
92
91
|
* Buyer's Registration / Identification Number / Passport Number.
|
|
93
|
-
* Format depends on schemeID: NRIC (12), BRN (20), PASSPORT (12)
|
|
92
|
+
* Format depends on schemeID: NRIC (12), BRN (20), PASSPORT (12).
|
|
94
93
|
* @example BRN: 202001234567
|
|
95
94
|
*/
|
|
96
95
|
registrationNumber: string;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["clientId: string","clientSecret: string","environment: 'sandbox' | 'production'","certificatePem: string","privateKeyPem: string","onBehalfOf?: string","debug?: boolean","path: string","options: Parameters<typeof fetch>[1]","tin: string","idType: 'NRIC' | 'ARMY' | 'PASSPORT' | 'BRN'","idValue: string","documents: InvoiceV1_1[]","submissionUid: string","pollInterval: number","maxRetries: number","documentUid: string"],"sources":["../src/index.ts"],"sourcesContent":["import { EInvoiceTypeCode } from './types'\nimport { platformLogin } from './api/platform/platformLogin'\nimport type {\n DocumentStatus,\n InvoiceV1_1,\n SigningCredentials,\n} from './types/documents'\nimport { getBaseUrl } from './utils/getBaseUrl'\nimport { extractCertificateInfo, validateKeyPair } from './utils/certificate'\n\nimport type {\n DocumentSummary,\n DocumentValidationResult,\n DocumentValidationStepResult,\n GetSubmissionResponse,\n SubmissionResponse,\n SubmissionStatus,\n} from './types/documents'\nimport { generateCompleteDocument } from './utils/document'\n\nexport class MyInvoisClient {\n private readonly baseUrl: string\n private readonly clientId: string\n private readonly clientSecret: string\n private readonly onBehalfOf?: string\n private readonly signingCredentials: SigningCredentials\n private readonly debug: boolean\n private token = ''\n private tokenExpiration: Date | undefined = undefined\n\n constructor(\n clientId: string,\n clientSecret: string,\n environment: 'sandbox' | 'production',\n certificatePem: string,\n privateKeyPem: string,\n onBehalfOf?: string,\n debug?: boolean,\n ) {\n // Check if basic signing credentials are available\n if (!privateKeyPem || !certificatePem) {\n throw new Error(\n 'Missing required environment variables: PRIVATE_KEY and CERTIFICATE',\n )\n }\n\n // Validate that the key pair matches\n if (!validateKeyPair(certificatePem, privateKeyPem)) {\n throw new Error('Certificate and private key do not match')\n }\n\n this.clientId = clientId\n this.clientSecret = clientSecret\n this.baseUrl = getBaseUrl(environment)\n this.onBehalfOf = onBehalfOf\n this.debug = (debug ?? process.env.MYINVOIS_DEBUG === 'true') ? true : false\n\n // Extract certificate information\n const { issuerName, serialNumber } = extractCertificateInfo(certificatePem)\n\n this.signingCredentials = {\n privateKeyPem,\n certificatePem,\n issuerName,\n serialNumber,\n }\n }\n\n private async refreshToken() {\n const tokenResponse = await platformLogin({\n clientId: this.clientId,\n clientSecret: this.clientSecret,\n baseUrl: this.baseUrl,\n onBehalfOf: this.onBehalfOf,\n debug: this.debug,\n })\n\n this.token = tokenResponse.token\n this.tokenExpiration = tokenResponse.tokenExpiration\n }\n\n private async getToken() {\n if (\n !this.tokenExpiration ||\n this.tokenExpiration < new Date() ||\n isNaN(this.tokenExpiration.getTime())\n ) {\n if (this.debug) {\n console.log('Token expired')\n console.log('Refreshing token')\n }\n await this.refreshToken()\n }\n\n return this.token\n }\n\n private async fetch(path: string, options: Parameters<typeof fetch>[1] = {}) {\n const token = await this.getToken()\n\n return fetch(`${this.baseUrl}${path}`, {\n ...options,\n headers: { ...options.headers, Authorization: `Bearer ${token}` },\n })\n }\n\n /**\n * Validates a TIN against a NRIC/ARMY/PASSPORT/BRN (Business Registration Number)\n *\n * @param tin - The TIN to validate\n * @param idType - The type of ID to validate against\n * @param idValue - The value of the ID to validate against\n * @returns true if the TIN is valid, false otherwise\n */\n async verifyTin(\n tin: string,\n idType: 'NRIC' | 'ARMY' | 'PASSPORT' | 'BRN',\n idValue: string,\n ): Promise<boolean> {\n try {\n const response = await this.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 (this.debug) {\n console.error(error)\n }\n return false\n }\n }\n\n /**\n * Submits one or more e-invoice documents to the MyInvois platform for processing.\n *\n * This method digitally signs each document using the provided certificate and private key,\n * generates document hashes, encodes them for submission, and sends them to the platform.\n * The method includes comprehensive validation warnings for document size and count limits.\n *\n * @param documents - Array of InvoiceV1_1 documents to be submitted\n * @returns Promise resolving to submission response containing the submission data and HTTP status\n * @throws {Error} If PRIVATE_KEY or CERTIFICATE environment variables are missing\n * @throws {Error} If document signing, encoding, or API submission fails\n *\n * @example\n * ```typescript\n * // Submit a single invoice\n * const result = await client.submitDocument([invoiceData]);\n * console.log(result.data.submissionUid); // Track submission with this UID\n *\n * // Submit multiple invoices\n * const result = await client.submitDocument([invoice1, invoice2, invoice3]);\n * if (result.status === 202) {\n * console.log('Documents submitted successfully');\n * }\n * ```\n *\n * @remarks\n * - Requires PRIVATE_KEY and CERTIFICATE environment variables for document signing\n * - Each document is digitally signed with XML-DSIG before submission\n * - Documents are base64-encoded for transmission\n * - API limits: Max 100 documents per submission, 5MB total payload, 300KB per document\n * - Debug mode provides detailed logging of payload sizes and validation warnings\n * - Returns HTTP 202 for successful submissions that require processing\n */\n async submitDocument(documents: InvoiceV1_1[]): Promise<{\n data: SubmissionResponse\n status: number\n }> {\n if (this.debug) {\n console.log(`📦 Preparing to submit ${documents.length} document(s)...`)\n }\n\n // Generate the complete signed document structure first\n const completeDocument = generateCompleteDocument(\n documents,\n this.signingCredentials,\n )\n\n if (this.debug) {\n console.log('✅ Documents signed successfully')\n console.log('📄 Document structure keys:', Object.keys(completeDocument))\n console.log('📊 Number of invoices:', completeDocument.Invoice.length)\n }\n\n // Convert the complete document to JSON string\n const documentJson = JSON.stringify(completeDocument)\n\n if (this.debug) {\n console.log(`📏 Document JSON size: ${documentJson.length} bytes`)\n }\n\n // Generate SHA256 hash of the JSON document\n const crypto = await import('crypto')\n const documentHash = crypto\n .createHash('sha256')\n .update(documentJson, 'utf8')\n .digest('hex')\n\n // Base64 encode the JSON document\n const documentBase64 = Buffer.from(documentJson, 'utf8').toString('base64')\n\n if (this.debug) {\n console.log(`🔒 Document hash: ${documentHash.substring(0, 16)}...`)\n console.log(`📦 Base64 size: ${documentBase64.length} bytes`)\n }\n\n // Build the submission payload according to MyInvois API format\n const submissionPayload = {\n documents: documents.map(doc => ({\n format: 'JSON', // We're submitting JSON format\n document: documentBase64, // Base64 encoded complete document\n documentHash: documentHash, // SHA256 hash of the JSON\n codeNumber: doc.eInvoiceCodeOrNumber, // Document reference number\n })),\n }\n\n if (this.debug) {\n console.log('🚀 Submission payload structure:')\n console.log('- Format: JSON')\n console.log('- Documents count:', submissionPayload.documents.length)\n console.log(\n '- Total payload size:',\n JSON.stringify(submissionPayload).length,\n 'bytes',\n )\n\n // Validate submission constraints\n const payloadSize = JSON.stringify(submissionPayload).length\n if (payloadSize > 5 * 1024 * 1024) {\n // 5MB\n console.warn('⚠️ WARNING: Payload size exceeds 5MB limit')\n }\n\n if (documents.length > 100) {\n console.warn('⚠️ WARNING: Document count exceeds 100 document limit')\n }\n\n if (documentJson.length > 300 * 1024) {\n // 300KB per document\n console.warn('⚠️ WARNING: Document size exceeds 300KB limit')\n }\n }\n\n // Submit to MyInvois API with proper headers\n const response = await this.fetch('/api/v1.0/documentsubmissions', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(submissionPayload),\n })\n\n if (this.debug) {\n console.log(`📡 API Response status: ${response.status}`)\n }\n\n const data = (await response.json()) as SubmissionResponse\n\n if (this.debug) {\n if (response.status !== 202) {\n console.error('❌ Submission failed with status:', response.status)\n console.error('❌ Response data:', data)\n } else {\n console.log('✅ Submission successful!')\n console.log(`📋 Submission UID: ${data.submissionUid}`)\n console.log(\n `✅ Accepted documents: ${data.acceptedDocuments?.length || 0}`,\n )\n console.log(\n `❌ Rejected documents: ${data.rejectedDocuments?.length || 0}`,\n )\n }\n }\n\n return {\n data,\n status: response.status,\n }\n }\n\n async getSubmissionStatus(\n submissionUid: string,\n pollInterval: number = 1000,\n maxRetries: number = 10,\n ): Promise<{\n status: SubmissionStatus\n documentSummary?: DocumentSummary[]\n error?: {\n code: string\n message: string | null\n target: string\n details: {\n code: string\n message: string\n target: string\n }[]\n }\n }> {\n try {\n const response = await this.fetch(\n `/api/v1.0/documentsubmissions/${submissionUid}`,\n )\n\n const data = (await response.json()) as GetSubmissionResponse\n\n if (this.debug) {\n console.log('Submission:', data)\n if (data.error) {\n console.log('Submission error details:', data.error.details)\n }\n }\n\n // If we have a successful response and status is completed, return success\n if (data.overallStatus === 'Valid') {\n return {\n status: data.overallStatus,\n documentSummary: data.documentSummary,\n }\n }\n if (data.overallStatus === 'Invalid') {\n return {\n status: 'Invalid',\n documentSummary: data.documentSummary,\n }\n }\n\n // If we have retries left, continue polling for any non-completed status or errors\n if (maxRetries > 0) {\n await new Promise(resolve => setTimeout(resolve, pollInterval))\n return await this.getSubmissionStatus(\n submissionUid,\n pollInterval,\n maxRetries - 1,\n )\n }\n\n // No retries left - return timeout\n return {\n status: 'Invalid',\n error: {\n code: 'Timeout',\n message: 'Submission timed out',\n target: 'submission',\n details: [],\n },\n }\n } catch (error) {\n // Handle any request errors by retrying if we have retries left\n if (maxRetries > 0) {\n if (this.debug) {\n console.log('Request error, retrying...', error)\n }\n await new Promise(resolve => setTimeout(resolve, pollInterval))\n return await this.getSubmissionStatus(\n submissionUid,\n pollInterval,\n maxRetries - 1,\n )\n }\n\n // No retries left - return timeout\n return {\n status: 'Invalid',\n error: {\n code: 'Timeout',\n message: 'Submission timed out after request errors',\n target: 'submission',\n details: [],\n },\n }\n }\n }\n\n /**\n * Retrieves a document by its unique identifier with the raw document content.\n *\n * @param documentUid - The unique identifier of the document to retrieve\n * @returns Promise resolving to document summary with raw document content as a string\n * @throws {Error} If the document is not found or request fails\n *\n * @example\n * ```typescript\n * const document = await client.getDocument('doc-uuid-123');\n * console.log(document.document); // Raw XML/JSON content\n * console.log(document.uuid); // Document UUID\n * ```\n */\n async getDocument(\n documentUid: string,\n ): Promise<DocumentSummary & { document: string }> {\n const response = await this.fetch(`/api/v1.0/documents/${documentUid}/raw`)\n\n const data = await response.json()\n\n return data as DocumentSummary & { document: string }\n }\n\n /**\n * Retrieves detailed information about a document including validation results.\n *\n * @param documentUid - The unique identifier of the document to get details for\n * @returns Promise resolving to document summary with detailed validation results\n * @throws {Error} If the document is not found or request fails\n *\n * @example\n * ```typescript\n * const details = await client.getDocumentDetails('doc-uuid-123');\n * console.log(details.validationResults.status); // 'Valid' | 'Invalid' | 'Processing'\n * console.log(details.validationResults.validationSteps); // Array of validation step results\n * ```\n */\n async getDocumentDetails(documentUid: string): Promise<\n DocumentSummary & {\n validationResults: {\n status: DocumentValidationResult\n validationSteps: DocumentValidationStepResult[]\n }\n }\n > {\n const response = await this.fetch(\n `/api/v1.0/documents/${documentUid}/details`,\n )\n\n const data = (await response.json()) as DocumentSummary & {\n validationResults: {\n status: DocumentValidationResult\n validationSteps: DocumentValidationStepResult[]\n }\n }\n\n return data\n }\n\n /**\n * Searches for documents based on various filter criteria.\n *\n * @param params - Search parameters object\n * @param params.uuid - Optional specific document UUID to search for\n * @param params.submissionDateFrom - Required start date for submission date range (ISO date string)\n * @param params.submissionDateTo - Optional end date for submission date range (ISO date string)\n * @param params.pageSize - Optional number of results per page (default handled by API)\n * @param params.pageNo - Optional page number for pagination (0-based)\n * @param params.issueDateFrom - Optional start date for issue date range (ISO date string)\n * @param params.issueDateTo - Optional end date for issue date range (ISO date string)\n * @param params.invoiceDirection - Optional filter by invoice direction ('Sent' or 'Received')\n * @param params.status - Optional filter by document status\n * @param params.documentType - Optional filter by e-invoice type code\n * @param params.searchQuery - Optional text search across uuid, buyerTIN, supplierTIN, buyerName, supplierName, internalID, total\n * @returns Promise resolving to array of document summaries matching the search criteria\n * @throws {Error} If the search request fails\n *\n * @example\n * ```typescript\n * // Search for documents submitted in the last 30 days\n * const documents = await client.searchDocuments({\n * submissionDateFrom: '2024-01-01',\n * submissionDateTo: '2024-01-31',\n * status: 'Valid',\n * pageSize: 10\n * });\n *\n * // Search by supplier name\n * const supplierDocs = await client.searchDocuments({\n * submissionDateFrom: '2024-01-01',\n * searchQuery: 'ACME Corp',\n * invoiceDirection: 'Received'\n * });\n * ```\n */\n async searchDocuments({\n uuid,\n submissionDateFrom,\n submissionDateTo,\n pageSize,\n pageNo,\n issueDateFrom,\n issueDateTo,\n invoiceDirection,\n status,\n documentType,\n searchQuery,\n }: {\n uuid?: string\n submissionDateFrom: string\n submissionDateTo?: string\n pageSize?: number\n pageNo?: number\n issueDateFrom?: string\n issueDateTo?: string\n invoiceDirection?: 'Sent' | 'Received'\n status?: DocumentStatus\n documentType?: EInvoiceTypeCode\n searchQuery?: string // Search by uuid, buyerTIN, supplierTIN, buyerName, supplierName, internalID, total\n }): Promise<DocumentSummary[]> {\n const queryParams = new URLSearchParams()\n\n if (uuid) queryParams.set('uuid', uuid)\n if (submissionDateFrom)\n queryParams.set('submissionDateFrom', submissionDateFrom)\n if (submissionDateTo) queryParams.set('submissionDateTo', submissionDateTo)\n if (pageSize) queryParams.set('pageSize', pageSize.toString())\n if (pageNo) queryParams.set('pageNo', pageNo.toString())\n if (issueDateFrom) queryParams.set('issueDateFrom', issueDateFrom)\n if (issueDateTo) queryParams.set('issueDateTo', issueDateTo)\n if (invoiceDirection) queryParams.set('invoiceDirection', invoiceDirection)\n if (status) queryParams.set('status', status)\n if (documentType) queryParams.set('documentType', documentType)\n if (searchQuery) queryParams.set('searchQuery', searchQuery)\n\n const response = await this.fetch(\n `/api/v1.0/documents/search?${queryParams.toString()}`,\n )\n\n const data = (await response.json()) as DocumentSummary[]\n\n return data\n }\n}\n\nexport type * from './types/index.d.ts'\n"],"mappings":";;;;;;AAoBA,IAAa,iBAAb,MAA4B;CAC1B,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAQ,QAAQ;CAChB,AAAQ;CAER,YACEA,UACAC,cACAC,aACAC,gBACAC,eACAC,YACAC,OACA;AAEA,OAAK,kBAAkB,eACrB,OAAM,IAAI,MACR;AAKJ,OAAK,oCAAgB,gBAAgB,cAAc,CACjD,OAAM,IAAI,MAAM;AAGlB,OAAK,WAAW;AAChB,OAAK,eAAe;AACpB,OAAK,UAAU,8BAAW,YA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AC7C,MAAI,aAAc,aAAY,IAAI,gBAAgB,aAAa;AAC/D,MAAI,YAAa,aAAY,IAAI,eAAe,YAAY;EAE5D,MAAM,WAAW,MAAM,KAAK,OACzB,6BAA6B,YAAY,UAAU,CAAC,EACtD;EAED,MAAM,OAAQ,MAAM,SAAS,MAAM;AAEnC,SAAO;CACR;AACF"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["clientId: string","clientSecret: string","environment: 'sandbox' | 'production'","certificatePem: string","privateKeyPem: string","onBehalfOf?: string","debug?: boolean","path: string","options: Parameters<typeof fetch>[1]","tin: string","idType: RegistrationType","idValue: string","documents: InvoiceV1_1[]","submissionUid: string","pollInterval: number","maxRetries: number","documentUid: string"],"sources":["../src/index.ts"],"sourcesContent":["import { EInvoiceTypeCode } from './types'\nimport { platformLogin } from './api/platform/platformLogin'\nimport type {\n DocumentStatus,\n InvoiceV1_1,\n RegistrationType,\n SigningCredentials,\n} from './types/documents'\nimport { getBaseUrl } from './utils/getBaseUrl'\nimport { extractCertificateInfo, validateKeyPair } from './utils/certificate'\n\nimport type {\n DocumentSummary,\n DocumentValidationResult,\n DocumentValidationStepResult,\n GetSubmissionResponse,\n SubmissionResponse,\n SubmissionStatus,\n} from './types/documents'\nimport { generateCompleteDocument } from './utils/document'\n\nexport class MyInvoisClient {\n private readonly baseUrl: string\n private readonly clientId: string\n private readonly clientSecret: string\n private readonly onBehalfOf?: string\n private readonly signingCredentials: SigningCredentials\n private readonly debug: boolean\n private token = ''\n private tokenExpiration: Date | undefined = undefined\n\n constructor(\n clientId: string,\n clientSecret: string,\n environment: 'sandbox' | 'production',\n certificatePem: string,\n privateKeyPem: string,\n onBehalfOf?: string,\n debug?: boolean,\n ) {\n // Check if basic signing credentials are available\n if (!privateKeyPem || !certificatePem) {\n throw new Error(\n 'Missing required environment variables: PRIVATE_KEY and CERTIFICATE',\n )\n }\n\n // Validate that the key pair matches\n if (!validateKeyPair(certificatePem, privateKeyPem)) {\n throw new Error('Certificate and private key do not match')\n }\n\n this.clientId = clientId\n this.clientSecret = clientSecret\n this.baseUrl = getBaseUrl(environment)\n this.onBehalfOf = onBehalfOf\n this.debug = (debug ?? process.env.MYINVOIS_DEBUG === 'true') ? true : false\n\n // Extract certificate information\n const { issuerName, serialNumber } = extractCertificateInfo(certificatePem)\n\n this.signingCredentials = {\n privateKeyPem,\n certificatePem,\n issuerName,\n serialNumber,\n }\n }\n\n private async refreshToken() {\n const tokenResponse = await platformLogin({\n clientId: this.clientId,\n clientSecret: this.clientSecret,\n baseUrl: this.baseUrl,\n onBehalfOf: this.onBehalfOf,\n debug: this.debug,\n })\n\n this.token = tokenResponse.token\n this.tokenExpiration = tokenResponse.tokenExpiration\n }\n\n private async getToken() {\n if (\n !this.tokenExpiration ||\n this.tokenExpiration < new Date() ||\n isNaN(this.tokenExpiration.getTime())\n ) {\n if (this.debug) {\n console.log('Token expired')\n console.log('Refreshing token')\n }\n await this.refreshToken()\n }\n\n return this.token\n }\n\n private async fetch(path: string, options: Parameters<typeof fetch>[1] = {}) {\n const token = await this.getToken()\n\n return fetch(`${this.baseUrl}${path}`, {\n ...options,\n headers: { ...options.headers, Authorization: `Bearer ${token}` },\n })\n }\n\n /**\n * Validates a TIN against a NRIC/ARMY/PASSPORT/BRN (Business Registration Number)\n *\n * @param tin - The TIN to validate\n * @param idType - The type of ID to validate against\n * @param idValue - The value of the ID to validate against\n * @returns true if the TIN is valid, false otherwise\n */\n async verifyTin(\n tin: string,\n idType: RegistrationType,\n idValue: string,\n ): Promise<boolean> {\n try {\n const response = await this.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 (this.debug) {\n console.error(error)\n }\n return false\n }\n }\n\n /**\n * Submits one or more e-invoice documents to the MyInvois platform for processing.\n *\n * This method digitally signs each document using the provided certificate and private key,\n * generates document hashes, encodes them for submission, and sends them to the platform.\n * The method includes comprehensive validation warnings for document size and count limits.\n *\n * @param documents - Array of InvoiceV1_1 documents to be submitted\n * @returns Promise resolving to submission response containing the submission data and HTTP status\n * @throws {Error} If PRIVATE_KEY or CERTIFICATE environment variables are missing\n * @throws {Error} If document signing, encoding, or API submission fails\n *\n * @example\n * ```typescript\n * // Submit a single invoice\n * const result = await client.submitDocument([invoiceData]);\n * console.log(result.data.submissionUid); // Track submission with this UID\n *\n * // Submit multiple invoices\n * const result = await client.submitDocument([invoice1, invoice2, invoice3]);\n * if (result.status === 202) {\n * console.log('Documents submitted successfully');\n * }\n * ```\n *\n * @remarks\n * - Requires PRIVATE_KEY and CERTIFICATE environment variables for document signing\n * - Each document is digitally signed with XML-DSIG before submission\n * - Documents are base64-encoded for transmission\n * - API limits: Max 100 documents per submission, 5MB total payload, 300KB per document\n * - Debug mode provides detailed logging of payload sizes and validation warnings\n * - Returns HTTP 202 for successful submissions that require processing\n */\n async submitDocument(documents: InvoiceV1_1[]): Promise<{\n data: SubmissionResponse\n status: number\n }> {\n if (this.debug) {\n console.log(`📦 Preparing to submit ${documents.length} document(s)...`)\n }\n\n // Generate the complete signed document structure first\n const completeDocument = generateCompleteDocument(\n documents,\n this.signingCredentials,\n )\n\n if (this.debug) {\n console.log('✅ Documents signed successfully')\n console.log('📄 Document structure keys:', Object.keys(completeDocument))\n console.log('📊 Number of invoices:', completeDocument.Invoice.length)\n }\n\n // Convert the complete document to JSON string\n const documentJson = JSON.stringify(completeDocument)\n\n if (this.debug) {\n console.log(`📏 Document JSON size: ${documentJson.length} bytes`)\n }\n\n // Generate SHA256 hash of the JSON document\n const crypto = await import('crypto')\n const documentHash = crypto\n .createHash('sha256')\n .update(documentJson, 'utf8')\n .digest('hex')\n\n // Base64 encode the JSON document\n const documentBase64 = Buffer.from(documentJson, 'utf8').toString('base64')\n\n if (this.debug) {\n console.log(`🔒 Document hash: ${documentHash.substring(0, 16)}...`)\n console.log(`📦 Base64 size: ${documentBase64.length} bytes`)\n }\n\n // Build the submission payload according to MyInvois API format\n const submissionPayload = {\n documents: documents.map(doc => ({\n format: 'JSON', // We're submitting JSON format\n document: documentBase64, // Base64 encoded complete document\n documentHash: documentHash, // SHA256 hash of the JSON\n codeNumber: doc.eInvoiceCodeOrNumber, // Document reference number\n })),\n }\n\n if (this.debug) {\n console.log('🚀 Submission payload structure:')\n console.log('- Format: JSON')\n console.log('- Documents count:', submissionPayload.documents.length)\n console.log(\n '- Total payload size:',\n JSON.stringify(submissionPayload).length,\n 'bytes',\n )\n\n // Validate submission constraints\n const payloadSize = JSON.stringify(submissionPayload).length\n if (payloadSize > 5 * 1024 * 1024) {\n // 5MB\n console.warn('⚠️ WARNING: Payload size exceeds 5MB limit')\n }\n\n if (documents.length > 100) {\n console.warn('⚠️ WARNING: Document count exceeds 100 document limit')\n }\n\n if (documentJson.length > 300 * 1024) {\n // 300KB per document\n console.warn('⚠️ WARNING: Document size exceeds 300KB limit')\n }\n }\n\n // Submit to MyInvois API with proper headers\n const response = await this.fetch('/api/v1.0/documentsubmissions', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(submissionPayload),\n })\n\n if (this.debug) {\n console.log(`📡 API Response status: ${response.status}`)\n }\n\n const data = (await response.json()) as SubmissionResponse\n\n if (this.debug) {\n if (response.status !== 202) {\n console.error('❌ Submission failed with status:', response.status)\n console.error('❌ Response data:', data)\n } else {\n console.log('✅ Submission successful!')\n console.log(`📋 Submission UID: ${data.submissionUid}`)\n console.log(\n `✅ Accepted documents: ${data.acceptedDocuments?.length || 0}`,\n )\n console.log(\n `❌ Rejected documents: ${data.rejectedDocuments?.length || 0}`,\n )\n }\n }\n\n return {\n data,\n status: response.status,\n }\n }\n\n async getSubmissionStatus(\n submissionUid: string,\n pollInterval: number = 1000,\n maxRetries: number = 10,\n ): Promise<{\n status: SubmissionStatus\n documentSummary?: DocumentSummary[]\n error?: {\n code: string\n message: string | null\n target: string\n details: {\n code: string\n message: string\n target: string\n }[]\n }\n }> {\n try {\n const response = await this.fetch(\n `/api/v1.0/documentsubmissions/${submissionUid}`,\n )\n\n const data = (await response.json()) as GetSubmissionResponse\n\n if (this.debug) {\n console.log('Submission:', data)\n if (data.error) {\n console.log('Submission error details:', data.error.details)\n }\n }\n\n // If we have a successful response and status is completed, return success\n if (data.overallStatus === 'Valid') {\n return {\n status: data.overallStatus,\n documentSummary: data.documentSummary,\n }\n }\n if (data.overallStatus === 'Invalid') {\n return {\n status: 'Invalid',\n documentSummary: data.documentSummary,\n }\n }\n\n // If we have retries left, continue polling for any non-completed status or errors\n if (maxRetries > 0) {\n await new Promise(resolve => setTimeout(resolve, pollInterval))\n return await this.getSubmissionStatus(\n submissionUid,\n pollInterval,\n maxRetries - 1,\n )\n }\n\n // No retries left - return timeout\n return {\n status: 'Invalid',\n error: {\n code: 'Timeout',\n message: 'Submission timed out',\n target: 'submission',\n details: [],\n },\n }\n } catch (error) {\n // Handle any request errors by retrying if we have retries left\n if (maxRetries > 0) {\n if (this.debug) {\n console.log('Request error, retrying...', error)\n }\n await new Promise(resolve => setTimeout(resolve, pollInterval))\n return await this.getSubmissionStatus(\n submissionUid,\n pollInterval,\n maxRetries - 1,\n )\n }\n\n // No retries left - return timeout\n return {\n status: 'Invalid',\n error: {\n code: 'Timeout',\n message: 'Submission timed out after request errors',\n target: 'submission',\n details: [],\n },\n }\n }\n }\n\n /**\n * Retrieves a document by its unique identifier with the raw document content.\n *\n * @param documentUid - The unique identifier of the document to retrieve\n * @returns Promise resolving to document summary with raw document content as a string\n * @throws {Error} If the document is not found or request fails\n *\n * @example\n * ```typescript\n * const document = await client.getDocument('doc-uuid-123');\n * console.log(document.document); // Raw XML/JSON content\n * console.log(document.uuid); // Document UUID\n * ```\n */\n async getDocument(\n documentUid: string,\n ): Promise<DocumentSummary & { document: string }> {\n const response = await this.fetch(`/api/v1.0/documents/${documentUid}/raw`)\n\n const data = await response.json()\n\n return data as DocumentSummary & { document: string }\n }\n\n /**\n * Retrieves detailed information about a document including validation results.\n *\n * @param documentUid - The unique identifier of the document to get details for\n * @returns Promise resolving to document summary with detailed validation results\n * @throws {Error} If the document is not found or request fails\n *\n * @example\n * ```typescript\n * const details = await client.getDocumentDetails('doc-uuid-123');\n * console.log(details.validationResults.status); // 'Valid' | 'Invalid' | 'Processing'\n * console.log(details.validationResults.validationSteps); // Array of validation step results\n * ```\n */\n async getDocumentDetails(documentUid: string): Promise<\n DocumentSummary & {\n validationResults: {\n status: DocumentValidationResult\n validationSteps: DocumentValidationStepResult[]\n }\n }\n > {\n const response = await this.fetch(\n `/api/v1.0/documents/${documentUid}/details`,\n )\n\n const data = (await response.json()) as DocumentSummary & {\n validationResults: {\n status: DocumentValidationResult\n validationSteps: DocumentValidationStepResult[]\n }\n }\n\n return data\n }\n\n /**\n * Searches for documents based on various filter criteria.\n *\n * @param params - Search parameters object\n * @param params.uuid - Optional specific document UUID to search for\n * @param params.submissionDateFrom - Required start date for submission date range (ISO date string)\n * @param params.submissionDateTo - Optional end date for submission date range (ISO date string)\n * @param params.pageSize - Optional number of results per page (default handled by API)\n * @param params.pageNo - Optional page number for pagination (0-based)\n * @param params.issueDateFrom - Optional start date for issue date range (ISO date string)\n * @param params.issueDateTo - Optional end date for issue date range (ISO date string)\n * @param params.invoiceDirection - Optional filter by invoice direction ('Sent' or 'Received')\n * @param params.status - Optional filter by document status\n * @param params.documentType - Optional filter by e-invoice type code\n * @param params.searchQuery - Optional text search across uuid, buyerTIN, supplierTIN, buyerName, supplierName, internalID, total\n * @returns Promise resolving to array of document summaries matching the search criteria\n * @throws {Error} If the search request fails\n *\n * @example\n * ```typescript\n * // Search for documents submitted in the last 30 days\n * const documents = await client.searchDocuments({\n * submissionDateFrom: '2024-01-01',\n * submissionDateTo: '2024-01-31',\n * status: 'Valid',\n * pageSize: 10\n * });\n *\n * // Search by supplier name\n * const supplierDocs = await client.searchDocuments({\n * submissionDateFrom: '2024-01-01',\n * searchQuery: 'ACME Corp',\n * invoiceDirection: 'Received'\n * });\n * ```\n */\n async searchDocuments({\n uuid,\n submissionDateFrom,\n submissionDateTo,\n pageSize,\n pageNo,\n issueDateFrom,\n issueDateTo,\n invoiceDirection,\n status,\n documentType,\n searchQuery,\n }: {\n uuid?: string\n submissionDateFrom: string\n submissionDateTo?: string\n pageSize?: number\n pageNo?: number\n issueDateFrom?: string\n issueDateTo?: string\n invoiceDirection?: 'Sent' | 'Received'\n status?: DocumentStatus\n documentType?: EInvoiceTypeCode\n searchQuery?: string // Search by uuid, buyerTIN, supplierTIN, buyerName, supplierName, internalID, total\n }): Promise<DocumentSummary[]> {\n const queryParams = new URLSearchParams()\n\n if (uuid) queryParams.set('uuid', uuid)\n if (submissionDateFrom)\n queryParams.set('submissionDateFrom', submissionDateFrom)\n if (submissionDateTo) queryParams.set('submissionDateTo', submissionDateTo)\n if (pageSize) queryParams.set('pageSize', pageSize.toString())\n if (pageNo) queryParams.set('pageNo', pageNo.toString())\n if (issueDateFrom) queryParams.set('issueDateFrom', issueDateFrom)\n if (issueDateTo) queryParams.set('issueDateTo', issueDateTo)\n if (invoiceDirection) queryParams.set('invoiceDirection', invoiceDirection)\n if (status) queryParams.set('status', status)\n if (documentType) queryParams.set('documentType', documentType)\n if (searchQuery) queryParams.set('searchQuery', searchQuery)\n\n const response = await this.fetch(\n `/api/v1.0/documents/search?${queryParams.toString()}`,\n )\n\n const data = (await response.json()) as DocumentSummary[]\n\n return data\n }\n}\n\nexport type * from './types/index.d.ts'\n"],"mappings":";;;;;;AAqBA,IAAa,iBAAb,MAA4B;CAC1B,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAQ,QAAQ;CAChB,AAAQ;CAER,YACEA,UACAC,cACAC,aACAC,gBACAC,eACAC,YACAC,OACA;AAEA,OAAK,kBAAkB,eACrB,OAAM,IAAI,MACR;AAKJ,OAAK,oCAAgB,gBAAgB,cAAc,CACjD,OAAM,IAAI,MAAM;AAGlB,OAAK,WAAW;AA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C3E,MAAI,OAAQ,aAAY,IAAI,UAAU,OAAO;AAC7C,MAAI,aAAc,aAAY,IAAI,gBAAgB,aAAa;AAC/D,MAAI,YAAa,aAAY,IAAI,eAAe,YAAY;EAE5D,MAAM,WAAW,MAAM,KAAK,OACzB,6BAA6B,YAAY,UAAU,CAAC,EACtD;EAED,MAAM,OAAQ,MAAM,SAAS,MAAM;AAEnC,SAAO;CACR;AACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ import "./9X-Cpb6V4JC.js";
|
|
|
15
15
|
import { MSICCode } from "./msic-codes-C8PJVOaA.js";
|
|
16
16
|
import { CanonicalizationMethod, Cert, CertDigest, DigestMethod, IssuerDigitalSignature, IssuerSerial, KeyInfo, QualifyingProperties, Reference, SignatureMethod, SignedInfo, SignedProperties, SignedSignatureProperties, SigningCertificate, Transform, X509Data } from "./signatures-W-_brwdb.js";
|
|
17
17
|
import { TaxType, TaxTypeCode, TaxTypeCodeEnum } from "./tax-types-CsQ76JMf.js";
|
|
18
|
-
import { Address, Buyer, CompleteInvoice, DocumentStatus, DocumentSummary, DocumentValidationResult, DocumentValidationStepResult, FinalDocumentData, GetSubmissionResponse, InvoiceLineItem, InvoiceSubmission, InvoiceV1_1, LegalMonetaryTotal, RegistrationType, ResponseDocument, SignedInfoObject, SignedInvoiceSubmission, SignedPropertiesData, SignedPropertiesObject, SigningCredentials, StandardError, SubmissionResponse, SubmissionStatus, Supplier, TaxCategory, TaxSubtotal, TaxTotal, UBLDocument } from "./documents-
|
|
18
|
+
import { Address, Buyer, CompleteInvoice, DocumentStatus, DocumentSummary, DocumentValidationResult, DocumentValidationStepResult, FinalDocumentData, GetSubmissionResponse, InvoiceLineItem, InvoiceSubmission, InvoiceV1_1, LegalMonetaryTotal, RegistrationType, ResponseDocument, SignedInfoObject, SignedInvoiceSubmission, SignedPropertiesData, SignedPropertiesObject, SigningCredentials, StandardError, SubmissionResponse, SubmissionStatus, Supplier, TaxCategory, TaxSubtotal, TaxTotal, UBLDocument } from "./documents-i5EV868Y.js";
|
|
19
19
|
import { PaymentMode, PaymentModeCode, PaymentModeCodeEnum } from "./payment-modes-BOTSRC_X.js";
|
|
20
20
|
import "./1X-BywXCqtn.js";
|
|
21
21
|
import "./2X-3fSEGIuE.js";
|
|
@@ -78,7 +78,7 @@ declare class MyInvoisClient {
|
|
|
78
78
|
* @param idValue - The value of the ID to validate against
|
|
79
79
|
* @returns true if the TIN is valid, false otherwise
|
|
80
80
|
*/
|
|
81
|
-
verifyTin(tin: string, idType:
|
|
81
|
+
verifyTin(tin: string, idType: RegistrationType, idValue: string): Promise<boolean>;
|
|
82
82
|
/**
|
|
83
83
|
* Submits one or more e-invoice documents to the MyInvois platform for processing.
|
|
84
84
|
*
|
package/dist/index21.cjs
CHANGED
|
@@ -1,208 +1,3 @@
|
|
|
1
|
+
const require_platformLogin = require('./platformLogin-PGzMhw1X.cjs');
|
|
1
2
|
|
|
2
|
-
|
|
3
|
-
let MSIC_0X = /* @__PURE__ */ function(MSIC_0X$1) {
|
|
4
|
-
MSIC_0X$1["NOT_APPLICABLE"] = "00000";
|
|
5
|
-
MSIC_0X$1["GROWING_OF_MAIZE"] = "01111";
|
|
6
|
-
MSIC_0X$1["GROWING_OF_LEGUMINOUS_CROPS"] = "01112";
|
|
7
|
-
MSIC_0X$1["GROWING_OF_OIL_SEEDS"] = "01113";
|
|
8
|
-
MSIC_0X$1["GROWING_OF_OTHER_CEREALS"] = "01119";
|
|
9
|
-
MSIC_0X$1["GROWING_OF_PADDY"] = "01120";
|
|
10
|
-
MSIC_0X$1["GROWING_OF_LEAFY_OR_STEM_VEGETABLES"] = "01131";
|
|
11
|
-
MSIC_0X$1["GROWING_OF_FRUITS_BEARING_VEGETABLES"] = "01132";
|
|
12
|
-
MSIC_0X$1["GROWING_OF_MELONS"] = "01133";
|
|
13
|
-
MSIC_0X$1["GROWING_OF_MUSHROOMS_AND_TRUFFLES"] = "01134";
|
|
14
|
-
MSIC_0X$1["GROWING_OF_VEGETABLES_SEEDS"] = "01135";
|
|
15
|
-
MSIC_0X$1["GROWING_OF_OTHER_VEGETABLES"] = "01136";
|
|
16
|
-
MSIC_0X$1["GROWING_OF_SUGAR_BEET"] = "01137";
|
|
17
|
-
MSIC_0X$1["GROWING_OF_ROOTS_TUBERS"] = "01138";
|
|
18
|
-
MSIC_0X$1["GROWING_OF_SUGAR_CANE"] = "01140";
|
|
19
|
-
MSIC_0X$1["GROWING_OF_TOBACCO"] = "01150";
|
|
20
|
-
MSIC_0X$1["GROWING_OF_FIBRE_CROPS"] = "01160";
|
|
21
|
-
MSIC_0X$1["GROWING_OF_FLOWERS"] = "01191";
|
|
22
|
-
MSIC_0X$1["GROWING_OF_FLOWER_SEEDS"] = "01192";
|
|
23
|
-
MSIC_0X$1["GROWING_OF_SAGO"] = "01193";
|
|
24
|
-
MSIC_0X$1["GROWING_OF_OTHER_NON_PERENNIAL_CROPS"] = "01199";
|
|
25
|
-
MSIC_0X$1["GROWING_OF_GRAPES"] = "01210";
|
|
26
|
-
MSIC_0X$1["GROWING_OF_BANANA"] = "01221";
|
|
27
|
-
MSIC_0X$1["GROWING_OF_MANGO"] = "01222";
|
|
28
|
-
MSIC_0X$1["GROWING_OF_DURIAN"] = "01223";
|
|
29
|
-
MSIC_0X$1["GROWING_OF_RAMBUTAN"] = "01224";
|
|
30
|
-
MSIC_0X$1["GROWING_OF_STAR_FRUIT"] = "01225";
|
|
31
|
-
MSIC_0X$1["GROWING_OF_PAPAYA"] = "01226";
|
|
32
|
-
MSIC_0X$1["GROWING_OF_PINEAPPLE"] = "01227";
|
|
33
|
-
MSIC_0X$1["GROWING_OF_PITAYA"] = "01228";
|
|
34
|
-
MSIC_0X$1["GROWING_OF_OTHER_TROPICAL_FRUITS"] = "01229";
|
|
35
|
-
MSIC_0X$1["GROWING_OF_POMELO"] = "01231";
|
|
36
|
-
MSIC_0X$1["GROWING_OF_LEMON_AND_LIMES"] = "01232";
|
|
37
|
-
MSIC_0X$1["GROWING_OF_TANGERINES_AND_MANDARIN"] = "01233";
|
|
38
|
-
MSIC_0X$1["GROWING_OF_OTHER_CITRUS_FRUITS"] = "01239";
|
|
39
|
-
MSIC_0X$1["GROWING_OF_GUAVA"] = "01241";
|
|
40
|
-
MSIC_0X$1["GROWING_OF_OTHER_POME_FRUITS"] = "01249";
|
|
41
|
-
MSIC_0X$1["GROWING_OF_BERRIES"] = "01251";
|
|
42
|
-
MSIC_0X$1["GROWING_OF_FRUIT_SEEDS"] = "01252";
|
|
43
|
-
MSIC_0X$1["GROWING_OF_EDIBLE_NUTS"] = "01253";
|
|
44
|
-
MSIC_0X$1["GROWING_OF_OTHER_TREE_AND_BUSH_FRUITS"] = "01259";
|
|
45
|
-
MSIC_0X$1["GROWING_OF_OIL_PALM_ESTATE"] = "01261";
|
|
46
|
-
MSIC_0X$1["GROWING_OF_OIL_PALM_SMALLHOLDINGS"] = "01262";
|
|
47
|
-
MSIC_0X$1["GROWING_OF_COCONUT"] = "01263";
|
|
48
|
-
MSIC_0X$1["GROWING_OF_OTHER_OLEAGINOUS_FRUITS"] = "01269";
|
|
49
|
-
MSIC_0X$1["GROWING_OF_COFFEE"] = "01271";
|
|
50
|
-
MSIC_0X$1["GROWING_OF_TEA"] = "01272";
|
|
51
|
-
MSIC_0X$1["GROWING_OF_COCOA"] = "01273";
|
|
52
|
-
MSIC_0X$1["GROWING_OF_OTHER_BEVERAGE_CROPS"] = "01279";
|
|
53
|
-
MSIC_0X$1["GROWING_OF_PEPPER"] = "01281";
|
|
54
|
-
MSIC_0X$1["GROWING_OF_CHILIES"] = "01282";
|
|
55
|
-
MSIC_0X$1["GROWING_OF_NUTMEG"] = "01283";
|
|
56
|
-
MSIC_0X$1["GROWING_OF_GINGER"] = "01284";
|
|
57
|
-
MSIC_0X$1["GROWING_OF_PLANTS_FOR_PHARMACY"] = "01285";
|
|
58
|
-
MSIC_0X$1["GROWING_OF_OTHER_SPICES"] = "01289";
|
|
59
|
-
MSIC_0X$1["GROWING_OF_RUBBER_TREES_ESTATE"] = "01291";
|
|
60
|
-
MSIC_0X$1["GROWING_OF_RUBBER_TREES_SMALLHOLDINGS"] = "01292";
|
|
61
|
-
MSIC_0X$1["GROWING_OF_TREES_FOR_SAP"] = "01293";
|
|
62
|
-
MSIC_0X$1["GROWING_OF_NIPA_PALM"] = "01294";
|
|
63
|
-
MSIC_0X$1["GROWING_OF_ARECA"] = "01295";
|
|
64
|
-
MSIC_0X$1["GROWING_OF_ROSELLE"] = "01296";
|
|
65
|
-
MSIC_0X$1["GROWING_OF_OTHER_PERENNIAL_CROPS"] = "01299";
|
|
66
|
-
MSIC_0X$1["GROWING_OF_PLANTS_FOR_PLANTING"] = "01301";
|
|
67
|
-
MSIC_0X$1["GROWING_OF_PLANTS_FOR_ORNAMENTAL"] = "01302";
|
|
68
|
-
MSIC_0X$1["GROWING_OF_LIVE_PLANTS"] = "01303";
|
|
69
|
-
MSIC_0X$1["OPERATION_OF_TREE_NURSERIES"] = "01304";
|
|
70
|
-
MSIC_0X$1["RAISING_CATTLE_OR_BUFFALOES"] = "01411";
|
|
71
|
-
MSIC_0X$1["PRODUCTION_OF_RAW_MILK"] = "01412";
|
|
72
|
-
MSIC_0X$1["PRODUCTION_OF_BOVINE_SEMEN"] = "01413";
|
|
73
|
-
MSIC_0X$1["RAISING_OF_HORSES"] = "01420";
|
|
74
|
-
MSIC_0X$1["RAISING_OF_CAMELS"] = "01430";
|
|
75
|
-
MSIC_0X$1["RAISING_OF_SHEEP_AND_GOATS"] = "01441";
|
|
76
|
-
MSIC_0X$1["PRODUCTION_OF_SHEEP_MILK"] = "01442";
|
|
77
|
-
MSIC_0X$1["PRODUCTION_OF_RAW_WOOL"] = "01443";
|
|
78
|
-
MSIC_0X$1["RAISING_OF_SWINE"] = "01450";
|
|
79
|
-
MSIC_0X$1["RAISING_OF_CHICKEN"] = "01461";
|
|
80
|
-
MSIC_0X$1["RAISING_OF_DUCKS"] = "01462";
|
|
81
|
-
MSIC_0X$1["RAISING_OF_GEESE"] = "01463";
|
|
82
|
-
MSIC_0X$1["RAISING_OF_QUAILS"] = "01464";
|
|
83
|
-
MSIC_0X$1["RAISING_OF_OTHER_POULTRY"] = "01465";
|
|
84
|
-
MSIC_0X$1["PRODUCTION_OF_CHICKEN_EGGS"] = "01466";
|
|
85
|
-
MSIC_0X$1["PRODUCTION_OF_DUCK_EGGS"] = "01467";
|
|
86
|
-
MSIC_0X$1["PRODUCTION_OF_OTHER_POULTRY_EGGS"] = "01468";
|
|
87
|
-
MSIC_0X$1["OPERATION_OF_POULTRY_HATCHERIES"] = "01469";
|
|
88
|
-
MSIC_0X$1["RAISING_OF_SEMI_DOMESTICATED"] = "01491";
|
|
89
|
-
MSIC_0X$1["PRODUCTION_OF_FUR_SKINS"] = "01492";
|
|
90
|
-
MSIC_0X$1["OPERATION_OF_WORM_FARMS"] = "01493";
|
|
91
|
-
MSIC_0X$1["RAISING_OF_SILK_WORMS"] = "01494";
|
|
92
|
-
MSIC_0X$1["BEE_KEEPING"] = "01495";
|
|
93
|
-
MSIC_0X$1["RAISING_OF_PET_ANIMALS"] = "01496";
|
|
94
|
-
MSIC_0X$1["RAISING_OF_SWIFLET"] = "01497";
|
|
95
|
-
MSIC_0X$1["RAISING_OF_DIVERSE_ANIMALS"] = "01499";
|
|
96
|
-
MSIC_0X$1["MIXED_FARMING"] = "01500";
|
|
97
|
-
MSIC_0X$1["AGRICULTURAL_ACTIVITIES_FOR_CROPS"] = "01610";
|
|
98
|
-
MSIC_0X$1["AGRICULTURAL_ACTIVITIES_FOR_ANIMALS"] = "01620";
|
|
99
|
-
MSIC_0X$1["PREPARATION_OF_CROPS"] = "01631";
|
|
100
|
-
MSIC_0X$1["PREPARATION_OF_TOBACCO_LEAVES"] = "01632";
|
|
101
|
-
MSIC_0X$1["PREPARATION_OF_COCOA_BEANS"] = "01633";
|
|
102
|
-
MSIC_0X$1["SUN_DRYING_OF_FRUITS"] = "01634";
|
|
103
|
-
MSIC_0X$1["SEED_PROCESSING"] = "01640";
|
|
104
|
-
MSIC_0X$1["HUNTING_AND_TRAPPING"] = "01701";
|
|
105
|
-
MSIC_0X$1["TAKING_OF_ANIMALS"] = "01702";
|
|
106
|
-
MSIC_0X$1["PLANTING_OF_FORESTS"] = "02101";
|
|
107
|
-
MSIC_0X$1["GROWING_OF_COPPICE"] = "02102";
|
|
108
|
-
MSIC_0X$1["OPERATION_OF_FOREST_NURSERIES"] = "02103";
|
|
109
|
-
MSIC_0X$1["COLLECTION_OF_WILDINGS"] = "02104";
|
|
110
|
-
MSIC_0X$1["FOREST_PLANTATION"] = "02105";
|
|
111
|
-
MSIC_0X$1["PRODUCTION_OF_ROUND_WOOD"] = "02201";
|
|
112
|
-
MSIC_0X$1["PRODUCTION_OF_UNPROCESSED_WOOD"] = "02202";
|
|
113
|
-
MSIC_0X$1["PRODUCTION_OF_CHARCOAL"] = "02203";
|
|
114
|
-
MSIC_0X$1["RUBBER_WOOD_LOGGING"] = "02204";
|
|
115
|
-
MSIC_0X$1["COLLECTION_OF_RATTAN"] = "02301";
|
|
116
|
-
MSIC_0X$1["BIRDS_NEST_COLLECTION"] = "02302";
|
|
117
|
-
MSIC_0X$1["WILD_SAGO_PALM_COLLECTION"] = "02303";
|
|
118
|
-
MSIC_0X$1["GATHERING_OF_NON_WOOD_FOREST"] = "02309";
|
|
119
|
-
MSIC_0X$1["FORESTRY_SERVICE_ACTIVITIES"] = "02401";
|
|
120
|
-
MSIC_0X$1["LOGGING_SERVICE_ACTIVITIES"] = "02402";
|
|
121
|
-
MSIC_0X$1["COMMERCIAL_OCEAN_FISHING"] = "03111";
|
|
122
|
-
MSIC_0X$1["COLLECTION_OF_MARINE_CRUSTACEANS"] = "03112";
|
|
123
|
-
MSIC_0X$1["TAKING_OF_AQUATIC_ANIMALS"] = "03113";
|
|
124
|
-
MSIC_0X$1["VESSELS_FOR_FISHING"] = "03114";
|
|
125
|
-
MSIC_0X$1["GATHERING_OF_MARINE_ORGANISMS"] = "03115";
|
|
126
|
-
MSIC_0X$1["MARINE_FISHING"] = "03119";
|
|
127
|
-
MSIC_0X$1["COMMERCIAL_INLAND_FISHING"] = "03121";
|
|
128
|
-
MSIC_0X$1["TAKING_OF_FRESHWATER_CRUSTACEANS"] = "03122";
|
|
129
|
-
MSIC_0X$1["TAKING_OF_FRESHWATER_ANIMALS"] = "03123";
|
|
130
|
-
MSIC_0X$1["GATHERING_OF_FRESHWATER_FLORA"] = "03124";
|
|
131
|
-
MSIC_0X$1["FRESHWATER_FISHING"] = "03129";
|
|
132
|
-
MSIC_0X$1["FISH_FARMING_SEA_WATER"] = "03211";
|
|
133
|
-
MSIC_0X$1["PRODUCTION_OF_BIVALVE_SPAT"] = "03212";
|
|
134
|
-
MSIC_0X$1["GROWING_OF_SEAWEEDS"] = "03213";
|
|
135
|
-
MSIC_0X$1["CULTURE_OF_CRUSTACEANS"] = "03214";
|
|
136
|
-
MSIC_0X$1["AQUACULTURE_IN_BRACKISH"] = "03215";
|
|
137
|
-
MSIC_0X$1["AQUACULTURE_IN_SALT_WATER"] = "03216";
|
|
138
|
-
MSIC_0X$1["OPERATION_OF_MARINE_HATCHERIES"] = "03217";
|
|
139
|
-
MSIC_0X$1["OPERATION_OF_MARINE_WORM_FARMS"] = "03218";
|
|
140
|
-
MSIC_0X$1["MARINE_AQUACULTURE"] = "03219";
|
|
141
|
-
MSIC_0X$1["FISH_FARMING_FRESHWATER"] = "03221";
|
|
142
|
-
MSIC_0X$1["SHRIMP_FARMING_FRESHWATER"] = "03222";
|
|
143
|
-
MSIC_0X$1["CULTURE_OF_FRESHWATER_CRUSTACEANS"] = "03223";
|
|
144
|
-
MSIC_0X$1["OPERATION_OF_FRESHWATER_HATCHERIES"] = "03224";
|
|
145
|
-
MSIC_0X$1["FARMING_OF_FROGS"] = "03225";
|
|
146
|
-
MSIC_0X$1["FRESHWATER_AQUACULTURE"] = "03229";
|
|
147
|
-
MSIC_0X$1["MINING_OF_HARD_COAL"] = "05100";
|
|
148
|
-
MSIC_0X$1["MINING_OF_LIGNITE"] = "05200";
|
|
149
|
-
MSIC_0X$1["EXTRACTION_OF_CRUDE_PETROLEUM"] = "06101";
|
|
150
|
-
MSIC_0X$1["EXTRACTION_OF_BITUMINOUS"] = "06102";
|
|
151
|
-
MSIC_0X$1["PRODUCTION_OF_CRUDE_PETROLEUM"] = "06103";
|
|
152
|
-
MSIC_0X$1["PROCESSES_TO_OBTAIN_CRUDE_OILS"] = "06104";
|
|
153
|
-
MSIC_0X$1["PRODUCTION_OF_NATURAL_GAS"] = "06201";
|
|
154
|
-
MSIC_0X$1["EXTRACTION_OF_CONDENSATES"] = "06202";
|
|
155
|
-
MSIC_0X$1["DRAINING_OF_HYDROCARBON"] = "06203";
|
|
156
|
-
MSIC_0X$1["GAS_DESULPHURIZATION"] = "06204";
|
|
157
|
-
MSIC_0X$1["MINING_OF_HYDROCARBON_LIQUIDS"] = "06205";
|
|
158
|
-
MSIC_0X$1["MINING_OF_IRON_ORES"] = "07101";
|
|
159
|
-
MSIC_0X$1["BENEFICIATION_OF_IRON_ORES"] = "07102";
|
|
160
|
-
MSIC_0X$1["MINING_OF_URANIUM"] = "07210";
|
|
161
|
-
MSIC_0X$1["MINING_OF_TIN"] = "07291";
|
|
162
|
-
MSIC_0X$1["MINING_OF_COPPER"] = "07292";
|
|
163
|
-
MSIC_0X$1["MINING_OF_BAUXITE"] = "07293";
|
|
164
|
-
MSIC_0X$1["MINING_OF_ILMENITE"] = "07294";
|
|
165
|
-
MSIC_0X$1["MINING_OF_GOLD"] = "07295";
|
|
166
|
-
MSIC_0X$1["MINING_OF_SILVER"] = "07296";
|
|
167
|
-
MSIC_0X$1["MINING_OF_PLATINUM"] = "07297";
|
|
168
|
-
MSIC_0X$1["AMANG_RETREATMENT"] = "07298";
|
|
169
|
-
MSIC_0X$1["MINING_OF_OTHER_NON_FERROUS"] = "07299";
|
|
170
|
-
MSIC_0X$1["QUARRYING_OF_STONE"] = "08101";
|
|
171
|
-
MSIC_0X$1["QUARRYING_OF_LIMESTONE"] = "08102";
|
|
172
|
-
MSIC_0X$1["MINING_OF_GYPSUM"] = "08103";
|
|
173
|
-
MSIC_0X$1["MINING_OF_CHALK"] = "08104";
|
|
174
|
-
MSIC_0X$1["EXTRACTION_OF_SAND"] = "08105";
|
|
175
|
-
MSIC_0X$1["BREAKING_OF_STONE"] = "08106";
|
|
176
|
-
MSIC_0X$1["QUARRYING_OF_SAND"] = "08107";
|
|
177
|
-
MSIC_0X$1["MINING_OF_CLAYS"] = "08108";
|
|
178
|
-
MSIC_0X$1["QUARRYING_OF_GRANITE"] = "08109";
|
|
179
|
-
MSIC_0X$1["MINING_OF_PHOSPHATES"] = "08911";
|
|
180
|
-
MSIC_0X$1["MINING_OF_POTASSIUM"] = "08912";
|
|
181
|
-
MSIC_0X$1["MINING_OF_SULPHUR"] = "08913";
|
|
182
|
-
MSIC_0X$1["EXTRACTION_OF_PYRITES"] = "08914";
|
|
183
|
-
MSIC_0X$1["MINING_OF_BARIUM"] = "08915";
|
|
184
|
-
MSIC_0X$1["MINING_OF_BORATES"] = "08916";
|
|
185
|
-
MSIC_0X$1["MINING_OF_EARTH_COLOURS"] = "08917";
|
|
186
|
-
MSIC_0X$1["GUANO_MINING"] = "08918";
|
|
187
|
-
MSIC_0X$1["PEAT_DIGGING"] = "08921";
|
|
188
|
-
MSIC_0X$1["PEAT_AGGLOMERATION"] = "08922";
|
|
189
|
-
MSIC_0X$1["PREPARATION_OF_PEAT"] = "08923";
|
|
190
|
-
MSIC_0X$1["EXTRACTION_OF_UNDERGROUND_SALT"] = "08931";
|
|
191
|
-
MSIC_0X$1["SALT_PRODUCTION"] = "08932";
|
|
192
|
-
MSIC_0X$1["CRUSHING_OF_SALT"] = "08933";
|
|
193
|
-
MSIC_0X$1["MINING_OF_ABRASIVE_MATERIALS"] = "08991";
|
|
194
|
-
MSIC_0X$1["MINING_OF_ASBESTOS"] = "08992";
|
|
195
|
-
MSIC_0X$1["MINING_OF_SILICEOUS"] = "08993";
|
|
196
|
-
MSIC_0X$1["MINING_OF_GRAPHITE"] = "08994";
|
|
197
|
-
MSIC_0X$1["MINING_OF_STEATITE"] = "08995";
|
|
198
|
-
MSIC_0X$1["MINING_OF_GEMSTONES"] = "08996";
|
|
199
|
-
MSIC_0X$1["OTHER_MINING"] = "08999";
|
|
200
|
-
MSIC_0X$1["OIL_AND_GAS_EXTRACTION"] = "09101";
|
|
201
|
-
MSIC_0X$1["OIL_AND_GAS_FIREFIGHTING"] = "09102";
|
|
202
|
-
MSIC_0X$1["SUPPORT_FOR_MINING"] = "09900";
|
|
203
|
-
return MSIC_0X$1;
|
|
204
|
-
}({});
|
|
205
|
-
|
|
206
|
-
//#endregion
|
|
207
|
-
exports.MSIC_0X = MSIC_0X;
|
|
208
|
-
//# sourceMappingURL=index21.cjs.map
|
|
3
|
+
exports.platformLogin = require_platformLogin.platformLogin;
|