{"name":"@postalsys/vmc","version":"1.0.6","keywords":["VMC"],"author":{"name":"Postal Systems OÜ"},"license":"MIT","_id":"@postalsys/vmc@1.0.6","maintainers":[{"name":"andris","email":"andris@kreata.ee"}],"dist":{"shasum":"194f7a234ef39ed3b33c1b2731c3d8d79cd3dacb","tarball":"http://registry-npm.ywwl.com/@postalsys/vmc/download/@postalsys/vmc-1.0.6.tgz","fileCount":28,"integrity":"sha512-5VdvQHpB6mIf7Lj0efArfZjRy3NuvjK51ZytoWOpw6I4XMgWsdv++UDbHMq9bKTtnAvGwBZRFVKeBoPAhYWJ7A==","signatures":[{"sig":"MEQCIBI5Y6aQ0hYJFVcSV5s3+DyeA8pgwsmNM0r9AiUCdNBLAiAan3YP4IFEmAgEQ54bCjtd1OoByWrk2kiH04N5EswK4w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":80626,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi/db8ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpUgxAAgeQT+9b9Dv+OfzhXWtOGjL35w3ZlPvV+L6kFv9sDMxj3idJp\r\nSUBkNgt6BCWhTqxgRQpMknu/oivAVapciLsbeKlb5q1PrUhsvoffxmZZ1QOy\r\nbeIqjoeL5+GpIH5ZP8df6nC+OHMB3NdmwRIBAIl/UjKmfVLo+Ggyx7exgc/A\r\nL3gFi/FV6EZv9iP7USIXFGQu43TYh4ph4R1V+9FvLeUQZ3bcOTG8UHNl/lQA\r\nhy82MpOy9LIIN45wHTBQG61KT3hHpY35hxqSqBjbob86nIxLHMB0gwvGscuD\r\niBaedPc6y4KfpzOmkR9QKvCzmqhUr44wNpDD0ct3my5abHKLHTdgwEByKHxp\r\nEzxhtOY/3rwN8CHIhtAAXAvh8NmvTvDbON8TTa6uHv/9X9Tpti8IWWclkhQ0\r\n2+qEkeQPd6UKf22SqHBQNETZePBchOYwJ4RRZp6MCb2U6Beh7l5dtYvfX2t1\r\n712B2mNQbdKyghyL5h8YQr3h6X9nUTaexGlSB4HZmL7fKtUsx/2cyEhZcZ2f\r\nH9h9K6bofbiyTyS9Gy+2sUAFFFRSh3Zn7GliUgZ4LCC1OXC0Qkt2x/+P4J1D\r\n+sBH/Y/21HV+9ZCIau5pXjy+z6fw089mQUaFw7DgKNZ8yIl6GoAvWqKYB00T\r\n670usq/q5xy+slS23jbbr7AX1TF1IKVxheY=\r\n=bOrb\r\n-----END PGP SIGNATURE-----\r\n","size":30921,"noattachment":false,"key":"/@postalsys/vmc/-/@postalsys/vmc-1.0.6.tgz"},"main":"lib/vmc.js","gitHead":"8fcdcf7aa44d39a4b2365811150e0e006f7ceca5","scripts":{"test":"eslint \"lib/**/*.js\" \"test/**/*.js\" && mocha --recursive \"./test/**/*.js\" --reporter spec","prepublish":"npm run root-store || true","root-store":"node build-root-store.js"},"_npmUser":{"name":"andris","email":"andris@kreata.ee"},"_npmVersion":"8.10.0","description":"Parse VMC logo files","directories":{},"_nodeVersion":"18.1.0","dependencies":{"@peculiar/asn1-x509":"2.3.0","@peculiar/asn1-schema":"2.3.0","@peculiar/asn1-x509-logotype":"2.3.0"},"_hasShrinkwrap":false,"devDependencies":{"chai":"4.3.6","mocha":"10.0.0","eslint":"8.22.0","eslint-config-prettier":"8.5.0","eslint-config-nodemailer":"1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/vmc_1.0.6_1660802812360_0.8827016220553949","host":"s3://npm-registry-packages"},"readme":"# VMC\n\nA Node.js library for parsing and validating VMC (Verified Mark Certificate) and CMC (Common Mark Certificate) logo files used in BIMI (Brand Indicators for Message Identification) email authentication.\n\n## Installation\n\n```bash\nnpm install @postalsys/vmc\n```\n\n## Usage\n\n```javascript\nconst { vmc, RootStore } = require('@postalsys/vmc');\nconst fs = require('fs');\n\n// Load a PEM certificate bundle (leaf cert + intermediates)\nconst pemBundle = fs.readFileSync('certificate.pem');\n\n// Parse and validate the VMC\nconst logo = await vmc(pemBundle);\n\nconsole.log(logo.type); // 'VMC' or 'CMC'\nconsole.log(logo.mediaType); // 'image/svg+xml'\nconsole.log(logo.validHash); // true if logo hash matches\nconsole.log(logo.logoFile); // Base64-encoded SVG logo\nconsole.log(logo.certificate); // Certificate details\n```\n\n### Using a Custom Root Store\n\n```javascript\nconst { vmc, RootStore } = require('@postalsys/vmc');\n\n// Create a custom root store\nconst rootStore = RootStore.create();\n\n// Optionally add additional trusted root certificates\nrootStore.addCert(customRootPem);\n\nconst logo = await vmc(pemBundle, { rootStore });\n```\n\n### Validating at a Specific Time\n\n```javascript\n// Useful for testing with certificates that may have expired\nconst logo = await vmc(pemBundle, { now: new Date('2024-01-15') });\n```\n\n## API\n\n### vmc(pem, [options])\n\nParses and validates a VMC/CMC certificate bundle.\n\n**Parameters:**\n\n- `pem` (Buffer|string) - PEM-encoded certificate bundle containing the leaf certificate and any intermediate certificates\n- `options` (object, optional)\n    - `rootStore` (RootStore) - Custom root store for certificate validation. Defaults to built-in VMC root certificates.\n    - `now` (Date) - Date to use for certificate validity checks. Defaults to current time.\n\n**Returns:** Promise resolving to an object:\n\n```javascript\n{\n  type: 'VMC',              // 'VMC' (Verified Mark) or 'CMC' (Common Mark)\n  mediaType: 'image/svg+xml',\n  hashAlgo: 'sha256',       // Hash algorithm used\n  hashValue: '07001de5...',  // Hex-encoded hash of the logo\n  validHash: true,          // Whether the logo hash is valid\n  logoFile: 'PHN2ZyB4...',  // Base64-encoded logo file (SVG)\n  certificate: {\n    subject: {\n      commonName: 'Example Corp',\n      organizationName: 'Example Corp',\n      countryName: 'US',\n      trademarkRegistration: '1234567',\n      // ... other fields\n    },\n    subjectAltName: ['example.com'],\n    fingerprint: '17:B3:94:...',\n    serialNumber: '0A1B2C...',\n    validFrom: '2024-01-01T00:00:00.000Z',\n    validTo: '2025-01-01T00:00:00.000Z',\n    issuer: { /* issuer details */ }\n  }\n}\n```\n\n### RootStore\n\nClass for managing trusted root certificates.\n\n#### RootStore.create([config])\n\nCreates a new RootStore instance preloaded with built-in VMC root certificates (DigiCert, Entrust, GlobalSign, SSL.com).\n\n#### rootStore.addCert(pem)\n\nAdds a trusted root certificate to the store.\n\n- `pem` (string) - PEM-encoded certificate\n- Returns `true` if added, `false` if duplicate\n\n## Error Codes\n\nAll errors include a `code` property for programmatic handling:\n\n| Code                             | Description                                     |\n| -------------------------------- | ----------------------------------------------- |\n| `INVALID_CERT_BUNDLE`            | Empty or invalid PEM certificate bundle         |\n| `INVALID_CHAIN`                  | Certificate chain validation failed             |\n| `INVALID_LOGOTYPE_EXT`           | Certificate missing required logotype extension |\n| `CERTIFICATE_VERIFICATION_ERROR` | Certificate expired or not yet valid            |\n| `SELF_SIGNED_CERT_IN_CHAIN`      | No trusted root found for the certificate chain |\n| `BIMI_EXT_KEY_MISSING`           | Certificate missing BIMI Extended Key Usage OID |\n\n```javascript\ntry {\n    const logo = await vmc(pemBundle);\n} catch (err) {\n    if (err.code === 'CERTIFICATE_VERIFICATION_ERROR') {\n        console.log('Certificate has expired');\n    }\n}\n```\n\n## VMC vs CMC\n\n- **VMC (Verified Mark Certificate)** - Requires a registered trademark\n- **CMC (Common Mark Certificate)** - For marks without trademark registration (Prior Use Mark, Modified Registered Mark)\n\nThe `type` field in the response indicates which certificate type was used.\n\n## License\n\nMIT\n","publish_time":1660802812537,"_cnpm_publish_time":1660802812537,"dist-tags":{"latest":"1.1.5"}}