-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
34 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const jwt = require('jsonwebtoken') | ||
|
||
/** | ||
* | ||
* @param {Object} credentials Apple Music credentials. Consists of a key containing MusicKit privileges, the team ID of developer account and the ID of the key | ||
* @param {string} credentials.key A valid key generated from developer console that has MusicKit permissions | ||
* @param {string} credentials.keyId ID of the credentials.key | ||
* @param {string} credentials.teamId ID of the team that credentials.key belongs to | ||
*/ | ||
const createJWT = (credentials) => { | ||
if (!credentials || !credentials.key || !credentials.teamId || !credentials.keyId) { | ||
throw new Error("No credentials supplied") | ||
} | ||
|
||
return jwt.sign({}, credentials.key, { | ||
algorithm: 'ES256', | ||
expiresIn: '180d', | ||
issuer: credentials.teamId, | ||
header: { | ||
alg: 'ES256', | ||
kid: credentials.keyId | ||
} | ||
}); | ||
} | ||
|
||
module.exports.createJWT = createJWT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters