This pull request adds index.d.ts, implementing TypeScript typings for the sodium-plus's main entry point index.js.
The typings are mostly straightforward conversions based on the docstrings of each function. In some cases where it seemed to make sense I deviated from the docs a bit:
getBackendObject returns an opaque type Backend that is also branded, so functions expecting Backend instances shouldn't accept any other types (well, except any).
Stream and hashing states (as returned by crypto_secretstream_xchacha20poly1305_init_* and crypto_generichash_init) are now similarly opaque & branded types.
This pull request adds index.d.ts, implementing TypeScript typings for the sodium-plus's main entry point index.js.
The typings are mostly straightforward conversions based on the docstrings of each function. In some cases where it seemed to make sense I deviated from the docs a bit:
getBackendObject
returns an opaque typeBackend
that is also branded, so functions expectingBackend
instances shouldn't accept any other types (well, exceptany
).crypto_secretstream_xchacha20poly1305_init_*
andcrypto_generichash_init
) are now similarly opaque & branded types.CryptographyKey
(or its subclasses) are branded using theprivate readonly __nominal: void
trick.tag
parameter given tocrypto_secretstream_xchacha20poly1305_pu*
only accepts valid numeric values.The index.d.ts file is added to package.json's files array. The @types/node package is added as a devDependency.