@ripwords/myinvois-client 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/package.json +8 -11
  2. package/.prettierrc +0 -8
  3. package/CHANGELOG.md +0 -140
  4. package/bun.lock +0 -460
  5. package/myinvois-cert.conf.template +0 -23
  6. package/scripts/gen-cert.sh +0 -159
  7. package/src/api/platform/platformLogin.ts +0 -34
  8. package/src/index.ts +0 -530
  9. package/src/types/classification-codes.d.ts +0 -115
  10. package/src/types/country-code.d.ts +0 -790
  11. package/src/types/currencies.d.ts +0 -383
  12. package/src/types/documents.d.ts +0 -869
  13. package/src/types/e-invoice.d.ts +0 -41
  14. package/src/types/index.d.ts +0 -24
  15. package/src/types/msic/0X.d.ts +0 -408
  16. package/src/types/msic/1X.d.ts +0 -210
  17. package/src/types/msic/2X.d.ts +0 -266
  18. package/src/types/msic/3X.d.ts +0 -114
  19. package/src/types/msic/4X.d.ts +0 -520
  20. package/src/types/msic/5X.d.ts +0 -144
  21. package/src/types/msic/6X.d.ts +0 -200
  22. package/src/types/msic/7X.d.ts +0 -132
  23. package/src/types/msic/8X.d.ts +0 -210
  24. package/src/types/msic/9X.d.ts +0 -186
  25. package/src/types/msic-codes.d.ts +0 -31
  26. package/src/types/payment-modes.d.ts +0 -41
  27. package/src/types/signatures.d.ts +0 -169
  28. package/src/types/state-codes.d.ts +0 -59
  29. package/src/types/tax-types.d.ts +0 -39
  30. package/src/types/unit/1X.d.ts +0 -16
  31. package/src/types/unit/2X.d.ts +0 -62
  32. package/src/types/unit/3X.d.ts +0 -17
  33. package/src/types/unit/4X.d.ts +0 -44
  34. package/src/types/unit/5X.d.ts +0 -26
  35. package/src/types/unit/6X.d.ts +0 -12
  36. package/src/types/unit/7X.d.ts +0 -12
  37. package/src/types/unit/8X.d.ts +0 -15
  38. package/src/types/unit/9X.d.ts +0 -11
  39. package/src/types/unit/AX.d.ts +0 -202
  40. package/src/types/unit/BX.d.ts +0 -212
  41. package/src/types/unit/CX.d.ts +0 -238
  42. package/src/types/unit/DX.d.ts +0 -212
  43. package/src/types/unit/EX.d.ts +0 -196
  44. package/src/types/unit/FX.d.ts +0 -236
  45. package/src/types/unit/GX.d.ts +0 -254
  46. package/src/types/unit/HX.d.ts +0 -234
  47. package/src/types/unit/IX.d.ts +0 -28
  48. package/src/types/unit/JX.d.ts +0 -190
  49. package/src/types/unit/KX.d.ts +0 -284
  50. package/src/types/unit/LX.d.ts +0 -228
  51. package/src/types/unit/MX.d.ts +0 -288
  52. package/src/types/unit/NX.d.ts +0 -226
  53. package/src/types/unit/OX.d.ts +0 -34
  54. package/src/types/unit/PX.d.ts +0 -224
  55. package/src/types/unit/QX.d.ts +0 -94
  56. package/src/types/unit/RX.d.ts +0 -28
  57. package/src/types/unit/SX.d.ts +0 -56
  58. package/src/types/unit/TX.d.ts +0 -44
  59. package/src/types/unit/UX.d.ts +0 -14
  60. package/src/types/unit/VX.d.ts +0 -13
  61. package/src/types/unit/WX.d.ts +0 -34
  62. package/src/types/unit/XX.d.ts +0 -825
  63. package/src/types/unit/YX.d.ts +0 -17
  64. package/src/types/unit/ZX.d.ts +0 -19
  65. package/src/types/unit-types.d.ts +0 -86
  66. package/src/utils/base64.ts +0 -7
  67. package/src/utils/certificate.ts +0 -60
  68. package/src/utils/document.ts +0 -852
  69. package/src/utils/getBaseUrl.ts +0 -5
  70. package/src/utils/helpers.ts +0 -552
  71. package/src/utils/signature-diagnostics.ts +0 -583
  72. package/src/utils/validation.ts +0 -268
  73. package/test/MyInvoiClientWithRealData.test.ts +0 -40
  74. package/test/MyInvoisClient.test.ts +0 -204
  75. package/test/base64.test.ts +0 -43
  76. package/test/dynamicInvoiceFeatures.test.ts +0 -451
  77. package/test/signAndSubmitInvoice.test.ts +0 -452
  78. package/test/signature-diagnostics.test.ts +0 -130
  79. package/tsconfig.json +0 -39
  80. package/tsdown.config.ts +0 -31
  81. package/vitest.config.ts +0 -8
