v1.7.0
First release on the new build/test/packaging foundation, bringing the library's
error and validation behavior in line with the W3C Web Crypto specification.
This release contains breaking changes — please review the migration notes below.
Added
- Rewritten TypeScript declarations (
types/msrCrypto.d.ts) describing theMsrCrypto
surface and resolving for the@microsoft/msrcryptoimport (export =). Errorstest module asserting correct rejection/throw names, plus the
previously-unwiredCryptoKeytest module.- npm package metadata (
keywords,author,homepage,bugs,exports,
sideEffects,publishConfig) and aprepublishOnlybuild guard. - Dormant GitHub Actions release workflow that builds, verifies the package, and
publishes to npm with provenance on tagged releases.
Changed
SubtleCryptoalgorithm params accept a stringAlgorithmIdentifier(e.g.
"SHA-256") in addition to an object.- Invalid input / unsupported algorithms surface as rejected promises per the Web
Crypto contract. - Library errors are
DOMExceptions (NotSupportedError,OperationError,
InvalidAccessError,DataError), with anErrorfallback on engines lacking
DOMException. - Bundle version injected from
package.jsonat build time, eliminating version drift. - Build migrated to esbuild (
build.mjs), producing unminified and minified bundles;
Node 18+ required.
⚠️ Breaking changes — migration
- Async errors: wrap
SubtleCryptocalls with.catch()/awaitinstead of
try/catch. Missing/wrong-type arguments reject withTypeError. - Error shape: inspect
error.name(e.g.OperationError,DataError) rather than
error.messageor custom fields. On engines withoutDOMException(e.g. IE8), a
fallbackErrorcarries the samenameand legacycode. getRandomValues: throwsQuotaExceededErrorfor requests > 65,536 bytes and
TypeMismatchErrorfor floating-point typed arrays.- Stricter
generateKey: AES rejects key lengths other than 128/192/256 bits; HMAC
interpretslengthas bits. - Layout: built output moved
lib/→dist/, declarationsdefinitions/→
types/. Imports by package name are unaffected; deep paths like
@microsoft/msrcrypto/lib/...must be updated. - Node: minimum supported version is now 18.
Fixed
- HMAC
generateKeyhonors the optionallength(bits) and zeroes unused trailing bits
for non-byte-aligned lengths. - AES
generateKey(CBC, GCM, KW) rejects key lengths other than 128/192/256 bits. - Removed a stray
console.logthat leaked exported key material duringwrapKey. - Fixed a worker result-path error when assigning to read-only
DOMException.code. - RSA
generateKeyhonors requested usages (routing each to the applicable
public/private key);RSA-OAEPwith["wrapKey","unwrapKey"]now yields usable keys.
Removed
- Dead
wrapKey.jsmodule and its orphaned JWK byte-serializer. Public
wrapKey/unwrapKeycontinue to work via the standard
export-then-encrypt / decrypt-then-import path.