Skip to content

Commit 4ffc5b8

Browse files
Merge branch 'v3' into add-profile-endpoints
2 parents 78919e3 + 2d7d839 commit 4ffc5b8

File tree

8 files changed

+124
-39
lines changed

8 files changed

+124
-39
lines changed

CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
# [3.13.7] - 10-03-2023
6+
7+
### Changes
8+
9+
- Fixed undefined values for `getSignedMediaToken` method
10+
11+
# [3.13.6] - 10-03-2023
12+
13+
### Added
14+
15+
- Axios version upgraded to newest
16+
- New `Assets` method `getSignedMediaToken`
17+
518
# [3.13.5] - 02-02-2023
619

720
### Added

index.d.ts

+8
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,9 @@ export interface RequestDataCaptureAccessData {
494494
company: string;
495495
merchant_uuid: string;
496496
}
497+
export interface SignedMediaResponse {
498+
token: string;
499+
}
497500

498501
export declare class Asset {
499502
constructor(config: Record<string, unknown>, Account: Account);
@@ -537,6 +540,10 @@ export declare class Asset {
537540
requestDataCaptureNoAuthAccess(
538541
accessData: RequestDataCaptureAccessData
539542
): Promise<AxiosResponse<CommonResponse>>;
543+
getSignedMediaToken(
544+
appConfigId: string,
545+
mediaId: string
546+
): Promise<AxiosResponse<SignedMediaResponse>>;
540547
}
541548

542549
export interface BrandingDetails {
@@ -1102,6 +1109,7 @@ export interface ApiEndpoints {
11021109
getFreemiumAsset: string;
11031110
getCloudfrontURL: (assetId: number, videoUrl: string) => string;
11041111
requestCodeAccess: string;
1112+
getSignedMediaToken: (appConfigId: string, mediaId: string) => string;
11051113
releaseAccessCode: (code: number) => string;
11061114
requestDataCaptureNoAuthAccess: string;
11071115
// Payment

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@inplayer-org/inplayer.js",
3-
"version": "3.13.5",
3+
"version": "3.13.7",
44
"author": "InPlayer",
55
"license": "MIT",
66
"description": "A Javascript SDK for Inplayer's RESTful API",
@@ -44,7 +44,7 @@
4444
],
4545
"dependencies": {
4646
"aws-iot-device-sdk": "^2.2.6",
47-
"axios": "^0.19.2",
47+
"axios": "^0.21.2",
4848
"core-js": "^3.8.2",
4949
"fingerprintjs2": "^2.1.2",
5050
"lodash": "^4.17.20",

src/constants/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ export const API = {
6868
`items/access/codes/${codeId}/${fingerprint}`,
6969
// donation
7070
getDonations: (id: number): string => `v2/items/${id}/donations`,
71+
// media signer
72+
getSignedMediaToken: (appConfigId: string, mediaId: string): string =>
73+
`v2/items/jw-media/token?app_config_id=${appConfigId}&media_id=${mediaId}`,
7174

7275
// Payments
7376
getPaymentMethods: '/payments/methods',

src/endpoints/asset.ts

+59-9
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
GetMerchantPackage,
1818
ItemDetailsV1,
1919
RequestDataCaptureAccessData,
20+
SignedMediaResponse,
2021
} from '../models/IAsset&Access';
2122
import BaseExtend from '../extends/base';
2223
import { API } from '../constants';
@@ -59,7 +60,9 @@ class Asset extends BaseExtend {
5960
* }
6061
* ```
6162
*/
62-
async checkAccessForAsset(id: number): Promise<AxiosResponse<GetItemAccessV1>> {
63+
async checkAccessForAsset(
64+
id: number,
65+
): Promise<AxiosResponse<GetItemAccessV1>> {
6366
const tokenObject = await this.request.getToken();
6467

6568
return this.request.authenticatedGet(API.checkAccessForAsset(id), {
@@ -128,7 +131,10 @@ class Asset extends BaseExtend {
128131
* }
129132
* ```
130133
*/
131-
async getAsset(assetId: number, merchantUuid: string): Promise<AxiosResponse<ItemDetailsV1>> {
134+
async getAsset(
135+
assetId: number,
136+
merchantUuid: string,
137+
): Promise<AxiosResponse<ItemDetailsV1>> {
132138
return this.request.get(API.getAsset(assetId, merchantUuid));
133139
}
134140

@@ -332,7 +338,9 @@ class Asset extends BaseExtend {
332338
* }
333339
* ```
334340
*/
335-
async getAssetsInPackage(id: number): Promise<AxiosResponse<GetAssetsInPackage>> {
341+
async getAssetsInPackage(
342+
id: number,
343+
): Promise<AxiosResponse<GetAssetsInPackage>> {
336344
return this.request.get(API.getAssetsInPackage(id));
337345
}
338346

@@ -622,7 +630,9 @@ class Asset extends BaseExtend {
622630
* }
623631
* ```
624632
*/
625-
getAccessCode(assetId: number): CodeAccessData | null | Promise<CodeAccessData | null> {
633+
getAccessCode(
634+
assetId: number,
635+
): CodeAccessData | null | Promise<CodeAccessData | null> {
626636
const accessCode = tokenStorage.getItem(
627637
this.config.INPLAYER_ACCESS_CODE_NAME(assetId),
628638
);
@@ -632,7 +642,9 @@ class Asset extends BaseExtend {
632642
(resolvedString ? (JSON.parse(resolvedString) as CodeAccessData) : null)) as Promise<CodeAccessData | null>;
633643
}
634644

635-
return accessCode ? (JSON.parse(accessCode as string) as CodeAccessData) : null;
645+
return accessCode
646+
? (JSON.parse(accessCode as string) as CodeAccessData)
647+
: null;
636648
}
637649

638650
/**
@@ -655,7 +667,9 @@ class Asset extends BaseExtend {
655667
* }]
656668
* ```
657669
*/
658-
async getAccesCodeSessions(codeId: number): Promise<AxiosResponse<Array<CodeAccessSessionsData>>> {
670+
async getAccesCodeSessions(
671+
codeId: number,
672+
): Promise<AxiosResponse<Array<CodeAccessSessionsData>>> {
659673
return this.request.get(API.requestAccessCodeSessions(codeId));
660674
}
661675

@@ -676,7 +690,9 @@ class Asset extends BaseExtend {
676690
* }
677691
* ```
678692
*/
679-
async terminateSession(assetId: number): Promise<AxiosResponse<CommonResponse> | null> {
693+
async terminateSession(
694+
assetId: number,
695+
): Promise<AxiosResponse<CommonResponse> | null> {
680696
const accessCode: CodeAccessData | null = await this.getAccessCode(assetId);
681697

682698
if (!accessCode) {
@@ -756,7 +772,10 @@ class Asset extends BaseExtend {
756772
* }
757773
* ```
758774
*/
759-
async getCloudfrontURL(assetId: number, videoUrl: string): Promise<AxiosResponse<CloudfrontUrl>> {
775+
async getCloudfrontURL(
776+
assetId: number,
777+
videoUrl: string,
778+
): Promise<AxiosResponse<CloudfrontUrl>> {
760779
const tokenObject = await this.request.getToken();
761780

762781
return this.request.get(API.getCloudfrontURL(assetId, videoUrl), {
@@ -793,7 +812,9 @@ class Asset extends BaseExtend {
793812
* }
794813
* ```
795814
*/
796-
async getDonationOptions(assetId: number): Promise<AxiosResponse<DonationDetails>> {
815+
async getDonationOptions(
816+
assetId: number,
817+
): Promise<AxiosResponse<DonationDetails>> {
797818
const tokenObject = await this.request.getToken();
798819

799820
return this.request.get(API.getDonations(assetId), {
@@ -802,6 +823,35 @@ class Asset extends BaseExtend {
802823
},
803824
});
804825
}
826+
827+
/**
828+
* Retrieves a signed token for media protection
829+
* @method getSignedMediaToken
830+
* @async
831+
* @param {number} appConfigId The id of the config used on the OTT Web App
832+
* @param {number} mediaId The id of the requested media to watch on the OTT Web App
833+
* @example
834+
* InPlayer.Asset
835+
* .getSignedMediaToken('slgaIsfX', 'kAscZclP)
836+
* .then(data => console.log(data));
837+
* @returns {AxiosResponse<SignedMediaResponse>} Contains the data:
838+
* ```typescript
839+
* {
840+
* token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpX...
841+
* }
842+
*/
843+
async getSignedMediaToken(
844+
appConfigId: string,
845+
mediaId: string,
846+
): Promise<AxiosResponse<SignedMediaResponse>> {
847+
const tokenObject = await this.request.getToken();
848+
849+
return this.request.get(API.getSignedMediaToken(appConfigId, mediaId), {
850+
headers: {
851+
Authorization: `Bearer ${tokenObject.token}`,
852+
},
853+
});
854+
}
805855
}
806856

807857
export default Asset;

src/models/Config.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export interface ApiEndpoints {
4343
getAssetAccessFees: (id: number) => string;
4444
getCloudfrontURL: (assetId: number, videoUrl: string) => string;
4545
getPurchaseHistory: (status: string, page?: number, size?: number) => string;
46+
getSignedMediaToken: (appConfigId: string, mediaId: string) => string;
4647
// code only
4748
requestCodeAccess: string;
4849
requestAccessCodeSessions: (codeId: number) => string;
@@ -60,21 +61,24 @@ export interface ApiEndpoints {
6061
createDirectDebitMandate: string;
6162
payForAssetDonation: string;
6263
confirmForAssetDonation: string;
63-
validateReceipt: (platform: string) => string,
64+
validateReceipt: (platform: string) => string;
6465
getAssetsHistory: (
6566
size: number,
6667
page: number,
6768
startDate?: string,
6869
endDate?: string,
69-
type?: string,
70+
type?: string
7071
) => string;
7172
// Subscriptions
7273
getSubscriptions: (limit: number, page: number) => string;
7374
getSubscription: (id: string) => string;
7475
cancelSubscription: (url: string) => string;
7576
subscribe: string;
7677
subscribeV2: string;
77-
changeSubscriptionPlan: (access_fee_id: number, inplayer_token: string) => string;
78+
changeSubscriptionPlan: (
79+
access_fee_id: number,
80+
inplayer_token: string
81+
) => string;
7882
// Voucher
7983
getDiscount: string;
8084
// Restrictions
@@ -89,7 +93,7 @@ export interface Request {
8993
setToken(
9094
token: string,
9195
refreshToken: string,
92-
expiresAt: number,
96+
expiresAt: number
9397
): void | Promise<void>;
9498
removeToken(): void | Promise<void>;
9599
get(

src/models/IAsset&Access.ts

+22-6
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ export interface Gift {
315315
export interface TransactionsDetails {
316316
access_fee_description: string;
317317
action_type: string;
318-
charged_amount: number
318+
charged_amount: number;
319319
client_id: string;
320320
consumer_email: string;
321321
consumer_id: number;
@@ -357,6 +357,10 @@ export interface AssetsTransactions {
357357
unique_paying_customers: number;
358358
}
359359

360+
export interface SignedMediaResponse {
361+
token: string;
362+
}
363+
360364
export interface Asset extends BaseExtend {
361365
checkAccessForAsset(id: number): Promise<AxiosResponse<GetItemAccessV1>>;
362366
isFreeTrialUsed(id: number): Promise<AxiosResponse<boolean>>;
@@ -377,15 +381,27 @@ export interface Asset extends BaseExtend {
377381
page?: number,
378382
startDate?: string,
379383
endDate?: string,
380-
type?: string,
384+
type?: string
381385
): Promise<AxiosResponse<AssetsTransactions>>;
382-
getAccessCode(assetId: number): CodeAccessData | null | Promise<CodeAccessData | null>;
383-
requestCodeAccess(data: RequestCodeAccessData): Promise<AxiosResponse<CodeAccessData>>;
384-
getAccesCodeSessions(codeId: number): Promise<AxiosResponse<Array<CodeAccessSessionsData>>>;
385-
terminateSession(assetId: number): Promise<AxiosResponse<CommonResponse> | null>;
386+
getAccessCode(
387+
assetId: number
388+
): CodeAccessData | null | Promise<CodeAccessData | null>;
389+
requestCodeAccess(
390+
data: RequestCodeAccessData
391+
): Promise<AxiosResponse<CodeAccessData>>;
392+
getAccesCodeSessions(
393+
codeId: number
394+
): Promise<AxiosResponse<Array<CodeAccessSessionsData>>>;
395+
terminateSession(
396+
assetId: number
397+
): Promise<AxiosResponse<CommonResponse> | null>;
386398
getCloudfrontURL(
387399
assetId: number,
388400
videoUrl: string
389401
): Promise<AxiosResponse<CloudfrontUrl>>;
390402
getDonationOptions(assetId: number): Promise<AxiosResponse<DonationDetails>>;
403+
getSignedMediaToken(
404+
appConfigId: string,
405+
mediaId: string
406+
): Promise<AxiosResponse<SignedMediaResponse>>;
391407
}

yarn.lock

+9-18
Original file line numberDiff line numberDiff line change
@@ -1515,12 +1515,12 @@ aws-iot-device-sdk@^2.2.6:
15151515
mqtt "2.18.8"
15161516
websocket-stream "^5.0.1"
15171517

1518-
axios@^0.19.2:
1519-
version "0.19.2"
1520-
resolved "https://registry.yarnpkg.com/axios/-/axios-0.19.2.tgz#3ea36c5d8818d0d5f8a8a97a6d36b86cdc00cb27"
1521-
integrity sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==
1518+
axios@^0.21.2:
1519+
version "0.21.2"
1520+
resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.2.tgz#21297d5084b2aeeb422f5d38e7be4fbb82239017"
1521+
integrity sha512-87otirqUw3e8CzHTMO+/9kh/FSgXt/eVDvipijwDtEuwbkySWZ9SBm6VEubmJ/kLKEoLQV/POhxXFb66bfekfg==
15221522
dependencies:
1523-
follow-redirects "1.5.10"
1523+
follow-redirects "^1.14.0"
15241524

15251525
babel-code-frame@^6.26.0:
15261526
version "6.26.0"
@@ -2370,13 +2370,6 @@ d@1, d@^1.0.1:
23702370
es5-ext "^0.10.50"
23712371
type "^1.0.1"
23722372

2373-
debug@=3.1.0:
2374-
version "3.1.0"
2375-
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
2376-
integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==
2377-
dependencies:
2378-
ms "2.0.0"
2379-
23802373
debug@^2.2.0, debug@^2.3.3, debug@^2.6.8, debug@^2.6.9:
23812374
version "2.6.9"
23822375
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
@@ -3165,12 +3158,10 @@ flush-write-stream@^1.0.0:
31653158
inherits "^2.0.3"
31663159
readable-stream "^2.3.6"
31673160

3168-
3169-
version "1.5.10"
3170-
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.10.tgz#7b7a9f9aea2fdff36786a94ff643ed07f4ff5e2a"
3171-
integrity sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==
3172-
dependencies:
3173-
debug "=3.1.0"
3161+
follow-redirects@^1.14.0:
3162+
version "1.15.2"
3163+
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13"
3164+
integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==
31743165

31753166
for-in@^1.0.2:
31763167
version "1.0.2"

0 commit comments

Comments
 (0)