Skip to content

Commit

Permalink
Merge branch 'player/use-event-sender' into player/remove-playback-pr…
Browse files Browse the repository at this point in the history
…ogress-event
  • Loading branch information
enjikaka committed May 6, 2024
2 parents bdfe4af + 1fc14a8 commit 5d35cfc
Show file tree
Hide file tree
Showing 33 changed files with 609 additions and 802 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

/packages/ @tidal-music/tidal-web-platform
/packages/auth/ @MathiasTim
/packages/event-producer @TheHaff
/packages/event-producer @tidal-music/tidal-web-platform
/packages/player @enjikaka
2 changes: 1 addition & 1 deletion .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ runs:
- name: Install package manager
uses: pnpm/action-setup@v3
with:
version: 8.15.4
version: 9.0.5
- name: Set up Node.js w/ version from .nvmrc
uses: actions/setup-node@v4
with:
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ on:
paths:
- packages/true-time/**
- packages/player/**
merge_group:
types: [checks_requested]
paths:
- packages/true-time/**
- packages/player/**

concurrency:
group: cypress-${{ github.event.pull_request.number || github.ref }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Pull Request

on:
pull_request:
merge_group:
type: [checks_requested]

jobs:
fossa-scans:
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.12.0
20.12.2
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default [
'no-restricted-syntax': [
'error',
{
message: 'Never use Date.now! always use TrueTime',
message: 'Never use Date.now! always use trueTime.now()',
selector:
'CallExpression[callee.object.name="Date"][callee.property.name="now"]',
},
Expand Down
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tidal-music/tidal-sdk-web",
"packageManager": "pnpm@8.15.5",
"packageManager": "pnpm@9.0.5",
"private": true,
"type": "module",
"scripts": {
Expand All @@ -17,13 +17,14 @@
"devDependencies": {
"eslint": "8.57.0",
"eslint-config-tidal": "3.2.0",
"eslint-plugin-disable-autofix": "4.2.0",
"eslint-plugin-jsdoc": "48.2.2",
"typedoc": "0.25.12"
"eslint-plugin-disable-autofix": "4.3.0",
"eslint-plugin-jsdoc": "48.2.3",
"typedoc": "0.25.13",
"vitest": "1.5.0"
},
"engines": {
"node": ">=20.11.1",
"pnpm": ">=8.6.7"
"pnpm": ">=9.0.5"
},
"prettier": {
"arrowParens": "avoid",
Expand All @@ -35,7 +36,7 @@
],
"pnpm": {
"patchedDependencies": {
"[email protected].11": "patches/[email protected].11.patch"
"[email protected].13": "patches/[email protected].13.patch"
}
}
}
2 changes: 1 addition & 1 deletion packages/auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This authentication method uses `clientId` and `clientSecret`, e.g. when utilizi
## Authorization Code Flow (user login)
(Only available for TIDAL internally developed applications for now)

To implement the login redirect flow, follow these steps or refer to our example for ["login redirect"](./examples/login-redirect.html).
To implement the login redirect flow, follow these steps or refer to our example for ["authorization code"](./examples/authorization-code.html).

1. Initiate the process by calling the `init` function.
2. For the first login:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<body>
<a href="../">Back to all examples</a>
<h1>Login redirect</h1>
<h1>Authorization code</h1>
<p>
This example showcases how to login through login.tidal.com and get redirected back to your app.
You need a properly configured clientId, which is tied to a secure redirect uri.
Expand All @@ -26,7 +26,7 @@ <h1>Login redirect</h1>
</p>


<form id="loginRedirectForm">
<form id="authorizationCodeForm">
<label>
<span>Client Id</span>
<input type="text" name="clientId" required />
Expand All @@ -45,7 +45,7 @@ <h1>Login redirect</h1>
<button id="getUserBtn">Get user</button>
<button id="forceRefreshBtn">Force Refresh (sub status)</button>

<script type="module" src="./login-redirect.js"></script>
<script type="module" src="./authorization-code.js"></script>
</body>

</html>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { finalizeLogin, init, initializeLogin, logout } from '../dist';
import { getUserInfo } from './shared';

window.addEventListener('load', () => {
const form = document.getElementById('loginRedirectForm');
const form = document.getElementById('authorizationCodeForm');
const logoutButton = document.getElementById('logoutBtn');

form?.addEventListener('submit', event => {
Expand Down Expand Up @@ -34,7 +34,7 @@ const submitHandler = async event => {
await init({
clientId,
clientUniqueKey: 'test',
credentialsStorageKey: 'loginRedirect',
credentialsStorageKey: 'authorizationCode',
});

const loginUrl = await initializeLogin({
Expand All @@ -47,20 +47,20 @@ const submitHandler = async event => {
const loadHandler = async () => {
const clientId = localStorage.getItem('clientId');
const redirectUri = localStorage.getItem('redirectUri');
const form = document.getElementById('loginRedirectForm');
const form = document.getElementById('authorizationCodeForm');

if (clientId && redirectUri) {
form.style.display = 'none';

await init({
clientId,
clientUniqueKey: 'test',
credentialsStorageKey: 'loginRedirect',
credentialsStorageKey: 'authorizationCode',
});

if (window.location.search.length > 0) {
await finalizeLogin(window.location.search);
window.location.replace('/examples/login-redirect.html');
window.location.replace('/examples/authorization-code.html');
} else {
await getUserInfo();
document.getElementById('getUserBtn').style.display = 'block';
Expand Down
4 changes: 2 additions & 2 deletions packages/auth/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
<h1>Auth module examples</h1>
<ul>
<li><a href="./examples/client-credentials.html">Client Credentials</a></li>
<li><a href="./examples/login-redirect.html">Login redirect</a></li>
<li><a href="./examples/authorization-code.html">Authorization code</a></li>
<li><a href="./examples/limited-input-device.html">Limited input device (e.g. TVs)</a></li>
<li><a href="./examples/setting-credentials.html">Setting credentials</a></li>
</ul>

</body>

</html>
</html>
14 changes: 7 additions & 7 deletions packages/auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tidal-music/auth",
"version": "1.2.2",
"version": "1.3.0",
"type": "module",
"files": [
"dist"
Expand Down Expand Up @@ -40,11 +40,11 @@
"@tidal-music/true-time": "workspace:^"
},
"devDependencies": {
"@vitest/coverage-v8": "1.4.0",
"@vitest/ui": "1.4.0",
"typescript": "5.4.3",
"vite": "5.2.7",
"vite-plugin-dts": "3.8.1",
"vitest": "1.4.0"
"@vitest/coverage-v8": "1.5.0",
"@vitest/ui": "1.5.0",
"typescript": "5.4.5",
"vite": "5.2.10",
"vite-plugin-dts": "3.8.3",
"vitest": "1.5.0"
}
}
15 changes: 6 additions & 9 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,13 @@
"test:ui": "pnpm run test:coverage --ui",
"typecheck": "tsc"
},
"dependencies": {
"@tidal-music/common": "workspace:*"
},
"devDependencies": {
"@tidal-music/event-producer": "workspace:*",
"@vitest/coverage-v8": "1.4.0",
"@vitest/ui": "1.4.0",
"typescript": "5.4.3",
"vite": "5.2.7",
"vite-plugin-dts": "3.8.1",
"vitest": "1.4.0"
"@vitest/coverage-v8": "1.5.0",
"@vitest/ui": "1.5.0",
"typescript": "5.4.5",
"vite": "5.2.10",
"vite-plugin-dts": "3.8.3",
"vitest": "1.5.0"
}
}
20 changes: 10 additions & 10 deletions packages/event-producer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tidal-music/event-producer",
"version": "2.0.4",
"version": "2.2.0",
"type": "module",
"files": [
"dist"
Expand Down Expand Up @@ -36,21 +36,21 @@
"typecheck": "tsc"
},
"devDependencies": {
"@vitest/coverage-v8": "1.4.0",
"@vitest/ui": "1.4.0",
"@vitest/web-worker": "1.4.0",
"happy-dom": "14.3.9",
"typescript": "5.4.3",
"vite": "5.2.7",
"vite-plugin-dts": "3.8.1",
"vitest": "1.4.0",
"@vitest/coverage-v8": "1.5.0",
"@vitest/ui": "1.5.0",
"@vitest/web-worker": "1.5.0",
"happy-dom": "14.7.1",
"typescript": "5.4.5",
"vite": "5.2.10",
"vite-plugin-dts": "3.8.3",
"vitest": "1.5.0",
"xml-js": "1.6.11"
},
"dependencies": {
"@tidal-music/common": "workspace:^",
"@tidal-music/event-producer": "workspace:*",
"@tidal-music/true-time": "workspace:^",
"localforage": "1.10.0",
"nanoid": "5.0.6"
"nanoid": "5.0.7"
}
}
2 changes: 1 addition & 1 deletion packages/event-producer/src/monitor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const sendMonitoringInfo = async () => {
consentCategory: 'NECESSARY',
credentials: await config.credentialsProvider?.getCredentials(),
platformData: config.platform,
sentTimestamp: trueTime.now().toString(),
sentTimestamp: trueTime.now(),
}),
id: uuid(),
name: 'tep-tl-monitoring',
Expand Down
2 changes: 1 addition & 1 deletion packages/event-producer/src/send/send.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe.sequential('sendEvent', () => {
expect.objectContaining({
payload: JSON.stringify({
...eventWithoutConsentCategory,
ts: '1337',
ts: 1337,
uuid: 'fakeUuid',
}),
}),
Expand Down
4 changes: 2 additions & 2 deletions packages/event-producer/src/send/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { uuid } from '../uuid/uuid';
type CreatePayloadParams = {
event: SentEvent;
id: string;
ts: string;
ts: number;
};
/**
* Creates a payload to be sent to backend. The payload is the whole raw event with uuid
Expand Down Expand Up @@ -40,7 +40,7 @@ const createEvent = async ({
event,
}: SendEventParams): Promise<EPEvent> => {
const id = uuid();
const sentTimestamp = trueTime.now().toString();
const sentTimestamp = trueTime.now();
const headers = getEventHeaders({
appInfo: config.appInfo,
consentCategory: event.consentCategory,
Expand Down
2 changes: 1 addition & 1 deletion packages/event-producer/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type AppInfo = {
appVersion: string;
};

export type EventHeaders = Record<string, string>;
export type EventHeaders = Record<string, number | string>;

/**
* This is an incoming raw event.
Expand Down
6 changes: 3 additions & 3 deletions packages/event-producer/src/utils/headerUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('headerUtils', () => {
consentCategory: 'NECESSARY',
credentials: credentials1,
platformData: config.platform,
sentTimestamp: '2023',
sentTimestamp: 2023,
suppliedHeaders: {
someXtraHeader: 'eggs',
},
Expand All @@ -26,7 +26,7 @@ describe('headerUtils', () => {
'client-id': 'fakeClientId',
'consent-category': 'NECESSARY',
'os-name': config.platform.osName,
'requested-sent-timestamp': '2023',
'requested-sent-timestamp': 2023,
someXtraHeader: 'eggs',
});
});
Expand All @@ -37,7 +37,7 @@ describe('headerUtils', () => {
consentCategory: 'NECESSARY',
credentials: credentials1,
platformData: config.platform,
sentTimestamp: '2023',
sentTimestamp: 2023,
suppliedHeaders: {
'app-name': 'bacon',
someXtraHeader: 'eggs',
Expand Down
4 changes: 2 additions & 2 deletions packages/event-producer/src/utils/headerUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export const getEventHeaders = ({
consentCategory: ConsentCategory;
credentials?: Credentials;
platformData: PlatformData;
sentTimestamp: string;
suppliedHeaders?: Record<string, string>;
sentTimestamp: number;
suppliedHeaders?: Record<string, number | string>;
}) => {
const accessToken = credentials?.token;
const clientId = credentials?.clientId ?? 'clientIDMissing!';
Expand Down
12 changes: 6 additions & 6 deletions packages/player-web-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
"@tidal-music/auth": "workspace:^",
"@tidal-music/common": "workspace:^",
"@tidal-music/player": "workspace:^",
"@vitest/coverage-v8": "1.4.0",
"@vitest/ui": "1.4.0",
"typescript": "5.4.3",
"vite": "5.2.7",
"vite-plugin-dts": "3.8.1",
"vitest": "1.4.0"
"@vitest/coverage-v8": "1.5.0",
"@vitest/ui": "1.5.0",
"typescript": "5.4.5",
"vite": "5.2.10",
"vite-plugin-dts": "3.8.3",
"vitest": "1.5.0"
}
}
Loading

0 comments on commit 5d35cfc

Please sign in to comment.