@eluvio/elv-client-js 4.0.49 → 4.0.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ElvClient-min.js +11 -10
- package/dist/ElvClient-node-min.js +10 -10
- package/dist/ElvFrameClient-min.js +4 -4
- package/dist/ElvPermissionsClient-min.js +1 -1
- package/dist/ElvWalletClient-min.js +10 -9
- package/dist/ElvWalletClient-node-min.js +10 -10
- package/dist/src/ElvClient.js +441 -306
- package/dist/src/FrameClient.js +2 -2
- package/dist/src/HttpClient.js +10 -1
- package/dist/src/UserProfileClient.js +206 -88
- package/dist/src/Utils.js +10 -0
- package/dist/src/Validation.js +1 -1
- package/dist/src/client/ContentAccess.js +574 -405
- package/dist/src/client/LiveConf.js +330 -0
- package/dist/src/client/LiveStream.js +1785 -0
- package/package.json +1 -1
- package/src/UserProfileClient.js +47 -0
- package/src/client/ContentAccess.js +17 -17
- package/src/client/LiveStream.js +85 -88
package/package.json
CHANGED
package/src/UserProfileClient.js
CHANGED
|
@@ -482,6 +482,53 @@ await client.userProfileClient.UserMetadata()
|
|
|
482
482
|
return this.tenantContractId;
|
|
483
483
|
}
|
|
484
484
|
|
|
485
|
+
/**
|
|
486
|
+
* Set the current user's tenant contract.
|
|
487
|
+
*
|
|
488
|
+
* Note: This method is not accessible to applications. Eluvio core will drop the request.
|
|
489
|
+
*
|
|
490
|
+
* @namedParams
|
|
491
|
+
* @param {string} tenantContractId - The tenant contract ID in hash format
|
|
492
|
+
* @param {string} address - The group address to use in the hash if id is not provided
|
|
493
|
+
*/
|
|
494
|
+
async SetTenantContractId({tenantContractId, address}) {
|
|
495
|
+
if(tenantContractId && (!tenantContractId.startsWith("iten") || !Utils.ValidHash(tenantContractId))) {
|
|
496
|
+
throw Error(`Invalid tenant ID: ${tenantContractId}`);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
if(address) {
|
|
500
|
+
if(!Utils.ValidAddress(address)) {
|
|
501
|
+
throw Error(`Invalid address: ${address}`);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
tenantContractId = `iten${Utils.AddressToHash(address)}`;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
try {
|
|
508
|
+
const version = await this.client.AccessType({id: tenantContractId});
|
|
509
|
+
|
|
510
|
+
if(version !== this.client.authClient.ACCESS_TYPES.TENANT) {
|
|
511
|
+
throw Error("Invalid tenant ID: " + tenantContractId);
|
|
512
|
+
}
|
|
513
|
+
} catch(error) {
|
|
514
|
+
throw Error("Invalid tenant ID: " + tenantContractId);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
const tenantAdminGroupAddress = await this.client.CallContractMethod({
|
|
518
|
+
contractAddress: address || Utils.HashToAddress(tenantContractId),
|
|
519
|
+
methodName: "groupsMapping",
|
|
520
|
+
methodArgs : ["tenant_admin", 0],
|
|
521
|
+
formatArguments: true,
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
await this.MergeUserMetadata({
|
|
525
|
+
metadata: {
|
|
526
|
+
tenantContractId,
|
|
527
|
+
tenantId: !tenantAdminGroupAddress ? undefined : `iten${Utils.AddressToHash(tenantAdminGroupAddress)}`
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
|
|
485
532
|
/**
|
|
486
533
|
* Get the URL of the current user's profile image
|
|
487
534
|
*
|
|
@@ -2140,23 +2140,23 @@ exports.ContentObjectImageUrl = async function({libraryId, objectId, versionHash
|
|
|
2140
2140
|
* @param {string} versionHash - Version hash of the object
|
|
2141
2141
|
* @param {number} duration - Time until the token expires, in milliseconds (1 day = 24 * 60 * 60 * 1000 = 86400000)
|
|
2142
2142
|
* @param {Object} options - Additional video/player options
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2143
|
+
- `autoplay` - If enabled, video will autoplay. Note that videos block autoplay of videos with audio by default
|
|
2144
|
+
- `capLevelToPlayerSize` - Caps video quality to player size
|
|
2145
|
+
- `clipEnd` - End time for the video
|
|
2146
|
+
- `clipStart` - Start time for the video
|
|
2147
|
+
- `controls` - Sets the player control visibility. Values: browserDefault | autoHide | show | hide | hideWithVolume. Defaults to autoHide
|
|
2148
|
+
- `description` - Sets the page description
|
|
2149
|
+
- `directLink` - If enabled, sets direct link
|
|
2150
|
+
- `linkPath` - Video link path
|
|
2151
|
+
- `loop` - If enabled, video will loop
|
|
2152
|
+
- `muted` - Mutes the player
|
|
2153
|
+
- `offerings` - Offerings to play, as an array
|
|
2154
|
+
- `posterUrl` - URL of the player poster image
|
|
2155
|
+
- `protocols` - Video protocols, as an array
|
|
2156
|
+
- `showShare` - Show social media share buttons
|
|
2157
|
+
- `showTitle` - Shows the video title, which is set from the title option (if set) or the metadata
|
|
2158
|
+
- `title` - Sets the page title
|
|
2159
|
+
- `viewRecordKey` - Contains record key
|
|
2160
2160
|
*
|
|
2161
2161
|
* @returns {Promise<string>} - Will return an embed URL
|
|
2162
2162
|
*/
|
package/src/client/LiveStream.js
CHANGED
|
@@ -1122,108 +1122,105 @@ exports.StreamConfig = async function({name}) {
|
|
|
1122
1122
|
let conf = await this.LoadConf({name});
|
|
1123
1123
|
let status = {name};
|
|
1124
1124
|
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
status.object_id = conf.objectId;
|
|
1125
|
+
let libraryId = await this.ContentObjectLibraryId({objectId: conf.objectId});
|
|
1126
|
+
status.library_id = libraryId;
|
|
1127
|
+
status.object_id = conf.objectId;
|
|
1129
1128
|
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1129
|
+
let mainMeta = await this.ContentObjectMetadata({
|
|
1130
|
+
libraryId: libraryId,
|
|
1131
|
+
objectId: conf.objectId
|
|
1132
|
+
});
|
|
1134
1133
|
|
|
1135
|
-
|
|
1136
|
-
|
|
1134
|
+
let userConfig = mainMeta.live_recording_config;
|
|
1135
|
+
status.user_config = userConfig;
|
|
1137
1136
|
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1137
|
+
// Get node URI from user config
|
|
1138
|
+
const hostName = userConfig.url.replace("udp://", "").replace("rtmp://", "").split(":")[0];
|
|
1139
|
+
const streamUrl = new URL(userConfig.url);
|
|
1141
1140
|
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
let probeUrl = await this.Rep({
|
|
1163
|
-
libraryId,
|
|
1164
|
-
objectId: conf.objectId,
|
|
1165
|
-
rep: "probe"
|
|
1166
|
-
});
|
|
1167
|
-
|
|
1168
|
-
probe = await this.utils.ResponseToJson(
|
|
1169
|
-
await HttpClient.Fetch(probeUrl, {
|
|
1170
|
-
body: JSON.stringify({
|
|
1171
|
-
"filename": streamUrl.href,
|
|
1172
|
-
"listen": true
|
|
1173
|
-
}),
|
|
1174
|
-
method: "POST",
|
|
1175
|
-
signal: controller.signal
|
|
1176
|
-
})
|
|
1177
|
-
);
|
|
1141
|
+
console.log("Retrieving nodes...");
|
|
1142
|
+
let nodes = await this.SpaceNodes({matchEndpoint: hostName});
|
|
1143
|
+
if(nodes.length < 1) {
|
|
1144
|
+
status.error = "No node matching stream URL " + streamUrl.href;
|
|
1145
|
+
return status;
|
|
1146
|
+
}
|
|
1147
|
+
const node = nodes[0];
|
|
1148
|
+
status.node = node;
|
|
1149
|
+
|
|
1150
|
+
let endpoint = node.endpoints[0];
|
|
1151
|
+
this.SetNodes({fabricURIs: [endpoint]});
|
|
1152
|
+
|
|
1153
|
+
// Probe the stream
|
|
1154
|
+
let probe = {};
|
|
1155
|
+
const controller = new AbortController();
|
|
1156
|
+
const timeoutId = setTimeout(() => {
|
|
1157
|
+
controller.abort();
|
|
1158
|
+
}, 60 * 1000); // milliseconds
|
|
1159
|
+
try {
|
|
1178
1160
|
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
console.log("Stream probe failed", error);
|
|
1185
|
-
}
|
|
1186
|
-
}
|
|
1161
|
+
let probeUrl = await this.Rep({
|
|
1162
|
+
libraryId,
|
|
1163
|
+
objectId: conf.objectId,
|
|
1164
|
+
rep: "probe"
|
|
1165
|
+
});
|
|
1187
1166
|
|
|
1188
|
-
probe
|
|
1189
|
-
|
|
1167
|
+
probe = await this.utils.ResponseToJson(
|
|
1168
|
+
await HttpClient.Fetch(probeUrl, {
|
|
1169
|
+
body: JSON.stringify({
|
|
1170
|
+
"filename": streamUrl.href,
|
|
1171
|
+
"listen": true
|
|
1172
|
+
}),
|
|
1173
|
+
method: "POST",
|
|
1174
|
+
signal: controller.signal
|
|
1175
|
+
})
|
|
1176
|
+
);
|
|
1190
1177
|
|
|
1191
|
-
|
|
1192
|
-
let lc = new LiveConf(probe, node.id, endpoint, false, false, true);
|
|
1178
|
+
if(probe) { clearTimeout(timeoutId); }
|
|
1193
1179
|
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1180
|
+
if(probe.errors) {
|
|
1181
|
+
throw probe.errors[0];
|
|
1182
|
+
}
|
|
1183
|
+
} catch(error) {
|
|
1184
|
+
if(error.code === "ETIMEDOUT") {
|
|
1185
|
+
throw "Stream probe time out - make sure the stream source is available";
|
|
1186
|
+
} else {
|
|
1187
|
+
throw error;
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1197
1190
|
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
libraryId,
|
|
1201
|
-
objectId: conf.objectId
|
|
1202
|
-
});
|
|
1203
|
-
let writeToken = e.write_token;
|
|
1191
|
+
console.log("PROBE", probe);
|
|
1192
|
+
probe.format.filename = streamUrl.href;
|
|
1204
1193
|
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
objectId: conf.objectId,
|
|
1208
|
-
writeToken,
|
|
1209
|
-
metadataSubtree: "live_recording",
|
|
1210
|
-
metadata: liveRecordingConfig.live_recording
|
|
1211
|
-
});
|
|
1194
|
+
// Create live reocording config
|
|
1195
|
+
let lc = new LiveConf(probe, node.id, endpoint, false, false, true);
|
|
1212
1196
|
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
writeToken,
|
|
1217
|
-
commitMessage: "Apply live stream configuration"
|
|
1218
|
-
});
|
|
1197
|
+
const liveRecordingConfigStr = lc.generateLiveConf();
|
|
1198
|
+
let liveRecordingConfig = JSON.parse(liveRecordingConfigStr);
|
|
1199
|
+
console.log("CONFIG", JSON.stringify(liveRecordingConfig.live_recording));
|
|
1219
1200
|
|
|
1220
|
-
|
|
1201
|
+
// Store live recording config into the stream object
|
|
1202
|
+
let e = await this.EditContentObject({
|
|
1203
|
+
libraryId,
|
|
1204
|
+
objectId: conf.objectId
|
|
1205
|
+
});
|
|
1206
|
+
let writeToken = e.write_token;
|
|
1207
|
+
|
|
1208
|
+
await this.ReplaceMetadata({
|
|
1209
|
+
libraryId,
|
|
1210
|
+
objectId: conf.objectId,
|
|
1211
|
+
writeToken,
|
|
1212
|
+
metadataSubtree: "live_recording",
|
|
1213
|
+
metadata: liveRecordingConfig.live_recording
|
|
1214
|
+
});
|
|
1221
1215
|
|
|
1222
|
-
|
|
1216
|
+
status.fin = await this.FinalizeContentObject({
|
|
1217
|
+
libraryId,
|
|
1218
|
+
objectId: conf.objectId,
|
|
1219
|
+
writeToken,
|
|
1220
|
+
commitMessage: "Apply live stream configuration"
|
|
1221
|
+
});
|
|
1223
1222
|
|
|
1224
|
-
|
|
1225
|
-
console.log("ERROR", e);
|
|
1226
|
-
}
|
|
1223
|
+
return status;
|
|
1227
1224
|
};
|
|
1228
1225
|
|
|
1229
1226
|
// const ChannelStatus = async ({client, name}) => {
|