Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ The build commands outputs to the dist folder where the front-end parts are outp
| Variable Name | Description |
| ------------- | ----------- |
| EMBED_API_TOKEN | Required - Your TIDAL API token |
| EMBED_API_PUBLIC_KEY | Required - API key for new Tidal API calls |
| EMBED_API_TOKEN__NOSTR| Not required - for Nostr logged in full length playback support |
| TRACK_JS_TOKEN | Not required - Specify along with TRACK_JS_APPLICATION to include TrackJS |
| TRACK_JS_APPLICATION | Not required - Specify along with TRACK_JS_TOKEN to include TrackJS |
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"gh-action:start": "LAMBDA_TASK_ROOT=true AWS_EXECUTION_ENV=true AWS_ENV=fakelamda node src/server/local/index.js"
},
"devDependencies": {
"@tidal-music/auth": "1.4.0",
"@tidal-music/common": "0.2.0",
"@tidal-music/event-producer": "2.4.0",
"@tidal-music/player": "0.11.0",
Expand Down
1 change: 1 addition & 0 deletions scripts/esbuild-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const context = await esbuild.context({
define: {
// @ts-ignore
'process.env.EMBED_API_TOKEN': `'${process.env.EMBED_API_TOKEN}'`,
'process.env.EMBED_API_PUBLIC_KEY': `'${process.env.EMBED_API_PUBLIC_KEY}'`,
'process.env.EMBED_API_TOKEN__NOSTR': `'${process.env.EMBED_API_TOKEN__NOSTR}'`,
},
plugins: [
Expand Down
37 changes: 26 additions & 11 deletions src/client/js/playback/auth-provider.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { credentialsProvider, init as authSDKInit } from '@tidal-music/auth';

import DialogController from '../dialog-controller.js';

/**
Expand All @@ -10,6 +12,28 @@ const credentialsUpdatedEvent = new CustomEvent('credentialsUpdated', {
});

class DefaultCredentialsProvider {
constructor() {
if (
!process.env.EMBED_API_TOKEN ||
!process.env.EMBED_API_PUBLIC_KEY ||
process.env.EMBED_API_PUBLIC_KEY === 'undefined'
) {
throw new ReferenceError(
'You are running without setting an EMBED_API_TOKEN and an EMBED_API_PUBLIC_KEY variable',
);
}

authSDKInit({
clientId: process.env.EMBED_API_TOKEN,
clientSecret: process.env.EMBED_API_PUBLIC_KEY,
clientUniqueKey: 'tidal_embed_player',
credentialsStorageKey: 'tidal_embed_player',
scopes: [],
tidalAuthServiceBaseUri: 'https://auth.tidal.com/v1/',
tidalLoginServiceBaseUri: 'https://login.tidal.com/',
});
}

/**
* @type {import('@tidal-music/common/dist').Bus} fn
*/
Expand All @@ -20,17 +44,8 @@ class DefaultCredentialsProvider {
/**
* @type {import('@tidal-music/common/dist').GetCredentials} fn
*/
async getCredentials() {
if (process.env.EMBED_API_TOKEN) {
return {
clientId: process.env.EMBED_API_TOKEN,
requestedScopes: [],
};
}

throw new ReferenceError(
'You are running without setting an EMBED_API_TOKEN variable',
);
getCredentials(apiErrorSubStatus) {
return credentialsProvider.getCredentials(apiErrorSubStatus);
}
}

Expand Down
Loading