Canonical post-quantum algorithm identifier mappings across name, oid, jose, cose, and x509 descriptor shapes.
Package boundary:
pq-oid: low-level OID primitives (constants, OID encode/decode)pq-algorithm-id: multi-identifier mapping and normalization API
npm install pq-algorithm-idimport {
fromCose,
fromJose,
fromOid,
fromX509AlgorithmIdentifier,
normalizeX509AlgorithmIdentifier,
resolveX509AlgorithmIdentifier,
toCose,
toJose,
toOid,
toX509AlgorithmIdentifier,
} from 'pq-algorithm-id';
// Name/OID lookup
toOid('ML-DSA-65'); // '2.16.840.1.101.3.4.3.18'
fromOid('2.16.840.1.101.3.4.3.18'); // 'ML-DSA-65'
// JOSE/COSE mapping (currently ML-DSA only)
toJose('ML-DSA-65'); // 'ML-DSA-65'
fromJose('ML-DSA-65'); // 'ML-DSA-65'
toCose('ML-DSA-65'); // -49
fromCose(-49); // 'ML-DSA-65'
// X.509 descriptor mapping
toX509AlgorithmIdentifier('ML-KEM-768');
// {
// oid: '2.16.840.1.101.3.4.4.2',
// parameters: { kind: 'absent' }
// }
normalizeX509AlgorithmIdentifier({
oid: '2.16.840.1.101.3.4.3.18',
parameters: { kind: 'absent' },
});
// {
// oid: '2.16.840.1.101.3.4.3.18',
// parameters: { kind: 'absent' }
// }
resolveX509AlgorithmIdentifier({
oid: '2.16.840.1.101.3.4.3.18',
parameters: { kind: 'absent' },
});
// {
// name: 'ML-DSA-65',
// oid: '2.16.840.1.101.3.4.3.18',
// parameters: { kind: 'absent' }
// }fromOid,fromJose, andfromCoseare strict lookups (no trimming, no case normalization).toOid,toJose, andtoCoserequirenameto be a runtime string and throwInvalidArgumentErrorfor non-string inputs.toX509AlgorithmIdentifier(name)emitsparameters: { kind: 'absent' }and rejects unsupportedparametersEncodingvalues withInvalidArgumentError; explicitparametersEncoding: undefinedis treated the same as omission.normalizeX509AlgorithmIdentifier(input)treats both a missingparametersproperty and explicitparameters: undefinedas absent.normalizeX509AlgorithmIdentifier(input)accepts onlynull,{ kind: 'absent' }, and{ kind: 'null' }for explicit parameter values, but strict X.509 policy only permitsparameters: { kind: 'absent' }.resolveX509AlgorithmIdentifier(input)is an opt-in parser that returns{ name, oid, parameters }when you need the resolved algorithm name.fromX509AlgorithmIdentifier(input)is retained as a backwards-compatible alias fornormalizeX509AlgorithmIdentifier(input).- X.509 APIs reject unknown own properties on
input,options, and explicitparametersobjects. - X.509 APIs are designed for plain data objects;
Proxytraps can execute during object inspection, and related inspection failures are surfaced asInvalidArgumentErrorwithcause. - Malformed API inputs (for example non-string
oidor unexpectedparametersEncoding) throwInvalidArgumentError. - Unsupported mappings (for example
toJose('ML-KEM-512')) throw typed errors. - Diagnostic values in thrown messages are escaped and truncated to bounded previews to avoid oversized error payloads; raw metadata fields on typed errors are intentionally non-enumerable.
Suggested downstream migration order:
pq-key-encoderpq-cosepq-jwspq-jwk
Dependency and release policy for 0.x series:
- When
pq-algorithm-idneeds newerpq-oidbehavior, first bump the exact pinnedpq-oiddependency version in this package. - Then release a new
pq-algorithm-idversion. - No cross-package release sequencing workflow is required by this plan.
Until 1.0.0, pq-algorithm-id uses an exact pq-oid version pin (exact semver, no range operators), and upstream dependency bumps are the trigger for pq-algorithm-id releases.
MIT