@@ -1,583 +0,0 @@
1
- import crypto from 'crypto'
2
- import type { InvoiceV1_1 } from '../types'
3
- import {
4
- extractCertificateInfo,
5
- calculateDocumentDigest,
6
- calculateSignedPropertiesDigest,
7
- createSignedProperties,
8
- calculateCertificateDigest,
9
- } from './document'
10
-
11
- export interface CertificateAnalysisResult {
12
- organizationIdentifier?: string
13
- serialNumber?: string
14
- issuerName: string
15
- subjectName: string
16
- issues: string[]
17
- recommendations: string[]
18
- }
19
-
20
- export interface SignatureAnalysisResult {
21
- documentDigest: string
22
- certificateDigest: string
23
- signedPropertiesDigest: string
24
- issues: string[]
25
- recommendations: string[]
26
- }
27
-
28
- export interface DiagnosticResult {
29
- certificateAnalysis: CertificateAnalysisResult
30
- signatureAnalysis: SignatureAnalysisResult
31
- summary: {
32
- totalIssues: number
33
- certificateIssues: number
34
- signatureIssues: number
35
- }
36
- }
37
-
38
- /**
39
- * Analyzes certificate for MyInvois compatibility issues
40
- */
41
- function analyzeCertificateForDiagnostics(
42
- certificatePem: string,
43
- ): CertificateAnalysisResult {
44
- const issues: string[] = []
45
- const recommendations: string[] = []
46
-
47
- try {
48
- const cert = new crypto.X509Certificate(certificatePem)
49
- const certInfo = extractCertificateInfo(certificatePem)
50
-
51
- // Parse subject fields for MyInvois analysis
52
- const parseSubjectFields = (dn: string) => {
53
- const fields: Record<string, string> = {}
54
- dn.split('\n').forEach(line => {
55
- const trimmed = line.trim()
56
- if (trimmed.includes('=')) {
57
- const [key, ...valueParts] = trimmed.split('=')
58
- if (key) {
59
- fields[key.trim()] = valueParts.join('=').trim()
60
- }
61
- }
62
- })
63
- return fields
64
- }
65
-
66
- const subjectFields = parseSubjectFields(cert.subject)
67
- const organizationIdentifier =
68
- subjectFields['organizationIdentifier'] || subjectFields['2.5.4.97']
69
- const serialNumber = subjectFields['serialNumber']
70
-
71
- // DS311 - TIN Mismatch Analysis
72
- if (!organizationIdentifier) {
73
- issues.push(
74
- 'DS311: Certificate missing organizationIdentifier field (TIN)',
75
- )
76
- recommendations.push(
77
- 'CRITICAL: Generate new certificate with organizationIdentifier matching your MyInvois TIN',
78
- )
79
- recommendations.push(
80
- 'Portal Error: "Signer of invoice doesn\'t match the submitter of document. TIN doesn\'t match with the OI."',
81
- )
82
- } else {
83
- // Additional TIN format validation
84
- if (organizationIdentifier.length < 10) {
85
- issues.push(
86
- 'DS311: OrganizationIdentifier (TIN) appears too short - may cause submission rejection',
87
- )
88
- recommendations.push(
89
- 'Verify TIN format matches exactly what is registered in MyInvois',
90
- )
91
- }
92
- }
93
-
94
- // DS312 - Registration Number Analysis
95
- if (!serialNumber) {
96
- issues.push(
97
- 'DS312: Certificate missing serialNumber field (business registration)',
98
- )
99
- recommendations.push(
100
- 'CRITICAL: Generate new certificate with serialNumber matching your business registration',
101
- )
102
- recommendations.push(
103
- 'Portal Error: "Submitter registration/identity number doesn\'t match with the certificate SERIALNUMBER."',
104
- )
105
- }
106
-
107
- // DS329 - Certificate Trust Analysis
108
- if (cert.issuer === cert.subject) {
109
- issues.push(
110
- 'DS329: Self-signed certificate detected - will fail chain of trust validation',
111
- )
112
- recommendations.push(
113
- 'BLOCKING: Obtain certificate from MyInvois-approved CA:',
114
- )
115
- recommendations.push('• MSC Trustgate Sdn Bhd')
116
- recommendations.push('• DigiCert Sdn Bhd')
117
- recommendations.push('• Cybersign Asia Sdn Bhd')
118
- recommendations.push(
119
- 'Portal Error: "Certificate is not valid according to the chain of trust validation or has been issued by an untrusted certificate authority."',
120
- )
121
- } else {
122
- // Check if issuer looks like a known CA
123
- const issuerName = cert.issuer.toLowerCase()
124
- const approvedCAs = ['msc trustgate', 'digicert', 'cybersign']
125
- const isFromApprovedCA = approvedCAs.some(ca => issuerName.includes(ca))
126
-
127
- if (!isFromApprovedCA) {
128
- issues.push('DS329: Certificate may not be from MyInvois-approved CA')
129
- recommendations.push(
130
- 'Verify certificate was issued by an approved CA for MyInvois',
131
- )
132
- }
133
- }
134
-
135
- // DS326 - Issuer Name Format Analysis (Enhanced)
136
- const rawIssuer = cert.issuer
137
- const normalizedIssuer = certInfo.issuerName
138
-
139
- // Check for issues in the NORMALIZED issuer (these are actual problems)
140
- const normalizedIssuerIssues = [
141
- {
142
- check: normalizedIssuer.includes('\n'),
143
- issue: 'Normalized issuer still contains newlines',
144
- },
145
- {
146
- check: normalizedIssuer.includes(' '),
147
- issue: 'Normalized issuer contains double spaces',
148
- },
149
- {
150
- check: /=\s+/.test(normalizedIssuer),
151
- issue: 'Normalized issuer has spaces after equals',
152
- },
153
- {
154
- check: /\s+=/.test(normalizedIssuer),
155
- issue: 'Normalized issuer has spaces before equals',
156
- },
157
- {
158
- check: normalizedIssuer.includes('\r'),
159
- issue: 'Normalized issuer contains carriage returns',
160
- },
161
- ]
162
-
163
- // Only report actual issues in the normalized version that will cause portal errors
164
- const hasActualFormatIssues = normalizedIssuerIssues.some(
165
- ({ check, issue }) => {
166
- if (check) {
167
- issues.push(`DS326: ${issue} - will cause X509IssuerName mismatch`)
168
- return true
169
- }
170
- return false
171
- },
172
- )
173
-
174
- // Check if raw issuer has issues but normalized version is OK (informational)
175
- const hasRawIssuesButNormalizedOk =
176
- rawIssuer.includes('\n') && !normalizedIssuer.includes('\n')
177
-
178
- if (hasActualFormatIssues) {
179
- recommendations.push(
180
- 'CRITICAL: Fix issuer name normalization in signature generation',
181
- )
182
- recommendations.push(
183
- 'Portal Error: "Certificate X509IssuerName doesn\'t match the X509IssuerName value provided in the signed properties section."',
184
- )
185
- recommendations.push(
186
- 'The normalization function is not properly formatting the issuer name',
187
- )
188
- recommendations.push(
189
- 'Debug: Check document.ts extractCertificateInfo() normalization logic',
190
- )
191
- } else if (hasRawIssuesButNormalizedOk) {
192
- // This is informational - normalization is working correctly
193
- console.log(
194
- 'ā„¹ļø Note: Raw certificate issuer has newlines but normalization is handling them correctly',
195
- )
196
- }
197
-
198
- // Additional certificate validity checks
199
- const now = new Date()
200
- const validFrom = new Date(cert.validFrom)
201
- const validTo = new Date(cert.validTo)
202
-
203
- if (now < validFrom) {
204
- issues.push('DS329: Certificate not yet valid (future start date)')
205
- recommendations.push('Wait until certificate validity period begins')
206
- }
207
-
208
- if (now > validTo) {
209
- issues.push('DS329: Certificate has expired')
210
- recommendations.push(
211
- 'BLOCKING: Renew certificate - expired certificates are rejected',
212
- )
213
- }
214
-
215
- // Check certificate key usage (if available)
216
- try {
217
- if (cert.keyUsage && !cert.keyUsage.includes('digital signature')) {
218
- issues.push('DS333: Certificate lacks digitalSignature key usage')
219
- recommendations.push(
220
- 'Generate new certificate with digitalSignature key usage enabled',
221
- )
222
- }
223
- } catch {
224
- // Key usage might not be available in all certificates
225
- console.log('Note: Could not check key usage extensions')
226
- }
227
-
228
- return {
229
- organizationIdentifier,
230
- serialNumber,
231
- issuerName: certInfo.issuerName,
232
- subjectName: certInfo.subjectName,
233
- issues,
234
- recommendations,
235
- }
236
- } catch (error) {
237
- issues.push(`Certificate parsing failed: ${error}`)
238
- recommendations.push('Verify certificate format and validity')
239
-
240
- return {
241
- issuerName: '',
242
- subjectName: '',
243
- issues,
244
- recommendations,
245
- }
246
- }
247
- }
248
-
249
- /**
250
- * Analyzes signature generation for potential issues
251
- */
252
- function analyzeSignatureForDiagnostics(
253
- invoices: InvoiceV1_1[],
254
- certificatePem: string,
255
- ): SignatureAnalysisResult {
256
- const issues: string[] = []
257
- const recommendations: string[] = []
258
-
259
- try {
260
- // Step 1: Document digest
261
- const documentDigest = calculateDocumentDigest(invoices)
262
-
263
- // Step 2: Certificate digest
264
- const certificateDigest = calculateCertificateDigest(certificatePem)
265
-
266
- // Step 3: Extract certificate info
267
- const certInfo = extractCertificateInfo(certificatePem)
268
- const signingTime = new Date().toISOString()
269
-
270
- // Step 4: Create signed properties
271
- const signedProperties = createSignedProperties(
272
- certificateDigest,
273
- signingTime,
274
- certInfo.issuerName,
275
- certInfo.serialNumber,
276
- )
277
-
278
- // Step 5: Signed properties digest
279
- const signedPropertiesDigest =
280
- calculateSignedPropertiesDigest(signedProperties)
281
-
282
- // DS333 - Document Signature Validation
283
- if (documentDigest.length === 0) {
284
- issues.push('DS333: Document digest generation failed')
285
- recommendations.push(
286
- 'CRITICAL: Verify document serialization excludes UBLExtensions/Signature',
287
- )
288
- recommendations.push(
289
- 'Portal Error: "Document signature value is not a valid signature of the document digest using the public key of the certificate provided."',
290
- )
291
- }
292
-
293
- if (certificateDigest.length === 0) {
294
- issues.push('DS333: Certificate digest generation failed')
295
- recommendations.push('CRITICAL: Verify certificate format and encoding')
296
- recommendations.push(
297
- 'Certificate must be properly base64 encoded without headers/footers',
298
- )
299
- }
300
-
301
- if (signedPropertiesDigest.length === 0) {
302
- issues.push('DS333: Signed properties digest generation failed')
303
- recommendations.push(
304
- 'CRITICAL: Verify signed properties structure and canonicalization',
305
- )
306
- recommendations.push(
307
- 'Check XML canonicalization (C14N) is applied correctly',
308
- )
309
- }
310
-
311
- // Additional DS333 checks
312
- try {
313
- const cert = new crypto.X509Certificate(certificatePem)
314
-
315
- // Verify the certificate has the required algorithms for MyInvois
316
- const publicKey = cert.publicKey
317
- const keyDetails = publicKey.asymmetricKeyDetails
318
-
319
- if (keyDetails) {
320
- // Check if key size is adequate for RSA (minimum 2048 bits)
321
- if (
322
- publicKey.asymmetricKeyType === 'rsa' &&
323
- keyDetails.modulusLength &&
324
- keyDetails.modulusLength < 2048
325
- ) {
326
- issues.push(
327
- 'DS333: RSA key size too small (minimum 2048 bits required)',
328
- )
329
- recommendations.push(
330
- 'CRITICAL: Generate new certificate with RSA 2048+ bits',
331
- )
332
- }
333
-
334
- // Check supported key types
335
- const supportedKeyTypes = ['rsa', 'ec']
336
- if (!supportedKeyTypes.includes(publicKey.asymmetricKeyType || '')) {
337
- issues.push(
338
- `DS333: Unsupported key type: ${publicKey.asymmetricKeyType}`,
339
- )
340
- recommendations.push(
341
- 'CRITICAL: Use RSA or EC key types for MyInvois compatibility',
342
- )
343
- }
344
- }
345
-
346
- // Test certificate format validity
347
- const certBuffer = Buffer.from(
348
- certificatePem.replace(/-----[^-]+-----/g, '').replace(/\s/g, ''),
349
- 'base64',
350
- )
351
- if (certBuffer.length === 0) {
352
- issues.push('DS333: Certificate encoding appears invalid')
353
- recommendations.push(
354
- 'CRITICAL: Verify certificate is properly PEM encoded',
355
- )
356
- }
357
- } catch (error) {
358
- issues.push(`DS333: Certificate validation failed - ${error}`)
359
- recommendations.push(
360
- 'CRITICAL: Verify certificate format and structure are valid',
361
- )
362
- }
363
-
364
- // Validate digest formats (should be base64)
365
- const isValidBase64 = (str: string) => {
366
- try {
367
- return Buffer.from(str, 'base64').toString('base64') === str
368
- } catch {
369
- return false
370
- }
371
- }
372
-
373
- if (documentDigest && !isValidBase64(documentDigest)) {
374
- issues.push('DS333: Document digest is not valid base64 format')
375
- recommendations.push('Ensure digest is properly base64 encoded')
376
- }
377
-
378
- if (certificateDigest && !isValidBase64(certificateDigest)) {
379
- issues.push('DS333: Certificate digest is not valid base64 format')
380
- recommendations.push(
381
- 'Ensure certificate digest is properly base64 encoded',
382
- )
383
- }
384
-
385
- if (signedPropertiesDigest && !isValidBase64(signedPropertiesDigest)) {
386
- issues.push('DS333: Signed properties digest is not valid base64 format')
387
- recommendations.push(
388
- 'Ensure signed properties digest is properly base64 encoded',
389
- )
390
- }
391
-
392
- return {
393
- documentDigest,
394
- certificateDigest,
395
- signedPropertiesDigest,
396
- issues,
397
- recommendations,
398
- }
399
- } catch (error) {
400
- issues.push(`Signature analysis failed: ${error}`)
401
- recommendations.push('Review signature generation implementation')
402
-
403
- return {
404
- documentDigest: '',
405
- certificateDigest: '',
406
- signedPropertiesDigest: '',
407
- issues,
408
- recommendations,
409
- }
410
- }
411
- }
412
-
413
- /**
414
- * Comprehensive signature diagnostics
415
- */
416
- export function diagnoseSignatureIssues(
417
- invoices: InvoiceV1_1[],
418
- certificatePem: string,
419
- ): DiagnosticResult {
420
- const certificateAnalysis = analyzeCertificateForDiagnostics(certificatePem)
421
- const signatureAnalysis = analyzeSignatureForDiagnostics(
422
- invoices,
423
- certificatePem,
424
- )
425
-
426
- const certificateIssues = certificateAnalysis.issues.length
427
- const signatureIssues = signatureAnalysis.issues.length
428
-
429
- return {
430
- certificateAnalysis,
431
- signatureAnalysis,
432
- summary: {
433
- totalIssues: certificateIssues + signatureIssues,
434
- certificateIssues,
435
- signatureIssues,
436
- },
437
- }
438
- }
439
-
440
- /**
441
- * Prints diagnostic results in a formatted way
442
- */
443
- export function printDiagnostics(result: DiagnosticResult): void {
444
- console.log('\nšŸ” MyInvois Signature Diagnostics Report')
445
- console.log('='.repeat(60))
446
-
447
- // Certificate Analysis
448
- console.log('\nšŸ“œ CERTIFICATE ANALYSIS')
449
- console.log('-'.repeat(30))
450
-
451
- console.log(` Issuer: ${result.certificateAnalysis.issuerName}`)
452
- console.log(` Subject: ${result.certificateAnalysis.subjectName}`)
453
-
454
- if (result.certificateAnalysis.organizationIdentifier) {
455
- console.log(
456
- ` Organization ID (TIN): ${result.certificateAnalysis.organizationIdentifier}`,
457
- )
458
- }
459
-
460
- if (result.certificateAnalysis.serialNumber) {
461
- console.log(` Serial Number: ${result.certificateAnalysis.serialNumber}`)
462
- }
463
-
464
- if (result.certificateAnalysis.issues.length > 0) {
465
- console.log('\n 🚨 Certificate Issues:')
466
- result.certificateAnalysis.issues.forEach((issue, index) => {
467
- console.log(` ${index + 1}. ${issue}`)
468
- })
469
- }
470
-
471
- if (result.certificateAnalysis.recommendations.length > 0) {
472
- console.log('\n šŸ’” Certificate Recommendations:')
473
- result.certificateAnalysis.recommendations.forEach((rec, index) => {
474
- console.log(` ${index + 1}. ${rec}`)
475
- })
476
- }
477
-
478
- // Signature Analysis
479
- console.log('\nšŸ” SIGNATURE ANALYSIS')
480
- console.log('-'.repeat(30))
481
-
482
- console.log(
483
- ` Document Digest: ${result.signatureAnalysis.documentDigest.substring(0, 32)}...`,
484
- )
485
- console.log(
486
- ` Certificate Digest: ${result.signatureAnalysis.certificateDigest.substring(0, 32)}...`,
487
- )
488
- console.log(
489
- ` Signed Properties Digest: ${result.signatureAnalysis.signedPropertiesDigest.substring(0, 32)}...`,
490
- )
491
-
492
- if (result.signatureAnalysis.issues.length > 0) {
493
- console.log('\n 🚨 Signature Issues:')
494
- result.signatureAnalysis.issues.forEach((issue, index) => {
495
- console.log(` ${index + 1}. ${issue}`)
496
- })
497
- }
498
-
499
- if (result.signatureAnalysis.recommendations.length > 0) {
500
- console.log('\n šŸ’” Signature Recommendations:')
501
- result.signatureAnalysis.recommendations.forEach((rec, index) => {
502
- console.log(` ${index + 1}. ${rec}`)
503
- })
504
- }
505
-
506
- // Summary
507
- console.log('\nšŸ“Š SUMMARY')
508
- console.log('-'.repeat(30))
509
- console.log(` Total Issues Found: ${result.summary.totalIssues}`)
510
- console.log(` Certificate Issues: ${result.summary.certificateIssues}`)
511
- console.log(` Signature Issues: ${result.summary.signatureIssues}`)
512
-
513
- if (result.summary.totalIssues === 0) {
514
- console.log('\n āœ… No issues detected in current analysis')
515
- console.log(' šŸŽ‰ Certificate and signature implementation appear valid')
516
- } else {
517
- console.log('\n āš ļø Issues detected - review recommendations above')
518
-
519
- // Check for specific portal errors
520
- const hasDS311 = result.certificateAnalysis.issues.some(issue =>
521
- issue.includes('DS311'),
522
- )
523
- const hasDS312 = result.certificateAnalysis.issues.some(issue =>
524
- issue.includes('DS312'),
525
- )
526
- const hasDS326 = result.certificateAnalysis.issues.some(issue =>
527
- issue.includes('DS326'),
528
- )
529
- const hasDS329 = result.certificateAnalysis.issues.some(issue =>
530
- issue.includes('DS329'),
531
- )
532
- const hasDS333 = result.signatureAnalysis.issues.some(issue =>
533
- issue.includes('DS333'),
534
- )
535
-
536
- console.log('\n šŸŽÆ MYINVOIS PORTAL ERROR ANALYSIS:')
537
-
538
- if (hasDS311) {
539
- console.log(
540
- ' āŒ DS311 - TIN mismatch between certificate and submitter',
541
- )
542
- }
543
-
544
- if (hasDS312) {
545
- console.log(
546
- ' āŒ DS312 - Registration number mismatch with certificate',
547
- )
548
- }
549
-
550
- if (hasDS326) {
551
- console.log(' āŒ DS326 - X509IssuerName format inconsistency')
552
- }
553
-
554
- if (hasDS329) {
555
- console.log(' āŒ DS329 - Certificate trust chain validation failure')
556
- }
557
-
558
- if (hasDS333) {
559
- console.log(' āŒ DS333 - Document signature validation failure')
560
- }
561
-
562
- if (result.summary.certificateIssues > 0) {
563
- console.log('\n 🚨 PRIMARY ACTION REQUIRED:')
564
- console.log(' Certificate issues must be resolved first')
565
- console.log(
566
- ' Self-generated certificates cannot pass MyInvois validation',
567
- )
568
- }
569
-
570
- if (result.summary.signatureIssues > 0) {
571
- console.log('\n āš™ļø SECONDARY ACTION:')
572
- console.log(' Review and optimize signature implementation')
573
- }
574
-
575
- console.log('\n šŸ“‹ NEXT STEPS:')
576
- console.log(' 1. Address BLOCKING/CRITICAL issues first')
577
- console.log(' 2. Test with updated certificate/implementation')
578
- console.log(' 3. Re-run diagnostics to verify fixes')
579
- console.log(' 4. Submit test document to MyInvois portal')
580
- }
581
-
582
- console.log('\n' + '='.repeat(60))
583
- }