Skip to content
Client
Server

Reference / @open-music-sdk/developer-token / developerTokenMinter

Function: developerTokenMinter() ​

ts
function developerTokenMinter(options): tDeveloperTokenProvider;

Defined in: mint.ts:151

A developerToken provider that mints on first use and reuses the token, replacing it in the background halfway through its life. Concurrent requests share one mint, and a token Apple answers 401 to is replaced.

The options are read once, here, and the PEM held wrapped so that nothing prints it. The key is imported on first use and the PEM let go of: from then on the minter holds a key that can sign and cannot be exported, and no copy of the text it came from.

Parameters ​

options ​

tMinterOptions

The key, whose it is, what each token says about itself, and how far ahead of exp the next is minted.

Returns ​

tDeveloperTokenProvider

A provider to pass as developerToken. Minting is local, so it rejects only with a TypeError on first use when pem is not a PKCS8 P-256 private key, and with the reason of a signal that aborts before a token is had.

Throws ​

TypeError if an option is not what it should be, when the minter is created and before anything is signed.

MIT licensed. Not affiliated with, endorsed by, or sponsored by Apple Inc. Apple Music and MusicKit are trademarks of Apple Inc.