@ripwords/myinvois-client 0.2.41 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +2 -2
- package/dist/api/notificationManagement.d.ts +2 -2
- package/dist/api/platformLogin.d.ts +2 -2
- package/dist/api/taxpayerValidation.d.ts +2 -2
- package/dist/apiQueue-B6Q644Bz.js +201 -0
- package/dist/apiQueue-DgKWaQDS.cjs +220 -0
- package/dist/apiQueue-DgKWaQDS.cjs.map +1 -0
- package/dist/{document-DLFdGSK1.js → document-D4O7JY0G.js} +9 -3
- package/dist/{document-CCza2JPL.cjs → document-DoQEvmcK.cjs} +10 -4
- package/dist/document-DoQEvmcK.cjs.map +1 -0
- package/dist/{documentSubmission-M4UlirJ7.cjs → documentSubmission-DUsjqWhR.cjs} +2 -2
- package/dist/{documentSubmission-M4UlirJ7.cjs.map → documentSubmission-DUsjqWhR.cjs.map} +1 -1
- package/dist/{documentSubmission-ZAgXsd3X.js → documentSubmission-uJ7yPWub.js} +1 -1
- package/dist/{documents-DCZ3Ffya.d.cts → documents-BECak3KN.d.cts} +7 -1
- package/dist/{documents-DzZA3NHj.d.ts → documents-Dp19RgNX.d.ts} +6 -0
- package/dist/index.cjs +3 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/index10.cjs +24 -4
- package/dist/index10.cjs.map +1 -0
- package/dist/index11.cjs +0 -22
- package/dist/index12.cjs +33 -2
- package/dist/index12.cjs.map +1 -0
- package/dist/index13.cjs +23 -2
- package/dist/index13.cjs.map +1 -0
- package/dist/index14.cjs +0 -330
- package/dist/index15.cjs +0 -193
- package/dist/index16.cjs +0 -62
- package/dist/index17.cjs +4 -531
- package/dist/index18.cjs +6 -195
- package/dist/index19.cjs +5 -0
- package/dist/index2.cjs +61 -4
- package/dist/index2.cjs.map +1 -0
- package/dist/index20.cjs +2 -24
- package/dist/index21.cjs +3 -0
- package/dist/index22.cjs +6 -0
- package/dist/index23.cjs +203 -24
- package/dist/index23.cjs.map +1 -1
- package/dist/index24.cjs +104 -20
- package/dist/index24.cjs.map +1 -1
- package/dist/index25.cjs +137 -0
- package/dist/{index33.cjs.map → index25.cjs.map} +1 -1
- package/dist/index26.cjs +59 -29
- package/dist/index26.cjs.map +1 -1
- package/dist/index27.cjs +262 -19
- package/dist/index27.cjs.map +1 -1
- package/dist/index28.cjs +79 -0
- package/dist/{index36.cjs.map → index28.cjs.map} +1 -1
- package/dist/index29.cjs +107 -0
- package/dist/{index37.cjs.map → index29.cjs.map} +1 -1
- package/dist/index3.cjs +531 -6
- package/dist/index3.cjs.map +1 -0
- package/dist/index30.cjs +73 -0
- package/dist/{index38.cjs.map → index30.cjs.map} +1 -1
- package/dist/index31.cjs +107 -203
- package/dist/index31.cjs.map +1 -1
- package/dist/index32.cjs +95 -104
- package/dist/index32.cjs.map +1 -1
- package/dist/index33.cjs +4 -136
- package/dist/index34.cjs +9 -60
- package/dist/index34.cjs.map +1 -1
- package/dist/index35.cjs +4 -266
- package/dist/index36.cjs +21 -78
- package/dist/index37.cjs +2 -106
- package/dist/index38.cjs +2 -72
- package/dist/index39.cjs +326 -108
- package/dist/index39.cjs.map +1 -1
- package/dist/index4.cjs +195 -4
- package/dist/index4.cjs.map +1 -0
- package/dist/index40.cjs +189 -96
- package/dist/index40.cjs.map +1 -1
- package/dist/index5.cjs +0 -3
- package/dist/index6.cjs +24 -2
- package/dist/index6.cjs.map +1 -0
- package/dist/index68.cts.map +1 -1
- package/dist/index7.cjs +0 -6
- package/dist/index71.cts.map +1 -1
- package/dist/index8.cjs +0 -4
- package/dist/index9.cjs +25 -9
- package/dist/index9.cjs.map +1 -1
- package/dist/{taxpayer-DmHW0m7o.d.ts → taxpayer-BdvCGHHC.d.ts} +1 -1
- package/dist/{taxpayer-Pm90MrPj.d.cts → taxpayer-CaDfslWB.d.cts} +2 -2
- 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/apiQueue.d.ts +11 -3
- package/dist/utils/apiQueue.js +2 -2
- package/dist/utils/document.d.ts +4 -3
- package/dist/utils/document.js +1 -1
- package/dist/utils/signature-diagnostics.d.ts +2 -2
- package/dist/utils/signature-diagnostics.js +1 -1
- package/dist/utils/validation.d.ts +2 -2
- package/package.json +1 -1
- package/dist/apiQueue-CCrZMnMu.js +0 -182
- package/dist/apiQueue-Djd7WlnV.cjs +0 -195
- package/dist/apiQueue-Djd7WlnV.cjs.map +0 -1
- package/dist/document-CCza2JPL.cjs.map +0 -1
- package/dist/index14.cjs.map +0 -1
- package/dist/index15.cjs.map +0 -1
- package/dist/index16.cjs.map +0 -1
- package/dist/index17.cjs.map +0 -1
- package/dist/index18.cjs.map +0 -1
- package/dist/index20.cjs.map +0 -1
- package/dist/index35.cjs.map +0 -1
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/utils/apiQueue.ts
|
|
3
|
-
const WINDOW = 6e4;
|
|
4
|
-
const RATE_LIMITS = {
|
|
5
|
-
loginTaxpayer: {
|
|
6
|
-
limit: 12,
|
|
7
|
-
windowMs: WINDOW
|
|
8
|
-
},
|
|
9
|
-
loginIntermediary: {
|
|
10
|
-
limit: 12,
|
|
11
|
-
windowMs: WINDOW
|
|
12
|
-
},
|
|
13
|
-
submitDocuments: {
|
|
14
|
-
limit: 100,
|
|
15
|
-
windowMs: WINDOW
|
|
16
|
-
},
|
|
17
|
-
getSubmission: {
|
|
18
|
-
limit: 300,
|
|
19
|
-
windowMs: WINDOW
|
|
20
|
-
},
|
|
21
|
-
cancelDocument: {
|
|
22
|
-
limit: 12,
|
|
23
|
-
windowMs: WINDOW
|
|
24
|
-
},
|
|
25
|
-
rejectDocument: {
|
|
26
|
-
limit: 12,
|
|
27
|
-
windowMs: WINDOW
|
|
28
|
-
},
|
|
29
|
-
getDocument: {
|
|
30
|
-
limit: 60,
|
|
31
|
-
windowMs: WINDOW
|
|
32
|
-
},
|
|
33
|
-
getDocumentDetails: {
|
|
34
|
-
limit: 125,
|
|
35
|
-
windowMs: WINDOW
|
|
36
|
-
},
|
|
37
|
-
getRecentDocuments: {
|
|
38
|
-
limit: 12,
|
|
39
|
-
windowMs: WINDOW
|
|
40
|
-
},
|
|
41
|
-
searchDocuments: {
|
|
42
|
-
limit: 12,
|
|
43
|
-
windowMs: WINDOW
|
|
44
|
-
},
|
|
45
|
-
searchTin: {
|
|
46
|
-
limit: 60,
|
|
47
|
-
windowMs: WINDOW
|
|
48
|
-
},
|
|
49
|
-
taxpayerQr: {
|
|
50
|
-
limit: 60,
|
|
51
|
-
windowMs: WINDOW
|
|
52
|
-
},
|
|
53
|
-
default: {
|
|
54
|
-
limit: 12,
|
|
55
|
-
windowMs: WINDOW
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* A token-bucket style rate-limiter with queuing.
|
|
60
|
-
* Uses a sliding window approach to allow bursts while respecting overall limits.
|
|
61
|
-
* Each category gets its own instance so limits remain isolated.
|
|
62
|
-
*/
|
|
63
|
-
var RateLimiter = class {
|
|
64
|
-
limit;
|
|
65
|
-
windowMs;
|
|
66
|
-
minInterval;
|
|
67
|
-
queue = [];
|
|
68
|
-
nextAvailable = 0;
|
|
69
|
-
timer = null;
|
|
70
|
-
requestTimes = [];
|
|
71
|
-
isProcessing = false;
|
|
72
|
-
constructor(config) {
|
|
73
|
-
this.limit = config.limit;
|
|
74
|
-
this.windowMs = config.windowMs;
|
|
75
|
-
this.minInterval = Math.ceil(this.windowMs / this.limit * .5);
|
|
76
|
-
}
|
|
77
|
-
drainQueue() {
|
|
78
|
-
if (this.isProcessing || this.queue.length === 0) return;
|
|
79
|
-
this.isProcessing = true;
|
|
80
|
-
try {
|
|
81
|
-
const now = Date.now();
|
|
82
|
-
this.requestTimes = this.requestTimes.filter((time) => now - time < this.windowMs);
|
|
83
|
-
if (this.requestTimes.length >= this.limit) {
|
|
84
|
-
const oldestRequest = Math.min(...this.requestTimes);
|
|
85
|
-
const nextAvailable = oldestRequest + this.windowMs;
|
|
86
|
-
this.scheduleNextDrain(nextAvailable - now);
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
if (now < this.nextAvailable) {
|
|
90
|
-
this.scheduleNextDrain(this.nextAvailable - now);
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
const next = this.queue.shift();
|
|
94
|
-
const requestStartTime = Date.now();
|
|
95
|
-
this.requestTimes.push(requestStartTime);
|
|
96
|
-
this.nextAvailable = requestStartTime + this.minInterval;
|
|
97
|
-
next();
|
|
98
|
-
} finally {
|
|
99
|
-
this.isProcessing = false;
|
|
100
|
-
}
|
|
101
|
-
if (this.queue.length > 0) {
|
|
102
|
-
const now = Date.now();
|
|
103
|
-
const delay = Math.max(1, this.nextAvailable - now);
|
|
104
|
-
this.scheduleNextDrain(delay);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
scheduleNextDrain(delay) {
|
|
108
|
-
if (this.timer) clearTimeout(this.timer);
|
|
109
|
-
this.timer = setTimeout(() => {
|
|
110
|
-
this.timer = null;
|
|
111
|
-
this.drainQueue();
|
|
112
|
-
}, Math.max(0, delay));
|
|
113
|
-
}
|
|
114
|
-
get queueSize() {
|
|
115
|
-
return this.queue.length;
|
|
116
|
-
}
|
|
117
|
-
cleanup() {
|
|
118
|
-
if (this.timer) {
|
|
119
|
-
clearTimeout(this.timer);
|
|
120
|
-
this.timer = null;
|
|
121
|
-
}
|
|
122
|
-
this.queue = [];
|
|
123
|
-
this.requestTimes = [];
|
|
124
|
-
this.isProcessing = false;
|
|
125
|
-
}
|
|
126
|
-
schedule(fn, debug = false, category) {
|
|
127
|
-
return new Promise((resolve, reject) => {
|
|
128
|
-
const execute = () => {
|
|
129
|
-
if (debug && category) console.log(`[apiQueue] ▶️ Executing request (${category}). Remaining queue: ${this.queue.length}`);
|
|
130
|
-
try {
|
|
131
|
-
const result = fn();
|
|
132
|
-
if (result && typeof result.then === "function") result.then(resolve).catch(reject);
|
|
133
|
-
else resolve(result);
|
|
134
|
-
} catch (err) {
|
|
135
|
-
reject(err);
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
if (debug && category) console.log(`[apiQueue] ⏳ Queued request (${category}). Queue length before push: ${this.queue.length}`);
|
|
139
|
-
this.queue.push(execute);
|
|
140
|
-
this.drainQueue();
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
const limiterRegistry = /* @__PURE__ */ new Map();
|
|
145
|
-
function getLimiter(clientId, category) {
|
|
146
|
-
if (!limiterRegistry.has(clientId)) limiterRegistry.set(clientId, /* @__PURE__ */ new Map());
|
|
147
|
-
const clientLimiters = limiterRegistry.get(clientId);
|
|
148
|
-
if (!clientLimiters.has(category)) clientLimiters.set(category, new RateLimiter(RATE_LIMITS[category]));
|
|
149
|
-
return clientLimiters.get(category);
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Public helper to schedule a request according to the category's limits.
|
|
153
|
-
* Rate limits are enforced per clientId, so multiple instances with the same
|
|
154
|
-
* clientId will share rate limiters, while different clientIds get separate limiters.
|
|
155
|
-
*/
|
|
156
|
-
function queueRequest(clientId, category, fn, debug = false) {
|
|
157
|
-
const limiter = getLimiter(clientId, category);
|
|
158
|
-
return limiter.schedule(fn, debug, category);
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Very naive path-based category detection. If no matcher fits, the `default` category
|
|
162
|
-
* (effectively unlimited) is returned. Adjust these heuristics as your API surface evolves.
|
|
163
|
-
*/
|
|
164
|
-
function categorizeRequest(path, method = "GET") {
|
|
165
|
-
const cleanPath = path.toLowerCase();
|
|
166
|
-
const isPost = method?.toUpperCase() === "POST";
|
|
167
|
-
if (cleanPath.includes("/documentsubmissions")) return isPost ? "submitDocuments" : "getSubmission";
|
|
168
|
-
if (cleanPath.includes("/documents/recent")) return "getRecentDocuments";
|
|
169
|
-
if (cleanPath.includes("/documents/search")) return "searchDocuments";
|
|
170
|
-
if (cleanPath.includes("/documents/state/") && cleanPath.endsWith("/state")) return "cancelDocument";
|
|
171
|
-
if (/\/documents\/[^/]+\/raw$/.test(cleanPath)) return "getDocument";
|
|
172
|
-
if (/\/documents\/[^/]+\/details$/.test(cleanPath)) return "getDocumentDetails";
|
|
173
|
-
if (cleanPath.includes("/taxpayer/search/tin")) return "searchTin";
|
|
174
|
-
if (cleanPath.includes("/taxpayer/validate/")) return "searchTin";
|
|
175
|
-
if (cleanPath.includes("/taxpayer/qrcode")) return "taxpayerQr";
|
|
176
|
-
if (cleanPath.includes("/searchtin")) return "searchTin";
|
|
177
|
-
if (cleanPath.includes("/qrcode")) return "taxpayerQr";
|
|
178
|
-
if (cleanPath.includes("/connect/token")) return "loginTaxpayer";
|
|
179
|
-
return "default";
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
//#endregion
|
|
183
|
-
Object.defineProperty(exports, 'categorizeRequest', {
|
|
184
|
-
enumerable: true,
|
|
185
|
-
get: function () {
|
|
186
|
-
return categorizeRequest;
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
Object.defineProperty(exports, 'queueRequest', {
|
|
190
|
-
enumerable: true,
|
|
191
|
-
get: function () {
|
|
192
|
-
return queueRequest;
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
//# sourceMappingURL=apiQueue-Djd7WlnV.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"apiQueue-Djd7WlnV.cjs","names":["RATE_LIMITS: Record<ApiCategory, RateLimitConfig>","config: RateLimitConfig","delay: number","fn: () => Promise<T>","debug: boolean","category?: ApiCategory","clientId: string","category: ApiCategory","path: string","method: string"],"sources":["../src/utils/apiQueue.ts"],"sourcesContent":["// A very small utility that provides per-endpoint request queuing with fixed-window rate-limits.\n// The goal is to make sure that we never exceed the vendor-defined limits while also ensuring\n// that every request is eventually executed.\n//\n// NOTE: This is intentionally minimal – no external dependencies are introduced.\n// If you need more advanced features (persistence, jitter, etc.) consider a library such as `bottleneck`.\n\n/*\nRate-limit specification (per 60-second window)\n----------------------------------------------\nLogin as Taxpayer System : 12\nLogin as Intermediary System : 12\nSubmit Documents : 100\nGet Submission : 300\nCancel Document : 12\nReject Document : 12\nGet Document : 60\nGet Document Details : 125\nGet Recent Documents : 12\nSearch Documents : 12\nSearch Taxpayer's TIN : 60\nTaxpayer's QR Code : 60\n*/\n\nexport type ApiCategory =\n | 'loginTaxpayer'\n | 'loginIntermediary'\n | 'submitDocuments'\n | 'getSubmission'\n | 'cancelDocument'\n | 'rejectDocument'\n | 'getDocument'\n | 'getDocumentDetails'\n | 'getRecentDocuments'\n | 'searchDocuments'\n | 'searchTin'\n | 'taxpayerQr'\n | 'default'\n\ninterface RateLimitConfig {\n limit: number\n windowMs: number\n}\n\nconst WINDOW = 60_000 // 60 seconds\n\n// Hard-coded limits based on the specification above.\nconst RATE_LIMITS: Record<ApiCategory, RateLimitConfig> = {\n loginTaxpayer: { limit: 12, windowMs: WINDOW },\n loginIntermediary: { limit: 12, windowMs: WINDOW },\n submitDocuments: { limit: 100, windowMs: WINDOW },\n getSubmission: { limit: 300, windowMs: WINDOW },\n cancelDocument: { limit: 12, windowMs: WINDOW },\n rejectDocument: { limit: 12, windowMs: WINDOW },\n getDocument: { limit: 60, windowMs: WINDOW },\n getDocumentDetails: { limit: 125, windowMs: WINDOW },\n getRecentDocuments: { limit: 12, windowMs: WINDOW },\n searchDocuments: { limit: 12, windowMs: WINDOW },\n searchTin: { limit: 60, windowMs: WINDOW },\n taxpayerQr: { limit: 60, windowMs: WINDOW },\n default: { limit: 12, windowMs: WINDOW }, // minimum limit\n}\n\n/**\n * A token-bucket style rate-limiter with queuing.\n * Uses a sliding window approach to allow bursts while respecting overall limits.\n * Each category gets its own instance so limits remain isolated.\n */\nclass RateLimiter {\n private readonly limit: number\n private readonly windowMs: number\n private readonly minInterval: number\n\n private queue: Array<() => void> = []\n private nextAvailable = 0 // timestamp (ms) when the next request can be executed\n private timer: NodeJS.Timeout | null = null\n private requestTimes: number[] = [] // Track request timestamps for sliding window\n private isProcessing = false // Prevent race conditions in drainQueue\n\n constructor(config: RateLimitConfig) {\n this.limit = config.limit\n this.windowMs = config.windowMs\n // Use a more reasonable interval that allows bursts while preventing 429s\n // Allow bursts up to 50% of the limit, then space out remaining requests\n this.minInterval = Math.ceil((this.windowMs / this.limit) * 0.5) // 50% of even spacing\n }\n\n private drainQueue() {\n // Prevent race conditions by ensuring only one drainQueue runs at a time\n if (this.isProcessing || this.queue.length === 0) {\n return\n }\n\n this.isProcessing = true\n\n try {\n const now = Date.now()\n\n // Clean up old request times outside the window\n this.requestTimes = this.requestTimes.filter(\n time => now - time < this.windowMs,\n )\n\n // Check if we can make another request within the rate limit\n if (this.requestTimes.length >= this.limit) {\n // We've hit the limit, schedule for when the oldest request expires\n const oldestRequest = Math.min(...this.requestTimes)\n const nextAvailable = oldestRequest + this.windowMs\n\n this.scheduleNextDrain(nextAvailable - now)\n return\n }\n\n // Check minimum interval constraint\n if (now < this.nextAvailable) {\n // Too early – schedule when we're allowed to execute next\n this.scheduleNextDrain(this.nextAvailable - now)\n return\n }\n\n // Execute the next queued task\n const next = this.queue.shift()!\n const requestStartTime = Date.now()\n this.requestTimes.push(requestStartTime)\n this.nextAvailable = requestStartTime + this.minInterval\n\n // Execute the request immediately\n next()\n } finally {\n this.isProcessing = false\n }\n\n // After resetting isProcessing, check if there are more requests\n // and schedule the next drain with appropriate delay\n if (this.queue.length > 0) {\n // Calculate delay until we can process the next request\n const now = Date.now()\n const delay = Math.max(1, this.nextAvailable - now)\n\n // Use scheduleNextDrain to ensure only one timer is active\n this.scheduleNextDrain(delay)\n }\n }\n\n private scheduleNextDrain(delay: number) {\n if (this.timer) {\n clearTimeout(this.timer)\n }\n\n this.timer = setTimeout(\n () => {\n this.timer = null\n this.drainQueue()\n },\n Math.max(0, delay),\n )\n }\n\n get queueSize() {\n return this.queue.length\n }\n\n // Cleanup method to prevent memory leaks\n cleanup() {\n if (this.timer) {\n clearTimeout(this.timer)\n this.timer = null\n }\n this.queue = []\n this.requestTimes = []\n this.isProcessing = false\n }\n\n schedule<T>(\n fn: () => Promise<T>,\n debug: boolean = false,\n category?: ApiCategory,\n ): Promise<T> {\n return new Promise((resolve, reject) => {\n const execute = () => {\n if (debug && category) {\n console.log(\n `[apiQueue] ▶️ Executing request (${category}). Remaining queue: ${this.queue.length}`,\n )\n }\n try {\n const result = fn()\n if (result && typeof (result as any).then === 'function') {\n ;(result as Promise<T>).then(resolve).catch(reject)\n } else {\n resolve(result as T)\n }\n } catch (err) {\n reject(err)\n }\n }\n\n if (debug && category) {\n console.log(\n `[apiQueue] ⏳ Queued request (${category}). Queue length before push: ${this.queue.length}`,\n )\n }\n\n this.queue.push(execute)\n this.drainQueue()\n })\n }\n}\n\n// A shared registry of limiters keyed by clientId, then by category\n// This ensures that different clientIds get separate rate limiters,\n// while multiple instances with the same clientId share the same limiters.\nconst limiterRegistry = new Map<string, Map<ApiCategory, RateLimiter>>()\n\nfunction getLimiter(clientId: string, category: ApiCategory): RateLimiter {\n if (!limiterRegistry.has(clientId)) {\n limiterRegistry.set(clientId, new Map<ApiCategory, RateLimiter>())\n }\n\n const clientLimiters = limiterRegistry.get(clientId)!\n\n if (!clientLimiters.has(category)) {\n clientLimiters.set(category, new RateLimiter(RATE_LIMITS[category]))\n }\n\n return clientLimiters.get(category)!\n}\n\n/**\n * Public helper to schedule a request according to the category's limits.\n * Rate limits are enforced per clientId, so multiple instances with the same\n * clientId will share rate limiters, while different clientIds get separate limiters.\n */\nexport function queueRequest<T>(\n clientId: string,\n category: ApiCategory,\n fn: () => Promise<T>,\n debug: boolean = false,\n): Promise<T> {\n const limiter = getLimiter(clientId, category)\n return limiter.schedule(fn, debug, category)\n}\n\n/**\n * Very naive path-based category detection. If no matcher fits, the `default` category\n * (effectively unlimited) is returned. Adjust these heuristics as your API surface evolves.\n */\nexport function categorizeRequest(\n path: string,\n method: string = 'GET',\n): ApiCategory {\n const cleanPath = path.toLowerCase()\n const isPost = method?.toUpperCase() === 'POST'\n\n if (cleanPath.includes('/documentsubmissions')) {\n return isPost ? 'submitDocuments' : 'getSubmission'\n }\n\n // -----------------------------\n // v1.0 API endpoint matchers\n // -----------------------------\n\n // Get Recent Documents - /api/v1.0/documents/recent\n if (cleanPath.includes('/documents/recent')) {\n return 'getRecentDocuments'\n }\n\n // Search Documents - /api/v1.0/documents/search\n if (cleanPath.includes('/documents/search')) {\n return 'searchDocuments'\n }\n\n // Document state actions (cancel/reject) - PUT /api/v1.0/documents/state/{uuid}/state\n // Both cancel and reject use the same endpoint, differentiated only by request body\n if (cleanPath.includes('/documents/state/') && cleanPath.endsWith('/state')) {\n // Both cancelDocument and rejectDocument share the same rate limit (12 RPM)\n // Use cancelDocument category for both since they share the same bucket\n return 'cancelDocument'\n }\n\n // Document raw content - /api/v1.0/documents/{uuid}/raw\n if (/\\/documents\\/[^/]+\\/raw$/.test(cleanPath)) {\n return 'getDocument'\n }\n\n // Document details - /api/v1.0/documents/{uuid}/details\n if (/\\/documents\\/[^/]+\\/details$/.test(cleanPath)) {\n return 'getDocumentDetails'\n }\n\n // Taxpayer TIN search & validation share same limit bucket\n if (cleanPath.includes('/taxpayer/search/tin')) return 'searchTin'\n if (cleanPath.includes('/taxpayer/validate/')) return 'searchTin'\n\n // Taxpayer QR code info\n if (cleanPath.includes('/taxpayer/qrcode')) return 'taxpayerQr'\n\n // Legacy matchers (kept for backward compatibility)\n if (cleanPath.includes('/searchtin')) return 'searchTin'\n if (cleanPath.includes('/qrcode')) return 'taxpayerQr'\n if (cleanPath.includes('/connect/token')) {\n return 'loginTaxpayer'\n }\n\n return 'default'\n}\n"],"mappings":";;AA4CA,MAAM,SAAS;AAGf,MAAMA,cAAoD;CACxD,eAAe;EAAE,OAAO;EAA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AAI,UAAU,SAAS,iBAAiB,CACtC,QAAO;AAGT,QAAO;AACR"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"document-CCza2JPL.cjs","names":["item: InvoiceLineItem","doc: AllDocumentsV1_1","obj: unknown","sortedObj: Record<string, unknown>","invoice: AllDocumentsV1_1","invoices: AllDocumentsV1_1[]","invoice: InvoiceSubmission","certificatePem: string","X509Certificate","str: string","issuer: string","serialHex: string","error: unknown","certificateDigest: string","signingTime: string","issuerName: string","serialNumber: string","signedProperties: SignedPropertiesObject","useTargetWrapper: boolean","digestObj: unknown","docDigest: string","propsDigest: string","privateKeyPem: string","signedInfo: SignedInfoObject","documentString: string","signingCredentials: SigningCredentials","params: {\n itemClassificationCode: ClassificationCode\n itemDescription: string\n unitPrice: number\n quantity?: number\n taxType: TaxTypeCode\n taxRate: number\n totalTaxableAmountPerLine?: number\n discountAmount?: number\n discountRate?: number\n}","params: {\n itemClassificationCode: ClassificationCode\n itemDescription: string\n unitPrice: number\n quantity?: number\n taxType: TaxTypeCode\n taxPerUnitAmount: number\n baseUnitMeasure: number\n baseUnitMeasureCode: UnitTypeCode\n totalTaxableAmountPerLine?: number\n discountAmount?: number\n discountRate?: number\n}","lineItems: InvoiceLineItem[]"],"sources":["../src/utils/document.ts"],"sourcesContent":["import crypto, { X509Certificate } from 'crypto'\nimport {\n InvoiceSubmission,\n AllDocumentsV1_1,\n SigningCredentials,\n SignedPropertiesObject,\n UBLDocument,\n CompleteInvoice,\n SignedInfoObject,\n UnitTypeCode,\n InvoiceLineItem,\n} from '../types'\nimport type { ClassificationCode } from '../types'\nimport type { TaxTypeCode } from '../types'\nimport { formatIdValue } from './formatIdValue'\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 * Determines if a line item uses fixed rate taxation\n */\nexport const isFixedRateTax = (item: InvoiceLineItem): boolean => {\n return (\n item.taxPerUnitAmount !== undefined && item.baseUnitMeasure !== undefined\n )\n}\n\n/**\n * Determines if a line item uses percentage taxation\n */\nexport const isPercentageTax = (item: InvoiceLineItem): boolean => {\n return item.taxRate !== undefined && !isFixedRateTax(item)\n}\n\n/**\n * Calculates expected tax amount for a line item based on its tax type\n */\nexport const calculateExpectedTaxAmount = (item: InvoiceLineItem): number => {\n if (isFixedRateTax(item)) {\n return item.taxPerUnitAmount! * item.baseUnitMeasure!\n } else if (isPercentageTax(item)) {\n return (item.totalTaxableAmountPerLine * item.taxRate!) / 100\n }\n return 0\n}\n\n/**\n * Extracts the line-item array from any document variant\n */\nconst getLineItems = (doc: AllDocumentsV1_1): InvoiceLineItem[] => {\n if ('invoiceLineItems' in doc) return doc.invoiceLineItems\n if ('creditNoteLineItems' in doc) return doc.creditNoteLineItems\n if ('debitNoteLineItems' in doc) return doc.debitNoteLineItems\n if ('refundNoteLineItems' in doc) return doc.refundNoteLineItems\n if ('selfBilledCreditNoteLineItems' in doc)\n return doc.selfBilledCreditNoteLineItems\n if ('selfBilledRefundNoteLineItems' in doc)\n return doc.selfBilledRefundNoteLineItems\n // Fallback (should never happen with exhaustive types)\n return []\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: AllDocumentsV1_1,\n): InvoiceSubmission => {\n const lineItems = getLineItems(invoice)\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 // === BILLING REFERENCE (only for credit/debit/refund notes) ===\n ...('originalEInvoiceReferenceNumber' in invoice &&\n 'originalEInvoiceInternalId' in invoice &&\n invoice.originalEInvoiceReferenceNumber\n ? {\n BillingReference: [\n {\n InvoiceDocumentReference: [\n {\n UUID: [\n {\n _: invoice.originalEInvoiceReferenceNumber,\n },\n ],\n ID: [\n {\n _: invoice.originalEInvoiceInternalId,\n },\n ],\n },\n ],\n },\n ],\n }\n : {}),\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 _: formatIdValue(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 _: formatIdValue(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: [{ _: lineItems[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: lineItems.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 _:\n (item.totalTaxableAmountPerLine ?? 0) +\n (item.discountAmount ?? 0),\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 // Line-level discount (AllowanceCharge with ChargeIndicator=false) – include only if a discount exists\n ...(item.discountAmount !== undefined || item.discountRate !== undefined\n ? {\n AllowanceCharge: [\n {\n ChargeIndicator: [{ _: false }],\n Amount: [\n {\n _: item.discountAmount ?? 0,\n currencyID: invoice.invoiceCurrencyCode,\n },\n ],\n ...(item.discountRate !== undefined\n ? {\n MultiplierFactorNumeric: [{ _: item.discountRate }],\n BaseAmount: [\n {\n _:\n (item.totalTaxableAmountPerLine ?? 0) +\n (item.discountAmount ?? 0),\n currencyID: invoice.invoiceCurrencyCode,\n },\n ],\n }\n : {}),\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 // Conditional tax fields based on taxation type\n ...(item.taxPerUnitAmount !== undefined &&\n item.baseUnitMeasure !== undefined\n ? {\n // Fixed Rate Taxation\n PerUnitAmount: [\n {\n _: item.taxPerUnitAmount,\n currencyID: invoice.invoiceCurrencyCode,\n },\n ],\n BaseUnitMeasure: [\n {\n _: item.baseUnitMeasure,\n unitCode: item.baseUnitMeasureCode || 'C62',\n },\n ],\n }\n : item.taxRate !== undefined\n ? {\n // Percentage Taxation\n Percent: [{ _: item.taxRate }],\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: AllDocumentsV1_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 1: Transform the document for hashing or transmission\n * Removes UBLExtensions and Signature, and minifies the JSON\n * Returns the minified, cleaned JSON string\n *\n * FIXED: Use regex-based minification to match PowerShell script exactly\n */\nexport const transformDocumentForHashing = (\n invoices: AllDocumentsV1_1[],\n): string => {\n // Generate clean UBL document structure\n const cleanDocument = generateCleanUBLDocument(invoices)\n\n // Deep clone to avoid mutating input\n const documentForTransform = JSON.parse(JSON.stringify(cleanDocument))\n if (\n documentForTransform.Invoice &&\n Array.isArray(documentForTransform.Invoice)\n ) {\n documentForTransform.Invoice.forEach((invoice: InvoiceSubmission) => {\n delete invoice.UBLExtensions\n delete invoice.Signature\n })\n }\n\n // Convert to JSON string first\n const jsonString = JSON.stringify(documentForTransform)\n\n // Apply the exact same regex-based minification as PowerShell script\n // This regex preserves whitespace within quoted strings but removes all other whitespace\n const minifiedJson = jsonString.replace(\n /(\"(?:\\\\.|[^\"\\\\])*\")|\\s+/g,\n (match, quotedString) => {\n if (quotedString) {\n return quotedString // Keep string content exactly as-is\n } else {\n return '' // Remove all other whitespace\n }\n },\n )\n\n return minifiedJson\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 = (\n invoices: AllDocumentsV1_1[],\n): string => {\n // Use the transformation function to get the minified, cleaned JSON string\n const documentString = transformDocumentForHashing(invoices)\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 * FIXED: Match PowerShell script exactly - use raw certificate data like $cert.RawData\n */\nexport const calculateCertificateDigest = (certificatePem: string): string => {\n try {\n // Create X509Certificate object to get raw data (like PowerShell $cert.RawData)\n const cert = new X509Certificate(certificatePem)\n\n // Get the raw certificate data (DER-encoded, like PowerShell $cert.RawData)\n const rawCertificateData = cert.raw\n\n // Calculate SHA-256 hash of raw certificate data (like PowerShell $sha256.ComputeHash($cert.RawData))\n const hash = crypto.createHash('sha256')\n hash.update(rawCertificateData)\n\n // Return as Base64 (like PowerShell [Convert]::ToBase64String($certHash))\n return hash.digest('base64')\n } catch {\n // Fallback to the previous method if X509Certificate fails\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/**\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 // FIXED: Use raw issuer name like PowerShell $cert.IssuerName.Name\n // Apply XML escaping to match PowerShell [System.Security.SecurityElement]::Escape()\n const escapeXmlSpecialChars = (str: string): string => {\n return str\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"')\n .replace(/'/g, ''')\n }\n\n // FIXED: Normalize issuer name to match MyInvois expectations\n // The issuer name should be in the format: \"CN=Trial LHDNM Sub CA V1, OU=Terms of use at http://www.testcertcomp.com.my, O=LHDNM, C=MY\"\n const normalizeIssuerName = (issuer: string): string => {\n // Node returns issuer DN in reverse RDN order (C, O, ... , CN).\n // The MyInvois validator expects forward order (CN first).\n // 1. Break DN into components separated by newline or commas.\n // 2. Reverse to get CN → ... → C ordering.\n // 3. Join with \", \" and ensure single '=' spacing.\n const parts = issuer\n .split(/\\r?\\n|,\\s*/)\n .map(part => part.trim())\n .filter(part => part.length > 0)\n .reverse()\n return parts.join(', ').replace(/\\s*=\\s*/g, '=')\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 // FIXED: Use raw subject name without normalization to match PowerShell $cert.SubjectName.Name\n // The subject name should be in the format shown in the specification\n const rawSubjectName = cert.subject\n\n return {\n issuerName: escapeXmlSpecialChars(normalizeIssuerName(cert.issuer)),\n serialNumber: formatSerialNumber(serialNumberHex),\n subjectName: rawSubjectName, // Use raw subject name like PowerShell\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 _: '',\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 * Calculates the digest over the correct structure for validator compliance.\n * FIXED: Calculate digest from SignedProperties only (without Target wrapper)\n */\nexport const calculateSignedPropertiesDigest = (\n signedProperties: SignedPropertiesObject,\n useTargetWrapper: boolean = true, // Changed to true - validator calculates digest from embedded structure with Target wrapper\n): string => {\n let digestObj: unknown\n if (useTargetWrapper) {\n digestObj = {\n Target: 'signature',\n SignedProperties: signedProperties.SignedProperties,\n }\n } else {\n digestObj = signedProperties.SignedProperties\n }\n\n // FIXED: Don't sort object keys - use exact structure as embedded\n // The validator calculates digest from the exact embedded structure\n const signedPropertiesString = JSON.stringify(digestObj)\n\n // Apply the same regex-based minification as the document transformation\n const minifiedSignedProperties = signedPropertiesString.replace(\n /(\"(?:\\\\.|[^\"\\\\])*\")|\\s+/g,\n (match, quotedString) => {\n if (quotedString) {\n return quotedString // Keep string content exactly as-is\n } else {\n return '' // Remove all other whitespace\n }\n },\n )\n\n const hash = crypto.createHash('sha256')\n hash.update(minifiedSignedProperties, 'utf8')\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: SignedInfoObject = {\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 // Serialize the SignedInfo exactly as it will be embedded (no reordering)\n const signedInfoRaw = JSON.stringify(signedInfo)\n\n try {\n const signer = crypto.createSign('RSA-SHA256')\n signer.update(signedInfoRaw, 'utf8')\n const signatureValue = signer.sign(privateKeyPem, 'base64')\n\n // Reuse the original object so ordering is preserved\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 * Signs the minified document string using the provided private key PEM\n * Returns the signature as a base64 string\n * FIXED: Match PowerShell script exactly - first compute hash, then sign the hash\n */\nexport const signDocumentString = (\n documentString: string,\n privateKeyPem: string,\n): string => {\n // Create signer with RSA-SHA256 (matches PowerShell RSAPKCS1SignatureFormatter)\n const signer = crypto.createSign('RSA-SHA256')\n signer.update(documentString, 'utf8')\n return signer.sign(privateKeyPem, 'base64')\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: AllDocumentsV1_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 // Get the minified, cleaned JSON string for signing\n const documentString = transformDocumentForHashing(invoices)\n\n // Step 3: Sign the minified document string (not the digest)\n const docSignature = signDocumentString(\n documentString,\n signingCredentials.privateKeyPem,\n )\n\n // Generate signing time in proper ISO format matching PowerShell exactly\n // PowerShell: Get-Date -Format \"yyyy-MM-ddTHH:mm:ssZ\"\n const now = new Date()\n const signingTime =\n now.getFullYear() +\n '-' +\n String(now.getMonth() + 1).padStart(2, '0') +\n '-' +\n String(now.getDate()).padStart(2, '0') +\n 'T' +\n String(now.getHours()).padStart(2, '0') +\n ':' +\n String(now.getMinutes()).padStart(2, '0') +\n ':' +\n String(now.getSeconds()).padStart(2, '0') +\n 'Z'\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 using the dedicated function\n const propsDigest = calculateSignedPropertiesDigest(signedProperties)\n\n // Create simple SignedInfo structure (matching PowerShell approach)\n const signedInfo: SignedInfoObject = {\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 // Extract certificate content using raw data (like PowerShell $cert.RawData)\n const cert = new X509Certificate(signingCredentials.certificatePem)\n const certificate = cert.raw.toString('base64')\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: [{ _: docSignature }],\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\n/**\n * Creates a line item with percentage-based taxation (e.g., SST, GST)\n */\nexport const createPercentageTaxLineItem = (params: {\n itemClassificationCode: ClassificationCode\n itemDescription: string\n unitPrice: number\n quantity?: number\n taxType: TaxTypeCode\n taxRate: number\n totalTaxableAmountPerLine?: number\n discountAmount?: number\n discountRate?: number\n}): InvoiceLineItem => {\n const quantity = params.quantity || 1\n // Compute pre-discount from unit price and quantity only to avoid double-discounting\n const preDiscountAmount = params.unitPrice * quantity\n const hasDiscount =\n params.discountAmount !== undefined || params.discountRate !== undefined\n const computedDiscountByRate =\n hasDiscount && params.discountRate !== undefined\n ? preDiscountAmount * params.discountRate\n : 0\n const discountAmount =\n hasDiscount && params.discountAmount !== undefined\n ? params.discountAmount\n : computedDiscountByRate\n const totalTaxableAmount = Math.max(\n 0,\n preDiscountAmount - (hasDiscount ? discountAmount : 0),\n )\n const taxAmount = (totalTaxableAmount * params.taxRate) / 100\n\n return {\n itemClassificationCode: params.itemClassificationCode,\n itemDescription: params.itemDescription,\n unitPrice: params.unitPrice,\n taxType: params.taxType,\n taxRate: params.taxRate,\n ...(hasDiscount && discountAmount !== undefined ? { discountAmount } : {}),\n ...(hasDiscount && params.discountRate !== undefined\n ? { discountRate: params.discountRate }\n : {}),\n taxAmount: Math.round(taxAmount * 100) / 100, // Round to 2 decimal places\n totalTaxableAmountPerLine: totalTaxableAmount,\n totalAmountPerLine: totalTaxableAmount + taxAmount,\n }\n}\n\n/**\n * Creates a line item with fixed rate taxation (e.g., Tourism Tax)\n */\nexport const createFixedRateTaxLineItem = (params: {\n itemClassificationCode: ClassificationCode\n itemDescription: string\n unitPrice: number\n quantity?: number\n taxType: TaxTypeCode\n taxPerUnitAmount: number\n baseUnitMeasure: number\n baseUnitMeasureCode: UnitTypeCode\n totalTaxableAmountPerLine?: number\n discountAmount?: number\n discountRate?: number\n}): InvoiceLineItem => {\n const quantity = params.quantity || 1\n // Compute pre-discount from unit price and quantity only to avoid double-discounting\n const preDiscountAmount = params.unitPrice * quantity\n const hasDiscount =\n params.discountAmount !== undefined || params.discountRate !== undefined\n const computedDiscountByRate =\n hasDiscount && params.discountRate !== undefined\n ? preDiscountAmount * params.discountRate\n : 0\n const discountAmount =\n hasDiscount && params.discountAmount !== undefined\n ? params.discountAmount\n : computedDiscountByRate\n const totalTaxableAmount = Math.max(\n 0,\n preDiscountAmount - (hasDiscount ? discountAmount : 0),\n )\n const taxAmount = params.taxPerUnitAmount * params.baseUnitMeasure\n\n return {\n itemClassificationCode: params.itemClassificationCode,\n itemDescription: params.itemDescription,\n unitPrice: params.unitPrice,\n taxType: params.taxType,\n taxPerUnitAmount: params.taxPerUnitAmount,\n baseUnitMeasure: params.baseUnitMeasure,\n baseUnitMeasureCode: params.baseUnitMeasureCode,\n ...(hasDiscount && discountAmount !== undefined ? { discountAmount } : {}),\n ...(hasDiscount && params.discountRate !== undefined\n ? { discountRate: params.discountRate }\n : {}),\n taxAmount: Math.round(taxAmount * 100) / 100, // Round to 2 decimal places\n totalTaxableAmountPerLine: totalTaxableAmount,\n totalAmountPerLine: totalTaxableAmount + taxAmount,\n }\n}\n\n/**\n * Calculates invoice totals from line items\n */\nexport const calculateInvoiceTotals = (\n lineItems: InvoiceLineItem[],\n): {\n legalMonetaryTotal: {\n taxExclusiveAmount: number\n taxInclusiveAmount: number\n payableAmount: number\n }\n taxTotal: {\n taxAmount: number\n }\n} => {\n const taxExclusiveAmount = lineItems.reduce(\n (sum, item) => sum + item.totalTaxableAmountPerLine,\n 0,\n )\n const totalTaxAmount = lineItems.reduce(\n (sum, item) => sum + item.taxAmount,\n 0,\n )\n const taxInclusiveAmount = taxExclusiveAmount + totalTaxAmount\n\n return {\n legalMonetaryTotal: {\n taxExclusiveAmount: Math.round(taxExclusiveAmount * 100) / 100,\n taxInclusiveAmount: Math.round(taxInclusiveAmount * 100) / 100,\n payableAmount: Math.round(taxInclusiveAmount * 100) / 100,\n },\n taxTotal: {\n taxAmount: Math.round(totalTaxAmount * 100) / 100,\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAyBA,MAAa,iBAAiB,CAACA,SAAmC;AAChE,QACE,KAAK,+BAAkC,KAAK;AAE/C;;;;AAKD,MAAa,kBAAkB,CAACA,SAAmC;AACjE,QAAO,KAAK,uBAA0B,eAAe,KAAK;AAC3D;;;;AAKD,MAAa,6BAA6B,CAACA,SAAkC;AAC3E,KAAI,eAAe,KAAK,CACtB,QAAO,KAAK,mBAAoB,KAAK;UAC5B,gBAAgB,KAAK,CAC9B,QAAQ,KAAK,4BAA4B,KAAK,UAAY;AAE5D,QAAO;AACR;;;;AAKD,MAAM,eAAe,CAACC,QAA6C;AACjE,KAAI,sBAAsB,IAAK,QAAO,IAAI;AAC1C,KAAI,yBAAyB,IAAK,QAAO,IAAI;AAC7C,KAAI,wBAAwB,IAAK,QAAO,IAAI;AAC5C,KAAI,yBAAyB,IAAK,QAAO,IAAI;AAC7C,KAAI,mCAAmC,IACrC,QAAO,IAAI;AACb,KAAI,mCAAmC,IACrC,QAAO,IAAI;AAEb,QAAO,CAAE;AACV;;;;AAKD,SAAgB,eAAeC,KAAuB;AACpD,KAAI,QAAQ,eAAe,QAAQ,SACjC,QAAO;AAGT,KAAI,MAAM,QAAQ,IAAI,CACpB,QAAO,IAAI,IAAI,eAAe;CAGhC,MAAMC,YAAqC,CAAE;CAC7C,MAAM,OAAO,OAAO,KAAK,IAA+B,CAAC,MAAM;AAE/D,MAAK,MAAM,OAAO,KAChB,WAAU,OAAO,eAAgB,IAAgC,KAAK;AAGxE,QAAO;AACR;;;;;AAMD,MAAa,mBAAmB,CAACD,QAAyB;CACxD,MAAM,YAAY,eAAe,IAAI;AAErC,QAAO,KAAK,UAAU,WAAW,MAAM,EAAE;AAC1C;;;;;;;;;;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B,EAAE,eAAgB,IAAG,CAAE;EACzE,GAAI,eAAe,OAAO,0BACtB,EAAE,cAAc,OAAO,aAAc,IACrC,CAAE;EACN,WAAW,KAAK,MAAM,YAAY,IAAI,GAAG;EACzC,2BAA2B;EAC3B,oBAAoB,qBAAqB;CAC1C;AACF;;;;AAKD,MAAa,yBAAyB,CACpCC,cAUG;CACH,MAAM,qBAAqB,UAAU,OACnC,CAAC,KAAK,SAAS,MAAM,KAAK,2BAC1B,EACD;CACD,MAAM,iBAAiB,UAAU,OAC/B,CAAC,KAAK,SAAS,MAAM,KAAK,WAC1B,EACD;CACD,MAAM,qBAAqB,qBAAqB;AAEhD,QAAO;EACL,oBAAoB;GAClB,oBAAoB,KAAK,MAAM,qBAAqB,IAAI,GAAG;GAC3D,oBAAoB,KAAK,MAAM,qBAAqB,IAAI,GAAG;GAC3D,eAAe,KAAK,MAAM,qBAAqB,IAAI,GAAG;EACvD;EACD,UAAU,EACR,WAAW,KAAK,MAAM,iBAAiB,IAAI,GAAG,IAC/C;CACF;AACF"}
|
package/dist/index14.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index14.cjs","names":["certificatePem: string","issues: string[]","recommendations: string[]","dn: string","fields: Record<string, string>","invoices: InvoiceV1_1[]","str: string","result: DiagnosticResult"],"sources":["../src/utils/signature-diagnostics.ts"],"sourcesContent":["import crypto from 'crypto'\nimport type { InvoiceV1_1 } from '../types'\nimport {\n extractCertificateInfo,\n calculateDocumentDigest,\n calculateSignedPropertiesDigest,\n createSignedProperties,\n calculateCertificateDigest,\n} from './document'\n\nexport interface CertificateAnalysisResult {\n organizationIdentifier?: string\n serialNumber?: string\n issuerName: string\n subjectName: string\n issues: string[]\n recommendations: string[]\n}\n\nexport interface SignatureAnalysisResult {\n documentDigest: string\n certificateDigest: string\n signedPropertiesDigest: string\n issues: string[]\n recommendations: string[]\n}\n\nexport interface DiagnosticResult {\n certificateAnalysis: CertificateAnalysisResult\n signatureAnalysis: SignatureAnalysisResult\n summary: {\n totalIssues: number\n certificateIssues: number\n signatureIssues: number\n }\n}\n\n/**\n * Analyzes certificate for MyInvois compatibility issues\n */\nfunction analyzeCertificateForDiagnostics(\n certificatePem: string,\n): CertificateAnalysisResult {\n const issues: string[] = []\n const recommendations: string[] = []\n\n try {\n const cert = new crypto.X509Certificate(certificatePem)\n const certInfo = extractCertificateInfo(certificatePem)\n\n // Parse subject fields for MyInvois analysis\n const parseSubjectFields = (dn: string) => {\n const fields: Record<string, string> = {}\n dn.split('\\n').forEach(line => {\n const trimmed = line.trim()\n if (trimmed.includes('=')) {\n const [key, ...valueParts] = trimmed.split('=')\n if (key) {\n fields[key.trim()] = valueParts.join('=').trim()\n }\n }\n })\n return fields\n }\n\n const subjectFields = parseSubjectFields(cert.subject)\n const organizationIdentifier =\n subjectFields['organizationIdentifier'] || subjectFields['2.5.4.97']\n const serialNumber = subjectFields['serialNumber']\n\n // DS311 - TIN Mismatch Analysis\n if (!organizationIdentifier) {\n issues.push(\n 'DS311: Certificate missing organizationIdentifier field (TIN)',\n )\n recommendations.push(\n 'CRITICAL: Generate new certificate with organizationIdentifier matching your MyInvois TIN',\n )\n recommendations.push(\n 'Portal Error: \"Signer of invoice doesn\\'t match the submitter of document. TIN doesn\\'t match with the OI.\"',\n )\n } else {\n // Additional TIN format validation\n if (organizationIdentifier.length < 10) {\n issues.push(\n 'DS311: OrganizationIdentifier (TIN) appears too short - may cause submission rejection',\n )\n recommendations.push(\n 'Verify TIN format matches exactly what is registered in MyInvois',\n )\n }\n }\n\n // DS312 - Registration Number Analysis\n if (!serialNumber) {\n issues.push(\n 'DS312: Certificate missing serialNumber field (business registration)',\n )\n recommendations.push(\n 'CRITICAL: Generate new certificate with serialNumber matching your business registration',\n )\n recommendations.push(\n 'Portal Error: \"Submitter registration/identity number doesn\\'t match with the certificate SERIALNUMBER.\"',\n )\n }\n\n // DS329 - Certificate Trust Analysis\n if (cert.issuer === cert.subject) {\n issues.push(\n 'DS329: Self-signed certificate detected - will fail chain of trust validation',\n )\n recommendations.push(\n 'BLOCKING: Obtain certificate from MyInvois-approved CA:',\n )\n recommendations.push('• MSC Trustgate Sdn Bhd')\n recommendations.push('• DigiCert Sdn Bhd')\n recommendations.push('• Cybersign Asia Sdn Bhd')\n recommendations.push(\n 'Portal Error: \"Certificate is not valid according to the chain of trust validation or has been issued by an untrusted certificate authority.\"',\n )\n } else {\n // Check if issuer looks like a known CA\n const issuerName = cert.issuer.toLowerCase()\n const approvedCAs = ['msc trustgate', 'digicert', 'cybersign']\n const isFromApprovedCA = approvedCAs.some(ca => issuerName.includes(ca))\n\n if (!isFromApprovedCA) {\n issues.push('DS329: Certificate may not be from MyInvois-approved CA')\n recommendations.push(\n 'Verify certificate was issued by an approved CA for MyInvois',\n )\n }\n }\n\n // DS326 - Issuer Name Format Analysis (Enhanced)\n const rawIssuer = cert.issuer\n const normalizedIssuer = certInfo.issuerName\n\n // Check for issues in the NORMALIZED issuer (these are actual problems)\n const normalizedIssuerIssues = [\n {\n check: normalizedIssuer.includes('\\n'),\n issue: 'Normalized issuer still contains newlines',\n },\n {\n check: normalizedIssuer.includes(' '),\n issue: 'Normalized issuer contains double spaces',\n },\n {\n check: /=\\s+/.test(normalizedIssuer),\n issue: 'Normalized issuer has spaces after equals',\n },\n {\n check: /\\s+=/.test(normalizedIssuer),\n issue: 'Normalized issuer has spaces before equals',\n },\n {\n check: normalizedIssuer.includes('\\r'),\n issue: 'Normalized issuer contains carriage returns',\n },\n ]\n\n // Only report actual issues in the normalized version that will cause portal errors\n const hasActualFormatIssues = normalizedIssuerIssues.some(\n ({ check, issue }) => {\n if (check) {\n issues.push(`DS326: ${issue} - will cause X509IssuerName mismatch`)\n return true\n }\n return false\n },\n )\n\n // Check if raw issuer has issues but normalized version is OK (informational)\n const hasRawIssuesButNormalizedOk =\n rawIssuer.includes('\\n') && !normalizedIssuer.includes('\\n')\n\n if (hasActualFormatIssues) {\n recommendations.push(\n 'CRITICAL: Fix issuer name normalization in signature generation',\n )\n recommendations.push(\n 'Portal Error: \"Certificate X509IssuerName doesn\\'t match the X509IssuerName value provided in the signed properties section.\"',\n )\n recommendations.push(\n 'The normalization function is not properly formatting the issuer name',\n )\n recommendations.push(\n 'Debug: Check document.ts extractCertificateInfo() normalization logic',\n )\n } else if (hasRawIssuesButNormalizedOk) {\n // This is informational - normalization is working correctly\n console.log(\n 'ℹ️ Note: Raw certificate issuer has newlines but normalization is handling them correctly',\n )\n }\n\n // Additional certificate validity checks\n const now = new Date()\n const validFrom = new Date(cert.validFrom)\n const validTo = new Date(cert.validTo)\n\n if (now < validFrom) {\n issues.push('DS329: Certificate not yet valid (future start date)')\n recommendations.push('Wait until certificate validity period begins')\n }\n\n if (now > validTo) {\n issues.push('DS329: Certificate has expired')\n recommendations.push(\n 'BLOCKING: Renew certificate - expired certificates are rejected',\n )\n }\n\n // Check certificate key usage (if available)\n try {\n if (cert.keyUsage && !cert.keyUsage.includes('digital signature')) {\n issues.push('DS333: Certificate lacks digitalSignature key usage')\n recommendations.push(\n 'Generate new certificate with digitalSignature key usage enabled',\n )\n }\n } catch {\n // Key usage might not be available in all certificates\n console.log('Note: Could not check key usage extensions')\n }\n\n return {\n organizationIdentifier,\n serialNumber,\n issuerName: certInfo.issuerName,\n subjectName: certInfo.subjectName,\n issues,\n recommendations,\n }\n } catch (error) {\n issues.push(`Certificate parsing failed: ${error}`)\n recommendations.push('Verify certificate format and validity')\n\n return {\n issuerName: '',\n subjectName: '',\n issues,\n recommendations,\n }\n }\n}\n\n/**\n * Analyzes signature generation for potential issues\n */\nfunction analyzeSignatureForDiagnostics(\n invoices: InvoiceV1_1[],\n certificatePem: string,\n): SignatureAnalysisResult {\n const issues: string[] = []\n const recommendations: string[] = []\n\n try {\n // Step 1: Document digest\n const documentDigest = calculateDocumentDigest(invoices)\n\n // Step 2: Certificate digest\n const certificateDigest = calculateCertificateDigest(certificatePem)\n\n // Step 3: Extract certificate info\n const certInfo = extractCertificateInfo(certificatePem)\n const signingTime = new Date().toISOString()\n\n // Step 4: Create signed properties\n const signedProperties = createSignedProperties(\n certificateDigest,\n signingTime,\n certInfo.issuerName,\n certInfo.serialNumber,\n )\n\n // Step 5: Signed properties digest\n const signedPropertiesDigest =\n calculateSignedPropertiesDigest(signedProperties)\n\n // DS333 - Document Signature Validation\n if (documentDigest.length === 0) {\n issues.push('DS333: Document digest generation failed')\n recommendations.push(\n 'CRITICAL: Verify document serialization excludes UBLExtensions/Signature',\n )\n recommendations.push(\n 'Portal Error: \"Document signature value is not a valid signature of the document digest using the public key of the certificate provided.\"',\n )\n }\n\n if (certificateDigest.length === 0) {\n issues.push('DS333: Certificate digest generation failed')\n recommendations.push('CRITICAL: Verify certificate format and encoding')\n recommendations.push(\n 'Certificate must be properly base64 encoded without headers/footers',\n )\n }\n\n if (signedPropertiesDigest.length === 0) {\n issues.push('DS333: Signed properties digest generation failed')\n recommendations.push(\n 'CRITICAL: Verify signed properties structure and canonicalization',\n )\n recommendations.push(\n 'Check XML canonicalization (C14N) is applied correctly',\n )\n }\n\n // Additional DS333 checks\n try {\n const cert = new crypto.X509Certificate(certificatePem)\n\n // Verify the certificate has the required algorithms for MyInvois\n const publicKey = cert.publicKey\n const keyDetails = publicKey.asymmetricKeyDetails\n\n if (keyDetails) {\n // Check if key size is adequate for RSA (minimum 2048 bits)\n if (\n publicKey.asymmetricKeyType === 'rsa' &&\n keyDetails.modulusLength &&\n keyDetails.modulusLength < 2048\n ) {\n issues.push(\n 'DS333: RSA key size too small (minimum 2048 bits required)',\n )\n recommendations.push(\n 'CRITICAL: Generate new certificate with RSA 2048+ bits',\n )\n }\n\n // Check supported key types\n const supportedKeyTypes = ['rsa', 'ec']\n if (!supportedKeyTypes.includes(publicKey.asymmetricKeyType || '')) {\n issues.push(\n `DS333: Unsupported key type: ${publicKey.asymmetricKeyType}`,\n )\n recommendations.push(\n 'CRITICAL: Use RSA or EC key types for MyInvois compatibility',\n )\n }\n }\n\n // Test certificate format validity\n const certBuffer = Buffer.from(\n certificatePem.replace(/-----[^-]+-----/g, '').replace(/\\s/g, ''),\n 'base64',\n )\n if (certBuffer.length === 0) {\n issues.push('DS333: Certificate encoding appears invalid')\n recommendations.push(\n 'CRITICAL: Verify certificate is properly PEM encoded',\n )\n }\n } catch (error) {\n issues.push(`DS333: Certificate validation failed - ${error}`)\n recommendations.push(\n 'CRITICAL: Verify certificate format and structure are valid',\n )\n }\n\n // Validate digest formats (should be base64)\n const isValidBase64 = (str: string) => {\n try {\n return Buffer.from(str, 'base64').toString('base64') === str\n } catch {\n return false\n }\n }\n\n if (documentDigest && !isValidBase64(documentDigest)) {\n issues.push('DS333: Document digest is not valid base64 format')\n recommendations.push('Ensure digest is properly base64 encoded')\n }\n\n if (certificateDigest && !isValidBase64(certificateDigest)) {\n issues.push('DS333: Certificate digest is not valid base64 format')\n recommendations.push(\n 'Ensure certificate digest is properly base64 encoded',\n )\n }\n\n if (signedPropertiesDigest && !isValidBase64(signedPropertiesDigest)) {\n issues.push('DS333: Signed properties digest is not valid base64 format')\n recommendations.push(\n 'Ensure signed properties digest is properly base64 encoded',\n )\n }\n\n return {\n documentDigest,\n certificateDigest,\n signedPropertiesDigest,\n issues,\n recommendations,\n }\n } catch (error) {\n issues.push(`Signature analysis failed: ${error}`)\n recommendations.push('Review signature generation implementation')\n\n return {\n documentDigest: '',\n certificateDigest: '',\n signedPropertiesDigest: '',\n issues,\n recommendations,\n }\n }\n}\n\n/**\n * Comprehensive signature diagnostics\n */\nexport function diagnoseSignatureIssues(\n invoices: InvoiceV1_1[],\n certificatePem: string,\n): DiagnosticResult {\n const certificateAnalysis = analyzeCertificateForDiagnostics(certificatePem)\n const signatureAnalysis = analyzeSignatureForDiagnostics(\n invoices,\n certificatePem,\n )\n\n const certificateIssues = certificateAnalysis.issues.length\n const signatureIssues = signatureAnalysis.issues.length\n\n return {\n certificateAnalysis,\n signatureAnalysis,\n summary: {\n totalIssues: certificateIssues + signatureIssues,\n certificateIssues,\n signatureIssues,\n },\n }\n}\n\n/**\n * Prints diagnostic results in a formatted way\n */\nexport function printDiagnostics(result: DiagnosticResult): void {\n console.log('\\n🔍 MyInvois Signature Diagnostics Report')\n console.log('='.repeat(60))\n\n // Certificate Analysis\n console.log('\\n📜 CERTIFICATE ANALYSIS')\n console.log('-'.repeat(30))\n\n console.log(` Issuer: ${result.certificateAnalysis.issuerName}`)\n console.log(` Subject: ${result.certificateAnalysis.subjectName}`)\n\n if (result.certificateAnalysis.organizationIdentifier) {\n console.log(\n ` Organization ID (TIN): ${result.certificateAnalysis.organizationIdentifier}`,\n )\n }\n\n if (result.certificateAnalysis.serialNumber) {\n console.log(` Serial Number: ${result.certificateAnalysis.serialNumber}`)\n }\n\n if (result.certificateAnalysis.issues.length > 0) {\n console.log('\\n 🚨 Certificate Issues:')\n result.certificateAnalysis.issues.forEach((issue, index) => {\n console.log(` ${index + 1}. ${issue}`)\n })\n }\n\n if (result.certificateAnalysis.recommendations.length > 0) {\n console.log('\\n 💡 Certificate Recommendations:')\n result.certificateAnalysis.recommendations.forEach((rec, index) => {\n console.log(` ${index + 1}. ${rec}`)\n })\n }\n\n // Signature Analysis\n console.log('\\n🔐 SIGNATURE ANALYSIS')\n console.log('-'.repeat(30))\n\n console.log(\n ` Document Digest: ${result.signatureAnalysis.documentDigest.substring(0, 32)}...`,\n )\n console.log(\n ` Certificate Digest: ${result.signatureAnalysis.certificateDigest.substring(0, 32)}...`,\n )\n console.log(\n ` Signed Properties Digest: ${result.signatureAnalysis.signedPropertiesDigest.substring(0, 32)}...`,\n )\n\n if (result.signatureAnalysis.issues.length > 0) {\n console.log('\\n 🚨 Signature Issues:')\n result.signatureAnalysis.issues.forEach((issue, index) => {\n console.log(` ${index + 1}. ${issue}`)\n })\n }\n\n if (result.signatureAnalysis.recommendations.length > 0) {\n console.log('\\n 💡 Signature Recommendations:')\n result.signatureAnalysis.recommendations.forEach((rec, index) => {\n console.log(` ${index + 1}. ${rec}`)\n })\n }\n\n // Summary\n console.log('\\n📊 SUMMARY')\n console.log('-'.repeat(30))\n console.log(` Total Issues Found: ${result.summary.totalIssues}`)\n console.log(` Certificate Issues: ${result.summary.certificateIssues}`)\n console.log(` Signature Issues: ${result.summary.signatureIssues}`)\n\n if (result.summary.totalIssues === 0) {\n console.log('\\n ✅ No issues detected in current analysis')\n console.log(' 🎉 Certificate and signature implementation appear valid')\n } else {\n console.log('\\n ⚠️ Issues detected - review recommendations above')\n\n // Check for specific portal errors\n const hasDS311 = result.certificateAnalysis.issues.some(issue =>\n issue.includes('DS311'),\n )\n const hasDS312 = result.certificateAnalysis.issues.some(issue =>\n issue.includes('DS312'),\n )\n const hasDS326 = result.certificateAnalysis.issues.some(issue =>\n issue.includes('DS326'),\n )\n const hasDS329 = result.certificateAnalysis.issues.some(issue =>\n issue.includes('DS329'),\n )\n const hasDS333 = result.signatureAnalysis.issues.some(issue =>\n issue.includes('DS333'),\n )\n\n console.log('\\n 🎯 MYINVOIS PORTAL ERROR ANALYSIS:')\n\n if (hasDS311) {\n console.log(\n ' ❌ DS311 - TIN mismatch between certificate and submitter',\n )\n }\n\n if (hasDS312) {\n console.log(\n ' ❌ DS312 - Registration number mismatch with certificate',\n )\n }\n\n if (hasDS326) {\n console.log(' ❌ DS326 - X509IssuerName format inconsistency')\n }\n\n if (hasDS329) {\n console.log(' ❌ DS329 - Certificate trust chain validation failure')\n }\n\n if (hasDS333) {\n console.log(' ❌ DS333 - Document signature validation failure')\n }\n\n if (result.summary.certificateIssues > 0) {\n console.log('\\n 🚨 PRIMARY ACTION REQUIRED:')\n console.log(' Certificate issues must be resolved first')\n console.log(\n ' Self-generated certificates cannot pass MyInvois validation',\n )\n }\n\n if (result.summary.signatureIssues > 0) {\n console.log('\\n ⚙️ SECONDARY ACTION:')\n console.log(' Review and optimize signature implementation')\n }\n\n console.log('\\n 📋 NEXT STEPS:')\n console.log(' 1. Address BLOCKING/CRITICAL issues first')\n console.log(' 2. Test with updated certificate/implementation')\n console.log(' 3. Re-run diagnostics to verify fixes')\n console.log(' 4. Submit test document to MyInvois portal')\n }\n\n console.log('\\n' + '='.repeat(60))\n}\n"],"mappings":";;;;;;;;;AAwCA,SAAS,iCACPA,gBAC2B;CAC3B,MAAMC,SAAmB,CAAE;CAC3B,MAAMC,kBAA4B,CAAE;AAEpC,KAAI;EACF,MAAM,OAAO,IAAI,eAAO,gBAAgB;EACxC,MAAM,WAAW,wCAAuB,eAAe;EAGvD,MAAM,qBAAqB,CAACC,OAAe;GACzC,MAAMC,SAAiC,CAAE;AACzC,MAAG,MAAM,KAAK,CAAC,QAAQ,UAAQ;IAC7B,MAAM,UAAU,KAAK,MAAM;AAC3B,QAAI,QAAQ,SAAS,IAAI,EAAE;KACzB,MAAM,CAAC,KAAK,GAAG,WAAW,GAAG,QAAQ,MAAM,IAAI;AAC/C,SAAI,IACF,QAAO,IAAI,MAAM,IAAI,WAAW,KAAK,IAAI,CAAC,MAAM;IAEnD;GACF,EAAC;AACF,UAAO;EACR;EAED,MAAM,gBAAgB,mBAAmB,KAAK,QAAQ;EACtD,MAAM,yBACJ,cAAc,6BAA6B,cAAc;EAC3D,MAAM,eAAe,cAAc;AAGnC,OAAK,wBAAwB;AAC3B,UAAO,KACL,gEACD;AACD,mBAAgB,KACd,4FACD;AACD,mBAAgB,KACd,8GACD;EACF,WAEK,uBAAuB,SAAS,IAAI;AACtC,UAAO,KACL,yFACD;AACD,mBAAgB,KACd,mEACD;EACF;AAIH,OAAK,cAAc;AACjB,UAAO,KACL,wEACD;AACD,mBAAgB,KACd,2FACD;AACD,mBAAgB,KACd,4GACD;EACF;AAGD,MAAI,KAAK,WAAW,KAAK,SAAS;AAChC,UAAO,KACL,gFACD;AACD,mBAAgB,KACd,0DACD;AACD,mBAAgB,KAAK,0BAA0B;AAC/C,mBAAgB,KAAK,qBAAqB;AAC1C,mBAAgB,KAAK,2BAA2B;AAChD,mBAAgB,KACd,kJACD;EACF,OAAM;GAEL,MAAM,aAAa,KAAK,OAAO,aAAa;GAC5C,MAAM,cAA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ACD;AAGH,MAAI,SACF,SAAQ,IACN,+DACD;AAGH,MAAI,SACF,SAAQ,IAAI,qDAAqD;AAGnE,MAAI,SACF,SAAQ,IAAI,4DAA4D;AAG1E,MAAI,SACF,SAAQ,IAAI,uDAAuD;AAGrE,MAAI,OAAO,QAAQ,oBAAoB,GAAG;AACxC,WAAQ,IAAI,kCAAkC;AAC9C,WAAQ,IAAI,iDAAiD;AAC7D,WAAQ,IACN,mEACD;EACF;AAED,MAAI,OAAO,QAAQ,kBAAkB,GAAG;AACtC,WAAQ,IAAI,4BAA4B;AACxC,WAAQ,IAAI,oDAAoD;EACjE;AAED,UAAQ,IAAI,qBAAqB;AACjC,UAAQ,IAAI,iDAAiD;AAC7D,UAAQ,IAAI,uDAAuD;AACnE,UAAQ,IAAI,6CAA6C;AACzD,UAAQ,IAAI,kDAAkD;CAC/D;AAED,SAAQ,IAAI,OAAO,IAAI,OAAO,GAAG,CAAC;AACnC"}
|
package/dist/index15.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index15.cjs","names":["tin: string","registrationType?: string","errors: ValidationError[]","contactNumber: string","amount: number","fieldName: string","item: InvoiceLineItem","index: number","invoice: InvoiceV1_1","allErrors: ValidationError[]"],"sources":["../src/utils/validation.ts"],"sourcesContent":["import type { InvoiceV1_1, InvoiceLineItem } from '../types'\n\n/**\n * MyInvois Invoice Validation Utilities\n *\n * Provides comprehensive validation for invoice data before document generation\n * and submission to ensure compliance with MyInvois business rules and format requirements.\n */\n\nexport interface ValidationResult {\n isValid: boolean\n errors: ValidationError[]\n warnings: ValidationWarning[]\n}\n\nexport interface ValidationError {\n field: string\n code: string\n message: string\n severity: 'error' | 'warning'\n}\n\nexport interface ValidationWarning extends ValidationError {\n severity: 'warning'\n}\n\n/**\n * Validates TIN format based on registration type\n */\nexport const validateTIN = (\n tin: string,\n registrationType?: string,\n): ValidationError[] => {\n const errors: ValidationError[] = []\n\n if (!tin) {\n errors.push({\n field: 'tin',\n code: 'TIN_REQUIRED',\n message: 'TIN is required',\n severity: 'error',\n })\n return errors\n }\n\n // TIN format validation based on type\n if (registrationType === 'BRN' && !tin.startsWith('C')) {\n errors.push({\n field: 'tin',\n code: 'TIN_FORMAT_INVALID',\n message: 'Company TIN should start with \"C\" for BRN registration',\n severity: 'warning',\n })\n }\n\n if (registrationType === 'NRIC' && !tin.startsWith('IG')) {\n errors.push({\n field: 'tin',\n code: 'TIN_FORMAT_INVALID',\n message: 'Individual TIN should start with \"IG\" for NRIC registration',\n severity: 'warning',\n })\n }\n\n // Length validation\n if (tin.length > 14) {\n errors.push({\n field: 'tin',\n code: 'TIN_LENGTH_INVALID',\n message: 'TIN cannot exceed 14 characters',\n severity: 'error',\n })\n }\n\n return errors\n}\n\n/**\n * Validates contact number format (E.164 standard)\n */\nexport const validateContactNumber = (\n contactNumber: string,\n): ValidationError[] => {\n const errors: ValidationError[] = []\n\n if (!contactNumber || contactNumber === 'NA') {\n return errors // Allow NA for consolidated e-invoices\n }\n\n // E.164 format validation\n const e164Regex = /^\\+[1-9]\\d{1,14}$/\n if (!e164Regex.test(contactNumber)) {\n errors.push({\n field: 'contactNumber',\n code: 'CONTACT_FORMAT_INVALID',\n message: 'Contact number must be in E.164 format (e.g., +60123456789)',\n severity: 'error',\n })\n }\n\n if (contactNumber.length < 8) {\n errors.push({\n field: 'contactNumber',\n code: 'CONTACT_LENGTH_INVALID',\n message: 'Contact number must be at least 8 characters',\n severity: 'error',\n })\n }\n\n return errors\n}\n\n/**\n * Validates monetary amounts\n */\nexport const validateMonetaryAmount = (\n amount: number,\n fieldName: string,\n maxDigits = 18,\n maxDecimals = 2,\n): ValidationError[] => {\n const errors: ValidationError[] = []\n\n if (amount < 0) {\n errors.push({\n field: fieldName,\n code: 'AMOUNT_NEGATIVE',\n message: `${fieldName} cannot be negative`,\n severity: 'error',\n })\n }\n\n // Check total digits\n const amountStr = amount.toString()\n const [integerPart, decimalPart] = amountStr.split('.')\n\n if (integerPart && integerPart.length > maxDigits - maxDecimals) {\n errors.push({\n field: fieldName,\n code: 'AMOUNT_DIGITS_EXCEEDED',\n message: `${fieldName} exceeds maximum ${maxDigits} digits`,\n severity: 'error',\n })\n }\n\n if (decimalPart && decimalPart.length > maxDecimals) {\n errors.push({\n field: fieldName,\n code: 'AMOUNT_DECIMALS_EXCEEDED',\n message: `${fieldName} exceeds maximum ${maxDecimals} decimal places`,\n severity: 'error',\n })\n }\n\n return errors\n}\n\n/**\n * Validates line item tax calculation consistency for both fixed rate and percentage taxation\n */\nexport const validateLineItemTax = (\n item: InvoiceLineItem,\n index: number,\n): ValidationError[] => {\n const errors: ValidationError[] = []\n const tolerance = 0.01\n\n // Check if tax calculation method is specified\n const hasFixedRate =\n item.taxPerUnitAmount !== undefined && item.baseUnitMeasure !== undefined\n const hasPercentageRate = item.taxRate !== undefined\n\n if (!hasFixedRate && !hasPercentageRate) {\n errors.push({\n field: `lineItem[${index}]`,\n code: 'TAX_METHOD_MISSING',\n message: `Line item ${index + 1} must specify either taxRate (for percentage) or taxPerUnitAmount + baseUnitMeasure (for fixed rate)`,\n severity: 'error',\n })\n return errors\n }\n\n if (hasFixedRate && hasPercentageRate) {\n errors.push({\n field: `lineItem[${index}]`,\n code: 'TAX_METHOD_CONFLICT',\n message: `Line item ${index + 1} cannot have both percentage and fixed rate tax methods`,\n severity: 'error',\n })\n }\n\n // Validate fixed rate tax calculation\n if (hasFixedRate) {\n if (item.baseUnitMeasureCode === undefined) {\n errors.push({\n field: `lineItem[${index}].baseUnitMeasureCode`,\n code: 'UNIT_CODE_MISSING',\n message: `Line item ${index + 1} with fixed rate tax must specify baseUnitMeasureCode`,\n severity: 'error',\n })\n }\n\n const expectedTaxAmount = item.taxPerUnitAmount! * item.baseUnitMeasure!\n if (Math.abs(item.taxAmount - expectedTaxAmount) > tolerance) {\n errors.push({\n field: `lineItem[${index}].taxAmount`,\n code: 'FIXED_TAX_CALCULATION_MISMATCH',\n message: `Line item ${index + 1} tax amount (${item.taxAmount}) doesn't match fixed rate calculation (${item.taxPerUnitAmount} × ${item.baseUnitMeasure} = ${expectedTaxAmount})`,\n severity: 'error',\n })\n }\n }\n\n // Validate percentage tax calculation\n if (hasPercentageRate && !hasFixedRate) {\n const expectedTaxAmount =\n (item.totalTaxableAmountPerLine * item.taxRate!) / 100\n if (Math.abs(item.taxAmount - expectedTaxAmount) > tolerance) {\n errors.push({\n field: `lineItem[${index}].taxAmount`,\n code: 'PERCENTAGE_TAX_CALCULATION_MISMATCH',\n message: `Line item ${index + 1} tax amount (${item.taxAmount}) doesn't match percentage calculation (${item.totalTaxableAmountPerLine} × ${item.taxRate}% = ${expectedTaxAmount})`,\n severity: 'error',\n })\n }\n }\n\n return errors\n}\n\n/**\n * Validates tax calculation consistency\n */\nexport const validateTaxCalculations = (\n invoice: InvoiceV1_1,\n): ValidationError[] => {\n const errors: ValidationError[] = []\n\n // Validate individual line item tax calculations\n invoice.invoiceLineItems.forEach((item, index) => {\n errors.push(...validateLineItemTax(item, index))\n })\n\n // Calculate expected totals from line items\n const expectedTaxExclusive = invoice.invoiceLineItems.reduce(\n (sum, item) => sum + item.totalTaxableAmountPerLine,\n 0,\n )\n const expectedTaxAmount = invoice.invoiceLineItems.reduce(\n (sum, item) => sum + item.taxAmount,\n 0,\n )\n\n // Allow small rounding differences (0.01)\n const tolerance = 0.01\n\n if (\n Math.abs(\n invoice.legalMonetaryTotal.taxExclusiveAmount - expectedTaxExclusive,\n ) > tolerance\n ) {\n errors.push({\n field: 'legalMonetaryTotal.taxExclusiveAmount',\n code: 'TAX_EXCLUSIVE_MISMATCH',\n message: `Tax exclusive amount (${invoice.legalMonetaryTotal.taxExclusiveAmount}) doesn't match sum of line items (${expectedTaxExclusive})`,\n severity: 'error',\n })\n }\n\n if (Math.abs(invoice.taxTotal.taxAmount - expectedTaxAmount) > tolerance) {\n errors.push({\n field: 'taxTotal.taxAmount',\n code: 'TAX_AMOUNT_MISMATCH',\n message: `Tax amount (${invoice.taxTotal.taxAmount}) doesn't match sum of line item taxes (${expectedTaxAmount})`,\n severity: 'error',\n })\n }\n\n return errors\n}\n\n/**\n * Main validation function for complete invoice\n */\nexport const validateInvoice = (invoice: InvoiceV1_1): ValidationResult => {\n const allErrors: ValidationError[] = []\n\n // Core field validations\n allErrors.push(\n ...validateTIN(invoice.supplier.tin, invoice.supplier.registrationType),\n )\n allErrors.push(\n ...validateTIN(invoice.buyer.tin, invoice.buyer.registrationType),\n )\n\n allErrors.push(...validateContactNumber(invoice.supplier.contactNumber))\n allErrors.push(...validateContactNumber(invoice.buyer.contactNumber))\n\n // Monetary validations\n allErrors.push(\n ...validateMonetaryAmount(\n invoice.legalMonetaryTotal.taxExclusiveAmount,\n 'taxExclusiveAmount',\n ),\n )\n allErrors.push(\n ...validateMonetaryAmount(\n invoice.legalMonetaryTotal.payableAmount,\n 'payableAmount',\n ),\n )\n allErrors.push(\n ...validateMonetaryAmount(invoice.taxTotal.taxAmount, 'taxAmount'),\n )\n\n // Line item validations\n invoice.invoiceLineItems.forEach((item, index) => {\n allErrors.push(\n ...validateMonetaryAmount(item.unitPrice, `lineItem[${index}].unitPrice`),\n )\n allErrors.push(\n ...validateMonetaryAmount(item.taxAmount, `lineItem[${index}].taxAmount`),\n )\n allErrors.push(\n ...validateMonetaryAmount(\n item.totalTaxableAmountPerLine,\n `lineItem[${index}].totalTaxableAmountPerLine`,\n ),\n )\n })\n\n // Business rule validations\n allErrors.push(...validateTaxCalculations(invoice))\n\n // Separate errors and warnings\n const errors = allErrors.filter(e => e.severity === 'error')\n const warnings = allErrors.filter(\n e => e.severity === 'warning',\n ) as ValidationWarning[]\n\n return {\n isValid: errors.length === 0,\n errors,\n warnings,\n }\n}\n"],"mappings":";;;;;AA6BA,MAAa,cAAc,CACzBA,KACAC,qBACsB;CACtB,MAAMC,SAA4B,CAAE;AAEpC,MAAK,KAAK;AACR,SAAO,KAAK;GACV,OAAO;GACP,MAAM;GACN,SAAS;GACT,UAAU;EACX,EAAC;AACF,SAAO;C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AAY,CACnE;AAGD,SAAQ,iBAAiB,QAAQ,CAAC,MAAM,UAAU;AAChD,YAAU,KACR,GAAG,uBAAuB,KAAK,YAAY,WAAW,MAAM,aAAa,CAC1E;AACD,YAAU,KACR,GAAG,uBAAuB,KAAK,YAAY,WAAW,MAAM,aAAa,CAC1E;AACD,YAAU,KACR,GAAG,uBACD,KAAK,4BACJ,WAAW,MAAM,6BACnB,CACF;CACF,EAAC;AAGF,WAAU,KAAK,GAAG,wBAAwB,QAAQ,CAAC;CAGnD,MAAM,SAAS,UAAU,OAAO,OAAK,EAAE,aAAa,QAAQ;CAC5D,MAAM,WAAW,UAAU,OACzB,OAAK,EAAE,aAAa,UACrB;AAED,QAAO;EACL,SAAS,OAAO,WAAW;EAC3B;EACA;CACD;AACF"}
|
package/dist/index16.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index16.cjs","names":[],"sources":["../src/types/classification-codes.d.ts"],"sourcesContent":["/**\n * Represents the allowed classification codes for e-Invoice items.\n * Based on the documentation: https://sdk.myinvois.hasil.gov.my/codes/classification-codes/\n */\nexport type ClassificationCode =\n | '001' // Breastfeeding equipment\n | '002' // Child care centres and kindergartens fees\n | '003' // Computer, smartphone or tablet\n | '004' // Consolidated e-Invoice\n | '005' // Construction materials (as specified under Fourth Schedule of the Lembaga Pembangunan Industri Pembinaan Malaysia Act 1994)\n | '006' // Disbursement\n | '007' // Donation\n | '008' // e-Commerce - e-Invoice to buyer / purchaser\n | '009' // e-Commerce - Self-billed e-Invoice to seller, logistics, etc.\n | '010' // Education fees\n | '011' // Goods on consignment (Consignor)\n | '012' // Goods on consignment (Consignee)\n | '013' // Gym membership\n | '014' // Insurance - Education and medical benefits\n | '015' // Insurance - Takaful or life insurance\n | '016' // Interest and financing expenses\n | '017' // Internet subscription\n | '018' // Land and building\n | '019' // Medical examination for learning disabilities and early intervention or rehabilitation treatments of learning disabilities\n | '020' // Medical examination or vaccination expenses\n | '021' // Medical expenses for serious diseases\n | '022' // Others\n | '023' // Petroleum operations (as defined in Petroleum (Income Tax) Act 1967)\n | '024' // Private retirement scheme or deferred annuity scheme\n | '025' // Motor vehicle\n | '026' // Subscription of books / journals / magazines / newspapers / other similar publications\n | '027' // Reimbursement\n | '028' // Rental of motor vehicle\n | '029' // EV charging facilities (Installation, rental, sale / purchase or subscription fees)\n | '030' // Repair and maintenance\n | '031' // Research and development\n | '032' // Foreign income\n | '033' // Self-billed - Betting and gaming\n | '034' // Self-billed - Importation of goods\n | '035' // Self-billed - Importation of services\n | '036' // Self-billed - Others\n | '037' // Self-billed - Monetary payment to agents, dealers or distributors\n | '038' // Sports equipment, rental / entry fees for sports facilities, registration in sports competition or sports training fees imposed by associations / sports clubs / companies registered with the Sports Commissioner or Companies Commission of Malaysia and carrying out sports activities as listed under the Sports Development Act 1997\n | '039' // Supporting equipment for disabled person\n | '040' // Voluntary contribution to approved provident fund\n | '041' // Dental examination or treatment\n | '042' // Fertility treatment\n | '043' // Treatment and home care nursing, daycare centres and residential care centers\n | '044' // Vouchers, gift cards, loyalty points, etc\n | '045' // Self-billed - Non-monetary payment to agents, dealers or distributors\n\n/**\n * Enum representing the allowed classification codes with descriptive names.\n * Provides a more readable way to reference classification codes.\n *\n * @example\n * const code = ClassificationCodeEnum.ComputerSmartphoneOrTablet;\n * console.log(code); // Output: \"003\"\n */\nexport enum ClassificationCodeEnum {\n BreastfeedingEquipment = '001',\n ChildCareCentresAndKindergartensFees = '002',\n ComputerSmartphoneOrTablet = '003',\n ConsolidatedEInvoice = '004',\n ConstructionMaterials = '005',\n Disbursement = '006',\n Donation = '007',\n ECommerceEInvoiceToBuyer = '008',\n ECommerceSelfBilledToSellerLogistics = '009',\n EducationFees = '010',\n GoodsOnConsignmentConsignor = '011',\n GoodsOnConsignmentConsignee = '012',\n GymMembership = '013',\n InsuranceEducationMedicalBenefits = '014',\n InsuranceTakafulLife = '015',\n InterestFinancingExpenses = '016',\n InternetSubscription = '017',\n LandAndBuilding = '018',\n MedicalExamLearningDisabilities = '019',\n MedicalExamVaccination = '020',\n MedicalExpensesSeriousDiseases = '021',\n Others = '022',\n PetroleumOperations = '023',\n PrivateRetirementSchemeDeferredAnnuity = '024',\n MotorVehicle = '025',\n SubscriptionBooksJournalsEtc = '026',\n Reimbursement = '027',\n RentalOfMotorVehicle = '028',\n EVChargingFacilities = '029',\n RepairAndMaintenance = '030',\n ResearchAndDevelopment = '031',\n ForeignIncome = '032',\n SelfBilledBettingGaming = '033',\n SelfBilledImportationGoods = '034',\n SelfBilledImportationServices = '035',\n SelfBilledOthers = '036',\n SelfBilledMonetaryPaymentToAgents = '037',\n SportsEquipmentRentalFeesEtc = '038',\n SupportingEquipmentDisabledPerson = '039',\n VoluntaryContributionProvidentFund = '040',\n DentalExamTreatment = '041',\n FertilityTreatment = '042',\n TreatmentHomeCareNursingEtc = '043',\n VouchersGiftCardsLoyaltyPoints = '044',\n SelfBilledNonMonetaryPaymentToAgents = '045',\n}\n\n/**\n * Interface representing a classification code entry.\n * Contains the code and its corresponding description.\n */\nexport interface Classification {\n code: ClassificationCode\n description: string\n}\n"],"mappings":";;;;;;;;;;AA2DA,IAAY,4EAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACD"}
|
package/dist/index17.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index17.cjs","names":[],"sources":["../src/types/country-code.d.ts"],"sourcesContent":["/**\n * Represents the allowed ISO-3166 alpha-3 country codes.\n * Based on the documentation: https://sdk.myinvois.hasil.gov.my/codes/countries/\n */\nexport type CountryCode =\n | \"ABW\"\n | \"AFG\"\n | \"AGO\"\n | \"AIA\"\n | \"ALA\"\n | \"ALB\"\n | \"AND\"\n | \"ANT\"\n | \"ARE\"\n | \"ARG\"\n | \"ARM\"\n | \"ASM\"\n | \"ATA\"\n | \"ATF\"\n | \"ATG\"\n | \"AUS\"\n | \"AUT\"\n | \"AZE\"\n | \"BDI\"\n | \"BEL\"\n | \"BEN\"\n | \"BES\"\n | \"BFA\"\n | \"BGD\"\n | \"BGR\"\n | \"BHR\"\n | \"BHS\"\n | \"BIH\"\n | \"BLM\"\n | \"BLR\"\n | \"BLZ\"\n | \"BMU\"\n | \"BOL\"\n | \"BRA\"\n | \"BRB\"\n | \"BRN\"\n | \"BTN\"\n | \"BVT\"\n | \"BWA\"\n | \"CAF\"\n | \"CAN\"\n | \"CCK\"\n | \"CHE\"\n | \"CHL\"\n | \"CHN\"\n | \"CIV\"\n | \"CMR\"\n | \"COD\"\n | \"COG\"\n | \"COK\"\n | \"COL\"\n | \"COM\"\n | \"CPV\"\n | \"CRI\"\n | \"CUB\"\n | \"CUW\"\n | \"CXR\"\n | \"CYM\"\n | \"CYP\"\n | \"CZE\"\n | \"DEU\"\n | \"DJI\"\n | \"DMA\"\n | \"DNK\"\n | \"DOM\"\n | \"DZA\"\n | \"ECU\"\n | \"EGY\"\n | \"ERI\"\n | \"ESH\"\n | \"ESP\"\n | \"EST\"\n | \"ETH\"\n | \"FIN\"\n | \"FJI\"\n | \"FLK\"\n | \"FRA\"\n | \"FRO\"\n | \"FSM\"\n | \"GAB\"\n | \"GBR\"\n | \"GEO\"\n | \"GGY\"\n | \"GHA\"\n | \"GIB\"\n | \"GIN\"\n | \"GLP\"\n | \"GMB\"\n | \"GNB\"\n | \"GNQ\"\n | \"GRC\"\n | \"GRD\"\n | \"GRL\"\n | \"GTM\"\n | \"GUF\"\n | \"GUM\"\n | \"GUY\"\n | \"HKG\"\n | \"HMD\"\n | \"HND\"\n | \"HRV\"\n | \"HTI\"\n | \"HUN\"\n | \"IDN\"\n | \"IMN\"\n | \"IND\"\n | \"IOT\"\n | \"IRL\"\n | \"IRN\"\n | \"IRQ\"\n | \"ISL\"\n | \"ISR\"\n | \"ITA\"\n | \"JAM\"\n | \"JEY\"\n | \"JOR\"\n | \"JPN\"\n | \"KAZ\"\n | \"KEN\"\n | \"KGZ\"\n | \"KHM\"\n | \"KIR\"\n | \"KNA\"\n | \"KOR\"\n | \"KWT\"\n | \"LAO\"\n | \"LBN\"\n | \"LBR\"\n | \"LBY\"\n | \"LCA\"\n | \"LIE\"\n | \"LKA\"\n | \"LSO\"\n | \"LTU\"\n | \"LUX\"\n | \"LVA\"\n | \"MAC\"\n | \"MAF\"\n | \"MAR\"\n | \"MCO\"\n | \"MDA\"\n | \"MDG\"\n | \"MDV\"\n | \"MEX\"\n | \"MHL\"\n | \"MKD\"\n | \"MLI\"\n | \"MLT\"\n | \"MMR\"\n | \"MNE\"\n | \"MNG\"\n | \"MNP\"\n | \"MOZ\"\n | \"MRT\"\n | \"MSR\"\n | \"MTQ\"\n | \"MUS\"\n | \"MWI\"\n | \"MYS\"\n | \"MYT\"\n | \"NAM\"\n | \"NCL\"\n | \"NER\"\n | \"NFK\"\n | \"NGA\"\n | \"NIC\"\n | \"NIU\"\n | \"NLD\"\n | \"NOR\"\n | \"NPL\"\n | \"NRU\"\n | \"NZL\"\n | \"OMN\"\n | \"PAK\"\n | \"PAN\"\n | \"PCN\"\n | \"PER\"\n | \"PHL\"\n | \"PLW\"\n | \"PNG\"\n | \"POL\"\n | \"PRI\"\n | \"PRK\"\n | \"PRT\"\n | \"PRY\"\n | \"PSE\"\n | \"PYF\"\n | \"QAT\"\n | \"REU\"\n | \"ROU\"\n | \"RUS\"\n | \"RWA\"\n | \"SAU\"\n | \"SDN\"\n | \"SEN\"\n | \"SGP\"\n | \"SGS\"\n | \"SHN\"\n | \"SJM\"\n | \"SLB\"\n | \"SLE\"\n | \"SLV\"\n | \"SMR\"\n | \"SOM\"\n | \"SPM\"\n | \"SRB\"\n | \"SSD\"\n | \"STP\"\n | \"SUR\"\n | \"SVK\"\n | \"SVN\"\n | \"SWE\"\n | \"SWZ\"\n | \"SXM\"\n | \"SYC\"\n | \"SYR\"\n | \"TCA\"\n | \"TCD\"\n | \"TGO\"\n | \"THA\"\n | \"TJK\"\n | \"TKL\"\n | \"TKM\"\n | \"TLS\"\n | \"TON\"\n | \"TTO\"\n | \"TUN\"\n | \"TUR\"\n | \"TUV\"\n | \"TWN\"\n | \"TZA\"\n | \"UGA\"\n | \"UKR\"\n | \"UMI\"\n | \"URY\"\n | \"USA\"\n | \"UZB\"\n | \"VAT\"\n | \"VCT\"\n | \"VEN\"\n | \"VGB\"\n | \"VIR\"\n | \"VNM\"\n | \"VUT\"\n | \"WLF\"\n | \"WSM\"\n | \"XKX\"\n | \"YEM\"\n | \"ZAF\"\n | \"ZMB\"\n | \"ZWE\"\n\n/**\n * Enum representing the allowed ISO-3166 alpha-3 country codes.\n * Provides a more readable way to reference country codes.\n *\n * @example\n * const malaysiaCode = CountryCodeEnum.MYS;\n * console.log(malaysiaCode); // Output: \"MYS\"\n */\nexport enum CountryCodeEnum {\n ABW = \"ABW\",\n AFG = \"AFG\",\n AGO = \"AGO\",\n AIA = \"AIA\",\n ALA = \"ALA\",\n ALB = \"ALB\",\n AND = \"AND\",\n ANT = \"ANT\",\n ARE = \"ARE\",\n ARG = \"ARG\",\n ARM = \"ARM\",\n ASM = \"ASM\",\n ATA = \"ATA\",\n ATF = \"ATF\",\n ATG = \"ATG\",\n AUS = \"AUS\",\n AUT = \"AUT\",\n AZE = \"AZE\",\n BDI = \"BDI\",\n BEL = \"BEL\",\n BEN = \"BEN\",\n BES = \"BES\",\n BFA = \"BFA\",\n BGD = \"BGD\",\n BGR = \"BGR\",\n BHR = \"BHR\",\n BHS = \"BHS\",\n BIH = \"BIH\",\n BLM = \"BLM\",\n BLR = \"BLR\",\n BLZ = \"BLZ\",\n BMU = \"BMU\",\n BOL = \"BOL\",\n BRA = \"BRA\",\n BRB = \"BRB\",\n BRN = \"BRN\",\n BTN = \"BTN\",\n BVT = \"BVT\",\n BWA = \"BWA\",\n CAF = \"CAF\",\n CAN = \"CAN\",\n CCK = \"CCK\",\n CHE = \"CHE\",\n CHL = \"CHL\",\n CHN = \"CHN\",\n CIV = \"CIV\",\n CMR = \"CMR\",\n COD = \"COD\",\n COG = \"COG\",\n COK = \"COK\",\n COL = \"COL\",\n COM = \"COM\",\n CPV = \"CPV\",\n CRI = \"CRI\",\n CUB = \"CUB\",\n CUW = \"CUW\",\n CXR = \"CXR\",\n CYM = \"CYM\",\n CYP = \"CYP\",\n CZE = \"CZE\",\n DEU = \"DEU\",\n DJI = \"DJI\",\n DMA = \"DMA\",\n DNK = \"DNK\",\n DOM = \"DOM\",\n DZA = \"DZA\",\n ECU = \"ECU\",\n EGY = \"EGY\",\n ERI = \"ERI\",\n ESH = \"ESH\",\n ESP = \"ESP\",\n EST = \"EST\",\n ETH = \"ETH\",\n FIN = \"FIN\",\n FJI = \"FJI\",\n FLK = \"FLK\",\n FRA = \"FRA\",\n FRO = \"FRO\",\n FSM = \"FSM\",\n GAB = \"GAB\",\n GBR = \"GBR\",\n GEO = \"GEO\",\n GGY = \"GGY\",\n GHA = \"GHA\",\n GIB = \"GIB\",\n GIN = \"GIN\",\n GLP = \"GLP\",\n GMB = \"GMB\",\n GNB = \"GNB\",\n GNQ = \"GNQ\",\n GRC = \"GRC\",\n GRD = \"GRD\",\n GRL = \"GRL\",\n GTM = \"GTM\",\n GUF = \"GUF\",\n GUM = \"GUM\",\n GUY = \"GUY\",\n HKG = \"HKG\",\n HMD = \"HMD\",\n HND = \"HND\",\n HRV = \"HRV\",\n HTI = \"HTI\",\n HUN = \"HUN\",\n IDN = \"IDN\",\n IMN = \"IMN\",\n IND = \"IND\",\n IOT = \"IOT\",\n IRL = \"IRL\",\n IRN = \"IRN\",\n IRQ = \"IRQ\",\n ISL = \"ISL\",\n ISR = \"ISR\",\n ITA = \"ITA\",\n JAM = \"JAM\",\n JEY = \"JEY\",\n JOR = \"JOR\",\n JPN = \"JPN\",\n KAZ = \"KAZ\",\n KEN = \"KEN\",\n KGZ = \"KGZ\",\n KHM = \"KHM\",\n KIR = \"KIR\",\n KNA = \"KNA\",\n KOR = \"KOR\",\n KWT = \"KWT\",\n LAO = \"LAO\",\n LBN = \"LBN\",\n LBR = \"LBR\",\n LBY = \"LBY\",\n LCA = \"LCA\",\n LIE = \"LIE\",\n LKA = \"LKA\",\n LSO = \"LSO\",\n LTU = \"LTU\",\n LUX = \"LUX\",\n LVA = \"LVA\",\n MAC = \"MAC\",\n MAF = \"MAF\",\n MAR = \"MAR\",\n MCO = \"MCO\",\n MDA = \"MDA\",\n MDG = \"MDG\",\n MDV = \"MDV\",\n MEX = \"MEX\",\n MHL = \"MHL\",\n MKD = \"MKD\",\n MLI = \"MLI\",\n MLT = \"MLT\",\n MMR = \"MMR\",\n MNE = \"MNE\",\n MNG = \"MNG\",\n MNP = \"MNP\",\n MOZ = \"MOZ\",\n MRT = \"MRT\",\n MSR = \"MSR\",\n MTQ = \"MTQ\",\n MUS = \"MUS\",\n MWI = \"MWI\",\n MYS = \"MYS\",\n MYT = \"MYT\",\n NAM = \"NAM\",\n NCL = \"NCL\",\n NER = \"NER\",\n NFK = \"NFK\",\n NGA = \"NGA\",\n NIC = \"NIC\",\n NIU = \"NIU\",\n NLD = \"NLD\",\n NOR = \"NOR\",\n NPL = \"NPL\",\n NRU = \"NRU\",\n NZL = \"NZL\",\n OMN = \"OMN\",\n PAK = \"PAK\",\n PAN = \"PAN\",\n PCN = \"PCN\",\n PER = \"PER\",\n PHL = \"PHL\",\n PLW = \"PLW\",\n PNG = \"PNG\",\n POL = \"POL\",\n PRI = \"PRI\",\n PRK = \"PRK\",\n PRT = \"PRT\",\n PRY = \"PRY\",\n PSE = \"PSE\",\n PYF = \"PYF\",\n QAT = \"QAT\",\n REU = \"REU\",\n ROU = \"ROU\",\n RUS = \"RUS\",\n RWA = \"RWA\",\n SAU = \"SAU\",\n SDN = \"SDN\",\n SEN = \"SEN\",\n SGP = \"SGP\",\n SGS = \"SGS\",\n SHN = \"SHN\",\n SJM = \"SJM\",\n SLB = \"SLB\",\n SLE = \"SLE\",\n SLV = \"SLV\",\n SMR = \"SMR\",\n SOM = \"SOM\",\n SPM = \"SPM\",\n SRB = \"SRB\",\n SSD = \"SSD\",\n STP = \"STP\",\n SUR = \"SUR\",\n SVK = \"SVK\",\n SVN = \"SVN\",\n SWE = \"SWE\",\n SWZ = \"SWZ\",\n SXM = \"SXM\",\n SYC = \"SYC\",\n SYR = \"SYR\",\n TCA = \"TCA\",\n TCD = \"TCD\",\n TGO = \"TGO\",\n THA = \"THA\",\n TJK = \"TJK\",\n TKL = \"TKL\",\n TKM = \"TKM\",\n TLS = \"TLS\",\n TON = \"TON\",\n TTO = \"TTO\",\n TUN = \"TUN\",\n TUR = \"TUR\",\n TUV = \"TUV\",\n TWN = \"TWN\",\n TZA = \"TZA\",\n UGA = \"UGA\",\n UKR = \"UKR\",\n UMI = \"UMI\",\n URY = \"URY\",\n USA = \"USA\",\n UZB = \"UZB\",\n VAT = \"VAT\",\n VCT = \"VCT\",\n VEN = \"VEN\",\n VGB = \"VGB\",\n VIR = \"VIR\",\n VNM = \"VNM\",\n VUT = \"VUT\",\n WLF = \"WLF\",\n WSM = \"WSM\",\n XKX = \"XKX\",\n YEM = \"YEM\",\n ZAF = \"ZAF\",\n ZMB = \"ZMB\",\n ZWE = \"ZWE\",\n}\n\n/**\n * Enum mapping ISO-3166 alpha-3 country codes to their corresponding country names.\n * Provides a way to easily retrieve the name of a country using its code.\n *\n * @example\n * import { CountryCodeEnum, CountryNameEnum } from './country-code';\n * const malaysiaName = CountryNameEnum[CountryCodeEnum.MYS];\n * console.log(malaysiaName); // Output: MALAYSIA\n */\nexport enum CountryNameEnum {\n ABW = \"ARUBA\",\n AFG = \"AFGHANISTAN\",\n AGO = \"ANGOLA\",\n AIA = \"ANGUILLA\",\n ALA = \"ALAND ISLANDS\",\n ALB = \"ALBANIA\",\n AND = \"ANDORA\",\n ANT = \"NETHERLANDS ANTILLES\",\n ARE = \"UNITED ARAB EMIRATES\",\n ARG = \"ARGENTINA\",\n ARM = \"ARMENIA\",\n ASM = \"AMERICAN SAMOA\",\n ATA = \"ANTARCTICA\",\n ATF = \"FRENCH SOUTHERN TERRITORIES\",\n ATG = \"ANTIGUA AND BARBUDA\",\n AUS = \"AUSTRALIA\",\n AUT = \"AUSTRIA\",\n AZE = \"AZERBAIDJAN\",\n BDI = \"BURUNDI\",\n BEL = \"BELGIUM\",\n BEN = \"BENIN\",\n BES = \"BONAIRE, SINT EUSTATIUS AND SABA\",\n BFA = \"BURKINA FASO\",\n BGD = \"BANGLADESH\",\n BGR = \"BULGARIA\",\n BHR = \"BAHRAIN\",\n BHS = \"BAHAMAS\",\n BIH = \"BOSNIA AND HERZEGOVINA\",\n BLM = \"SAINT BARTHELEMY\",\n BLR = \"BELARUS\",\n BLZ = \"BELIZE\",\n BMU = \"BERMUDA\",\n BOL = \"BOLIVIA\",\n BRA = \"BRAZIL\",\n BRB = \"BARBADOS\",\n BRN = \"BRUNEI DARUSSALAM\",\n BTN = \"BHUTAN\",\n BVT = \"BOUVET ISLAND\",\n BWA = \"BOTSWANA\",\n CAF = \"CENTRAL AFRICAN REPUBLIC\",\n CAN = \"CANADA\",\n CCK = \"COCOS ISLAND\",\n CHE = \"SWITZERLAND\",\n CHL = \"CHILE\",\n CHN = \"CHINA\",\n CIV = \"COTE D'IVOIRE\",\n CMR = \"CAMEROON\",\n COD = \"CONGO, THE DEMOCRATIC REPUBLIC\",\n COG = \"CONGO\",\n COK = \"COOK ISLANDS\",\n COL = \"COLOMBIA\",\n COM = \"COMOROS\",\n CPV = \"CAPE VERDE\",\n CRI = \"COSTA RICA\",\n CUB = \"CUBA\",\n CUW = \"CURACAO\",\n CXR = \"CHRISTMAS ISLANDS\",\n CYM = \"CAYMAN ISLANDS\",\n CYP = \"CYPRUS\",\n CZE = \"CZECH REPUBLIC\",\n DEU = \"GERMANY\",\n DJI = \"DJIBOUTI\",\n DMA = \"DOMINICA\",\n DNK = \"DENMARK\",\n DOM = \"DOMINICAN REPUBLIC\",\n DZA = \"ALGERIA\",\n ECU = \"ECUADOR\",\n EGY = \"EGYPT\",\n ERI = \"ERITREA\",\n ESH = \"WESTERN SAHARA\",\n ESP = \"SPAIN\",\n EST = \"ESTONIA\",\n ETH = \"ETHIOPIA\",\n FIN = \"FINLAND\",\n FJI = \"FIJI\",\n FLK = \"FALKLAND ISLANDS (MALVINAS)\",\n FRA = \"FRANCE\",\n FRO = \"FAEROE ISLANDS\",\n FSM = \"MICRONESIA, FEDERATED STATES OF\",\n GAB = \"GABON\",\n GBR = \"UNITED KINGDOM\",\n GEO = \"GEORGIA\",\n GGY = \"GUERNSEY\",\n GHA = \"GHANA\",\n GIB = \"GIBRALTAR\",\n GIN = \"GUINEA\",\n GLP = \"GUADELOUPE\",\n GMB = \"GAMBIA\",\n GNB = \"GUINEA-BISSAU\",\n GNQ = \"EQUATORIAL GUINEA\",\n GRC = \"GREECE\",\n GRD = \"GRENADA\",\n GRL = \"GREENLAND\",\n GTM = \"GUATEMALA\",\n GUF = \"FRENCH GUIANA\",\n GUM = \"GUAM\",\n GUY = \"GUYANA\",\n HKG = \"HONG KONG\",\n HMD = \"HEARD AND MCDONALD ISLANDS\",\n HND = \"HONDURAS\",\n HRV = \"CROATIA\",\n HTI = \"HAITI\",\n HUN = \"HUNGARY\",\n IDN = \"INDONESIA\",\n IMN = \"ISLE OF MAN\",\n IND = \"INDIA\",\n IOT = \"BRITISH INDIAN OCEAN TERRITORY\",\n IRL = \"IRELAND\",\n IRN = \"IRAN\",\n IRQ = \"IRAQ\",\n ISL = \"ICELAND\",\n ISR = \"ISRAEL\",\n ITA = \"ITALY\",\n JAM = \"JAMAICA\",\n JEY = \"JERSEY (CHANNEL ISLANDS)\",\n JOR = \"JORDAN\",\n JPN = \"JAPAN\",\n KAZ = \"KAZAKHSTAN\",\n KEN = \"KENYA\",\n KGZ = \"KYRGYZSTAN\",\n KHM = \"CAMBODIA\",\n KIR = \"KIRIBATI\",\n KNA = \"ST.KITTS AND NEVIS\",\n KOR = \"THE REPUBLIC OF KOREA\",\n KWT = \"KUWAIT\",\n LAO = \"LAOS\",\n LBN = \"LEBANON\",\n LBR = \"LIBERIA\",\n LBY = \"LIBYAN ARAB JAMAHIRIYA\",\n LCA = \"SAINT LUCIA\",\n LIE = \"LIECHTENSTEIN\",\n LKA = \"SRI LANKA\",\n LSO = \"LESOTHO\",\n LTU = \"LITHUANIA\",\n LUX = \"LUXEMBOURG\",\n LVA = \"LATVIA\",\n MAC = \"MACAO\",\n MAF = \"SAINT MARTIN (FRENCH PART)\",\n MAR = \"MOROCCO\",\n MCO = \"MONACO\",\n MDA = \"MOLDOVA, REPUBLIC OF\",\n MDG = \"MADAGASCAR\",\n MDV = \"MALDIVES\",\n MEX = \"MEXICO\",\n MHL = \"MARSHALL ISLANDS\",\n MKD = \"MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF\",\n MLI = \"MALI\",\n MLT = \"MALTA\",\n MMR = \"MYANMAR\",\n MNE = \"MONTENEGRO\",\n MNG = \"MONGOLIA\",\n MNP = \"NORTHERN MARIANA ISLANDS\",\n MOZ = \"MOZAMBIQUE\",\n MRT = \"MAURITANIA\",\n MSR = \"MONTSERRAT\",\n MTQ = \"MARTINIQUE\",\n MUS = \"MAURITIUS\",\n MWI = \"MALAWI\",\n MYS = \"MALAYSIA\",\n MYT = \"MAYOTTE\",\n NAM = \"NAMIBIA\",\n NCL = \"NEW CALEDONIA\",\n NER = \"NIGER\",\n NFK = \"NORFOLK ISLAND\",\n NGA = \"NIGERIA\",\n NIC = \"NICARAGUA\",\n NIU = \"NIUE\",\n NLD = \"NETHERLANDS\",\n NOR = \"NORWAY\",\n NPL = \"NEPAL\",\n NRU = \"NAURU\",\n NZL = \"NEW ZEALAND\",\n OMN = \"OMAN\",\n PAK = \"PAKISTAN\",\n PAN = \"PANAMA\",\n PCN = \"PITCAIRN\",\n PER = \"PERU\",\n PHL = \"PHILIPPINES\",\n PLW = \"PALAU\",\n PNG = \"PAPUA NEW GUINEA\",\n POL = \"POLAND\",\n PRI = \"PUERTO RICO\",\n PRK = \"DEMOC.PEOPLES REP.OF KOREA\",\n PRT = \"PORTUGAL\",\n PRY = \"PARAGUAY\",\n PSE = \"PALESTINIAN TERRITORY, OCCUPIED\",\n PYF = \"FRENCH POLYNESIA\",\n QAT = \"QATAR\",\n REU = \"REUNION\",\n ROU = \"ROMANIA\",\n RUS = \"RUSSIAN FEDERATION (USSR)\",\n RWA = \"RWANDA\",\n SAU = \"SAUDI ARABIA\",\n SDN = \"SUDAN\",\n SEN = \"SENEGAL\",\n SGP = \"SINGAPORE\",\n SGS = \"SOUTH GEORGIA AND THE SOUTH SANDWICH ISLAND\",\n SHN = \"ST. HELENA\",\n SJM = \"SVALBARD AND JAN MAYEN ISLANDS\",\n SLB = \"SOLOMON ISLANDS\",\n SLE = \"SIERRA LEONE\",\n SLV = \"EL SALVADOR\",\n SMR = \"SAN MARINO\",\n SOM = \"SOMALIA\",\n SPM = \"ST. PIERRE AND MIQUELON\",\n SRB = \"SERBIA\",\n SSD = \"SOUTH SUDAN\",\n STP = \"SAO TOME AND PRINCIPE\",\n SUR = \"SURINAME\",\n SVK = \"SLOVAK REPUBLIC\",\n SVN = \"SLOVENIA\",\n SWE = \"SWEDEN\",\n SWZ = \"ESWATINI, KINGDOM OF (SWAZILAND)\",\n SXM = \"SINT MAARTEN (DUTCH PART)\",\n SYC = \"SEYCHELLES\",\n SYR = \"SYRIAN ARAB REPUBLIC\",\n TCA = \"TURKS AND CAICOS ISLANDS\",\n TCD = \"CHAD\",\n TGO = \"TOGO\",\n THA = \"THAILAND\",\n TJK = \"TAJIKISTAN\",\n TKL = \"TOKELAU\",\n TKM = \"TURKMENISTAN\",\n TLS = \"TIMOR-LESTE\",\n TON = \"TONGA\",\n TTO = \"TRINIDAD AND TOBAGO\",\n TUN = \"TUNISIA\",\n TUR = \"TURKIYE\",\n TUV = \"TUVALU\",\n TWN = \"TAIWAN\",\n TZA = \"TANZANIA UNITED REPUBLIC\",\n UGA = \"UGANDA\",\n UKR = \"UKRAINE\",\n UMI = \"UNITED STATES MINOR OUTLYING ISLANDS\",\n URY = \"URUGUAY\",\n USA = \"UNITED STATES OF AMERICA\",\n UZB = \"UZBEKISTAN\",\n VAT = \"VATICAN CITY STATE (HOLY SEE)\",\n VCT = \"SAINT VINCENT AND GRENADINES\",\n VEN = \"VENEZUELA\",\n VGB = \"VIRGIN ISLANDS(BRITISH)\",\n VIR = \"VIRGIN ISLANDS(US)\",\n VNM = \"VIETNAM\",\n VUT = \"VANUATU\",\n WLF = \"WALLIS AND FUTUNA ISLANDS\",\n WSM = \"SAMOA\",\n XKX = \"KOSOVO\",\n YEM = \"YEMEN\",\n ZAF = \"SOUTH AFRICA\",\n ZMB = \"ZAMBIA\",\n ZWE = \"ZIMBABWE\",\n}\n\n/**\n * Interface representing a country code entry.\n * Contains the ISO-3166 alpha-3 code and the country name.\n */\nexport interface Country {\n code: CountryCode\n name: string\n}\n"],"mappings":";;;;;;;;;;AAyQA,IAAY,8DAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACD;;;;;;;;;;AAWD,IAAY,8DAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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/currencies.d.ts"],"sourcesContent":["/**\n * Represents the allowed ISO-4217 3-letter currency codes.\n * Based on the documentation: https://sdk.myinvois.hasil.gov.my/codes/currencies/\n */\nexport type CurrencyCode =\n | 'AED'\n | 'AFN'\n | 'ALL'\n | 'AMD'\n | 'ANG'\n | 'AOA'\n | 'ARS'\n | 'AUD'\n | 'AWG'\n | 'AZN'\n | 'BAM'\n | 'BBD'\n | 'BDT'\n | 'BGN'\n | 'BHD'\n | 'BIF'\n | 'BMD'\n | 'BND'\n | 'BOB'\n | 'BOV'\n | 'BRL'\n | 'BSD'\n | 'BTN'\n | 'BWP'\n | 'BYN'\n | 'BZD'\n | 'CAD'\n | 'CDF'\n | 'CHE'\n | 'CHF'\n | 'CHW'\n | 'CLF'\n | 'CLP'\n | 'CNY'\n | 'COP'\n | 'COU'\n | 'CRC'\n | 'CUC'\n | 'CUP'\n | 'CVE'\n | 'CZK'\n | 'DJF'\n | 'DKK'\n | 'DOP'\n | 'DZD'\n | 'EGP'\n | 'ERN'\n | 'ETB'\n | 'EUR'\n | 'FJD'\n | 'FKP'\n | 'GBP'\n | 'GEL'\n | 'GHS'\n | 'GIP'\n | 'GMD'\n | 'GNF'\n | 'GTQ'\n | 'GYD'\n | 'HKD'\n | 'HNL'\n | 'HRK'\n | 'HTG'\n | 'HUF'\n | 'IDR'\n | 'ILS'\n | 'INR'\n | 'IQD'\n | 'IRR'\n | 'ISK'\n | 'JMD'\n | 'JOD'\n | 'JPY'\n | 'KES'\n | 'KGS'\n | 'KHR'\n | 'KMF'\n | 'KPW'\n | 'KRW'\n | 'KWD'\n | 'KYD'\n | 'KZT'\n | 'LAK'\n | 'LBP'\n | 'LKR'\n | 'LRD'\n | 'LSL'\n | 'LYD'\n | 'MAD'\n | 'MDL'\n | 'MGA'\n | 'MKD'\n | 'MMK'\n | 'MNT'\n | 'MOP'\n | 'MRU'\n | 'MUR'\n | 'MVR'\n | 'MWK'\n | 'MXN'\n | 'MXV'\n | 'MYR'\n | 'MZN'\n | 'NAD'\n | 'NGN'\n | 'NIO'\n | 'NOK'\n | 'NPR'\n | 'NZD'\n | 'OMR'\n | 'PAB'\n | 'PEN'\n | 'PGK'\n | 'PHP'\n | 'PKR'\n | 'PLN'\n | 'PYG'\n | 'QAR'\n | 'RON'\n | 'RSD'\n | 'RUB'\n | 'RWF'\n | 'SAR'\n | 'SBD'\n | 'SCR'\n | 'SDG'\n | 'SEK'\n | 'SGD'\n | 'SHP'\n | 'SLL'\n | 'SOS'\n | 'SRD'\n | 'SSP'\n | 'STN'\n | 'SVC'\n | 'SYP'\n | 'SZL'\n | 'THB'\n | 'TJS'\n | 'TMT'\n | 'TND'\n | 'TOP'\n | 'TRY'\n | 'TTD'\n | 'TWD'\n | 'TZS'\n | 'UAH'\n | 'UGX'\n | 'USD'\n | 'USN'\n | 'UYI'\n | 'UYU'\n | 'UYW'\n | 'UZS'\n | 'VED'\n | 'VES'\n | 'VND'\n | 'VUV'\n | 'WST'\n | 'XAF'\n | 'XAG'\n | 'XAU'\n | 'XBA'\n | 'XBB'\n | 'XBC'\n | 'XBD'\n | 'XCD'\n | 'XDR'\n | 'XOF'\n | 'XPD'\n | 'XPF'\n | 'XPT'\n | 'XSU'\n | 'XUA'\n | 'XXX'\n | 'YER'\n | 'ZAR'\n | 'ZMW'\n | 'ZWL'\n\n/**\n * Enum representing the allowed ISO-4217 3-letter currency codes.\n * Provides a more readable way to reference currency codes.\n *\n * @example\n * const currency = CurrencyCodeEnum.MYR;\n * console.log(currency); // Output: \"MYR\"\n */\nexport enum CurrencyCodeEnum {\n AED = 'AED',\n AFN = 'AFN',\n ALL = 'ALL',\n AMD = 'AMD',\n ANG = 'ANG',\n AOA = 'AOA',\n ARS = 'ARS',\n AUD = 'AUD',\n AWG = 'AWG',\n AZN = 'AZN',\n BAM = 'BAM',\n BBD = 'BBD',\n BDT = 'BDT',\n BGN = 'BGN',\n BHD = 'BHD',\n BIF = 'BIF',\n BMD = 'BMD',\n BND = 'BND',\n BOB = 'BOB',\n BOV = 'BOV',\n BRL = 'BRL',\n BSD = 'BSD',\n BTN = 'BTN',\n BWP = 'BWP',\n BYN = 'BYN',\n BZD = 'BZD',\n CAD = 'CAD',\n CDF = 'CDF',\n CHE = 'CHE',\n CHF = 'CHF',\n CHW = 'CHW',\n CLF = 'CLF',\n CLP = 'CLP',\n CNY = 'CNY',\n COP = 'COP',\n COU = 'COU',\n CRC = 'CRC',\n CUC = 'CUC',\n CUP = 'CUP',\n CVE = 'CVE',\n CZK = 'CZK',\n DJF = 'DJF',\n DKK = 'DKK',\n DOP = 'DOP',\n DZD = 'DZD',\n EGP = 'EGP',\n ERN = 'ERN',\n ETB = 'ETB',\n EUR = 'EUR',\n FJD = 'FJD',\n FKP = 'FKP',\n GBP = 'GBP',\n GEL = 'GEL',\n GHS = 'GHS',\n GIP = 'GIP',\n GMD = 'GMD',\n GNF = 'GNF',\n GTQ = 'GTQ',\n GYD = 'GYD',\n HKD = 'HKD',\n HNL = 'HNL',\n HRK = 'HRK',\n HTG = 'HTG',\n HUF = 'HUF',\n IDR = 'IDR',\n ILS = 'ILS',\n INR = 'INR',\n IQD = 'IQD',\n IRR = 'IRR',\n ISK = 'ISK',\n JMD = 'JMD',\n JOD = 'JOD',\n JPY = 'JPY',\n KES = 'KES',\n KGS = 'KGS',\n KHR = 'KHR',\n KMF = 'KMF',\n KPW = 'KPW',\n KRW = 'KRW',\n KWD = 'KWD',\n KYD = 'KYD',\n KZT = 'KZT',\n LAK = 'LAK',\n LBP = 'LBP',\n LKR = 'LKR',\n LRD = 'LRD',\n LSL = 'LSL',\n LYD = 'LYD',\n MAD = 'MAD',\n MDL = 'MDL',\n MGA = 'MGA',\n MKD = 'MKD',\n MMK = 'MMK',\n MNT = 'MNT',\n MOP = 'MOP',\n MRU = 'MRU',\n MUR = 'MUR',\n MVR = 'MVR',\n MWK = 'MWK',\n MXN = 'MXN',\n MXV = 'MXV',\n MYR = 'MYR',\n MZN = 'MZN',\n NAD = 'NAD',\n NGN = 'NGN',\n NIO = 'NIO',\n NOK = 'NOK',\n NPR = 'NPR',\n NZD = 'NZD',\n OMR = 'OMR',\n PAB = 'PAB',\n PEN = 'PEN',\n PGK = 'PGK',\n PHP = 'PHP',\n PKR = 'PKR',\n PLN = 'PLN',\n PYG = 'PYG',\n QAR = 'QAR',\n RON = 'RON',\n RSD = 'RSD',\n RUB = 'RUB',\n RWF = 'RWF',\n SAR = 'SAR',\n SBD = 'SBD',\n SCR = 'SCR',\n SDG = 'SDG',\n SEK = 'SEK',\n SGD = 'SGD',\n SHP = 'SHP',\n SLL = 'SLL',\n SOS = 'SOS',\n SRD = 'SRD',\n SSP = 'SSP',\n STN = 'STN',\n SVC = 'SVC',\n SYP = 'SYP',\n SZL = 'SZL',\n THB = 'THB',\n TJS = 'TJS',\n TMT = 'TMT',\n TND = 'TND',\n TOP = 'TOP',\n TRY = 'TRY',\n TTD = 'TTD',\n TWD = 'TWD',\n TZS = 'TZS',\n UAH = 'UAH',\n UGX = 'UGX',\n USD = 'USD',\n USN = 'USN',\n UYI = 'UYI',\n UYU = 'UYU',\n UYW = 'UYW',\n UZS = 'UZS',\n VED = 'VED',\n VES = 'VES',\n VND = 'VND',\n VUV = 'VUV',\n WST = 'WST',\n XAF = 'XAF',\n XAG = 'XAG',\n XAU = 'XAU',\n XBA = 'XBA',\n XBB = 'XBB',\n XBC = 'XBC',\n XBD = 'XBD',\n XCD = 'XCD',\n XDR = 'XDR',\n XOF = 'XOF',\n XPD = 'XPD',\n XPF = 'XPF',\n XPT = 'XPT',\n XSU = 'XSU',\n XUA = 'XUA',\n XXX = 'XXX',\n YER = 'YER',\n ZAR = 'ZAR',\n ZMW = 'ZMW',\n ZWL = 'ZWL',\n}\n\n/**\n * Interface representing a currency entry.\n * Contains the ISO-4217 code and the currency name.\n */\nexport interface Currency {\n code: CurrencyCode\n name: string\n}\n"],"mappings":";;;;;;;;;;AAiMA,IAAY,gEAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACD"}
|
package/dist/index20.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index20.cjs","names":[],"sources":["../src/types/e-invoice.d.ts"],"sourcesContent":["/**\n * Represents the allowed codes for e-Invoice types.\n * Based on the documentation: https://sdk.myinvois.hasil.gov.my/codes/e-invoice-types/\n */\nexport type EInvoiceTypeCode =\n | '01' // Invoice\n | '02' // Credit Note\n | '03' // Debit Note\n | '04' // Refund Note\n | '11' // Self-billed Invoice\n | '12' // Self-billed Credit Note\n | '13' // Self-billed Debit Note\n | '14' // Self-billed Refund Note\n\n/**\n * Interface representing an e-Invoice type entry.\n * Contains the code and its corresponding description.\n */\nexport interface EInvoiceType {\n code: EInvoiceTypeCode\n description: string\n}\n\n/**\n * Enum representing the allowed codes for e-Invoice types with descriptive names.\n * Provides a more readable way to reference e-Invoice types compared to using raw codes.\n *\n * @example\n * const invoiceCode = EInvoiceTypeCodeEnum.Invoice;\n * console.log(invoiceCode); // Output: \"01\"\n */\nexport enum EInvoiceTypeCodeEnum {\n Invoice = '01',\n CreditNote = '02',\n DebitNote = '03',\n RefundNote = '04',\n SelfBilledInvoice = '11',\n SelfBilledCreditNote = '12',\n SelfBilledDebitNote = '13',\n SelfBilledRefundNote = '14',\n}\n"],"mappings":";;;;;;;;;;AA+BA,IAAY,wEAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACD"}
|