Add PhenixEdgeAuthService and PhenixChannelService for channel token creation and subscription; format countries_mapping.json for consistency.
This commit is contained in:
18
src/services/EdgeAuth.service.ts
Normal file
18
src/services/EdgeAuth.service.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
// @ts-ignore - phenix-edge-auth doesn't have TypeScript definitions
|
||||||
|
import TokenBuilder from 'phenix-edge-auth';
|
||||||
|
|
||||||
|
export default class PhenixEdgeAuthService {
|
||||||
|
private constructor() {
|
||||||
|
throw new Error('PhenixEdgeAuthService is a static class that may not be instantiated');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static createChannelToken({id, secret, channelId}: {id: string; secret: string; channelId: string}): string {
|
||||||
|
return new TokenBuilder()
|
||||||
|
.expiresIn(3600)
|
||||||
|
.withUri('https://pcast-stg.phenixrts.com')
|
||||||
|
.withApplicationId(id)
|
||||||
|
.withSecret(secret)
|
||||||
|
.forChannel(channelId)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
24
src/services/PhenixChannel.service.ts
Normal file
24
src/services/PhenixChannel.service.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import {Channels} from '@phenixrts/sdk';
|
||||||
|
import type PhenixChannel from '@phenixrts/sdk/types/sdk/channels/Channel';
|
||||||
|
import {ApplicationCredentials, Channel} from '@techniker-me/pcast-api';
|
||||||
|
import PhenixEdgeAuthService from './EdgeAuth.service';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export default class PhenixChannelService {
|
||||||
|
private constructor() {
|
||||||
|
throw new Error('PhenixChannelService is a static class that may not be instantiated');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static subscribeToChannel({id, secret}: ApplicationCredentials, channel: Channel, videoElement: HTMLVideoElement): PhenixChannel {
|
||||||
|
const token = PhenixEdgeAuthService.createChannelToken({id, secret, channelId: channel.channelId});
|
||||||
|
|
||||||
|
console.log('token', token);
|
||||||
|
console.log('channel', channel);
|
||||||
|
|
||||||
|
return Channels.createChannel({
|
||||||
|
token,
|
||||||
|
videoElement
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
{"AF": "Afghanistan",
|
{
|
||||||
|
"AF": "Afghanistan",
|
||||||
"AO": "Angola",
|
"AO": "Angola",
|
||||||
"AL": "Albania",
|
"AL": "Albania",
|
||||||
"AE": "United Arab Emirates",
|
"AE": "United Arab Emirates",
|
||||||
@@ -174,4 +175,5 @@
|
|||||||
"YE": "Yemen",
|
"YE": "Yemen",
|
||||||
"ZA": "South Africa",
|
"ZA": "South Africa",
|
||||||
"ZM": "Zambia",
|
"ZM": "Zambia",
|
||||||
"ZW": "Zimbabwe"}
|
"ZW": "Zimbabwe"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user