Add PhenixEdgeAuthService and PhenixChannelService for channel token creation and subscription; format countries_mapping.json for consistency.

This commit is contained in:
2025-10-30 04:54:36 -04:00
parent 5a86c5e578
commit c8fb389f1f
3 changed files with 46 additions and 2 deletions

View 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();
}
}

View 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
});
}
}

View File

@@ -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"
}