From 22b94048e930d5e9bcbd5cc71ea1537f7d5754bf Mon Sep 17 00:00:00 2001 From: mirovladimitrovski Date: Thu, 20 Jun 2024 16:35:06 +0200 Subject: [PATCH 1/2] Send authorization header for getSignedMediaToken conditionally --- CHANGELOG.md | 6 ++++++ package.json | 2 +- src/endpoints/asset.ts | 17 ++++++++--------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9abef04a..b6c693f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to this project will be documented in this file. +# [3.13.28] - 20-06-2024 + +### Fixes + +- Send authorization header for `getSignedMediaToken` conditionally + # [3.13.27] - 19-06-2024 ### Changes diff --git a/package.json b/package.json index 39703be4..2645a19f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@inplayer-org/inplayer.js", - "version": "3.13.27", + "version": "3.13.28", "author": "InPlayer", "license": "MIT", "description": "A Javascript SDK for Inplayer's RESTful API", diff --git a/src/endpoints/asset.ts b/src/endpoints/asset.ts index 57fb184f..89260d3e 100644 --- a/src/endpoints/asset.ts +++ b/src/endpoints/asset.ts @@ -849,11 +849,14 @@ class Asset extends BaseExtend { mediaId: string ): Promise> { const tokenObject = await this.request.getToken(); + const headers = {}; + + if (tokenObject.token) { + headers['Authorization'] = `Bearer ${tokenObject.token}`; + } return this.request.get(API.getSignedMediaToken(appConfigId, mediaId), { - headers: { - Authorization: `Bearer ${tokenObject.token}` - } + headers }); } @@ -861,14 +864,10 @@ class Asset extends BaseExtend { siteId: string ): Promise> { const tokenObject = await this.request.getToken(); - - const headers: Record = { - Accept: 'application/json', - 'Content-Type': 'application/json' - }; + const headers = {}; if (tokenObject.token) { - headers.Authorization = `Bearer ${tokenObject.token}`; + headers['Authorization'] = `Bearer ${tokenObject.token}`; } return this.request.get(API.getSiteEntitlements(siteId), { headers }); From e55582f3c78fc3459a314de1c6930a44b9567911 Mon Sep 17 00:00:00 2001 From: mirovladimitrovski Date: Thu, 20 Jun 2024 16:38:56 +0200 Subject: [PATCH 2/2] fix an error --- src/endpoints/asset.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/endpoints/asset.ts b/src/endpoints/asset.ts index 89260d3e..5bdb19ef 100644 --- a/src/endpoints/asset.ts +++ b/src/endpoints/asset.ts @@ -15,7 +15,6 @@ import { GetAssetsInPackage, GetItemAccessV1, GetMerchantPackage, - ItemDetailsV1, RequestDataCaptureAccessData, SignedMediaResponse, SiteEntitlementsResponse @@ -849,10 +848,10 @@ class Asset extends BaseExtend { mediaId: string ): Promise> { const tokenObject = await this.request.getToken(); - const headers = {}; + const headers: Record = {}; if (tokenObject.token) { - headers['Authorization'] = `Bearer ${tokenObject.token}`; + headers.Authorization = `Bearer ${tokenObject.token}`; } return this.request.get(API.getSignedMediaToken(appConfigId, mediaId), { @@ -864,10 +863,10 @@ class Asset extends BaseExtend { siteId: string ): Promise> { const tokenObject = await this.request.getToken(); - const headers = {}; + const headers: Record = {}; if (tokenObject.token) { - headers['Authorization'] = `Bearer ${tokenObject.token}`; + headers.Authorization = `Bearer ${tokenObject.token}`; } return this.request.get(API.getSiteEntitlements(siteId), { headers });