@eluvio/elv-client-js 4.0.45 → 4.0.46
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/package.json +1 -1
- package/src/FrameClient.js +1 -0
- package/src/client/ContentAccess.js +134 -0
package/package.json
CHANGED
package/src/FrameClient.js
CHANGED
|
@@ -2131,6 +2131,140 @@ exports.ContentObjectImageUrl = async function({libraryId, objectId, versionHash
|
|
|
2131
2131
|
return this.objectImageUrls[versionHash];
|
|
2132
2132
|
};
|
|
2133
2133
|
|
|
2134
|
+
/**
|
|
2135
|
+
* Get an embed URL for the specified object
|
|
2136
|
+
*
|
|
2137
|
+
* @methodGroup URL Generation
|
|
2138
|
+
* @namedParams
|
|
2139
|
+
* @param {string} objectId - ID of the object
|
|
2140
|
+
* @param {string} versionHash - Version hash of the object
|
|
2141
|
+
* @param {number} duration - Time until the token expires, in milliseconds (1 day = 24 * 60 * 60 * 1000 = 86400000)
|
|
2142
|
+
* @param {Object} options - Additional video/player options
|
|
2143
|
+
* autoplay - If enabled, video will autoplay
|
|
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: browserDefaul t | autoHide | show. 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
|
+
*
|
|
2161
|
+
* @returns {Promise<string>} - Will return an embed URL
|
|
2162
|
+
*/
|
|
2163
|
+
exports.EmbedUrl = async function({
|
|
2164
|
+
objectId,
|
|
2165
|
+
versionHash,
|
|
2166
|
+
duration=86400000,
|
|
2167
|
+
options={}
|
|
2168
|
+
}) {
|
|
2169
|
+
if(versionHash) {
|
|
2170
|
+
ValidateVersion(versionHash);
|
|
2171
|
+
} else if(objectId) {
|
|
2172
|
+
ValidateObject(objectId);
|
|
2173
|
+
}
|
|
2174
|
+
|
|
2175
|
+
// Default options
|
|
2176
|
+
options.controls = options.controls === undefined ? "autoHide" : options.controls;
|
|
2177
|
+
|
|
2178
|
+
let embedUrl = new URL("https://embed.v3.contentfabric.io");
|
|
2179
|
+
const networkInfo = await this.NetworkInfo();
|
|
2180
|
+
const networkName = networkInfo.name === "demov3" ? "demo" : (networkInfo.name === "test" && networkInfo.id === 955205) ? "testv4" : networkInfo.name;
|
|
2181
|
+
const permission = await this.Permission({
|
|
2182
|
+
objectId: objectId ? objectId : this.utils.DecodeVersionHash(versionHash).objectId
|
|
2183
|
+
});
|
|
2184
|
+
|
|
2185
|
+
embedUrl.searchParams.set("p", "");
|
|
2186
|
+
embedUrl.searchParams.set("net", networkName);
|
|
2187
|
+
|
|
2188
|
+
if(versionHash) {
|
|
2189
|
+
embedUrl.searchParams.set("vid", versionHash);
|
|
2190
|
+
} else if(objectId) {
|
|
2191
|
+
embedUrl.searchParams.set("oid", objectId);
|
|
2192
|
+
}
|
|
2193
|
+
|
|
2194
|
+
const data = {};
|
|
2195
|
+
for(const option of Object.keys(options)) {
|
|
2196
|
+
switch(option) {
|
|
2197
|
+
case "autoplay":
|
|
2198
|
+
embedUrl.searchParams.set("ap", "");
|
|
2199
|
+
break;
|
|
2200
|
+
case "capLevelToPlayerSize":
|
|
2201
|
+
embedUrl.searchParams.set("cap", "");
|
|
2202
|
+
break;
|
|
2203
|
+
case "clipEnd":
|
|
2204
|
+
embedUrl.searchParams.set("end", options.clipEnd);
|
|
2205
|
+
break;
|
|
2206
|
+
case "clipStart":
|
|
2207
|
+
embedUrl.searchParams.set("start", options.clipStart);
|
|
2208
|
+
break;
|
|
2209
|
+
case "controls":
|
|
2210
|
+
embedUrl.searchParams.set("ct", options.controls);
|
|
2211
|
+
break;
|
|
2212
|
+
case "description":
|
|
2213
|
+
data["og:description"] = options.description;
|
|
2214
|
+
break;
|
|
2215
|
+
case "directLink":
|
|
2216
|
+
embedUrl.searchParams.set("dr", "");
|
|
2217
|
+
break;
|
|
2218
|
+
case "linkPath":
|
|
2219
|
+
embedUrl.searchParams.set("ln", this.utils.B64(options.linkPath));
|
|
2220
|
+
break;
|
|
2221
|
+
case "loop":
|
|
2222
|
+
embedUrl.searchParams.set("lp", "");
|
|
2223
|
+
break;
|
|
2224
|
+
case "muted":
|
|
2225
|
+
embedUrl.searchParams.set("m", "");
|
|
2226
|
+
break;
|
|
2227
|
+
case "offerings":
|
|
2228
|
+
embedUrl.searchParams.set("off", options.offerings.join(","));
|
|
2229
|
+
break;
|
|
2230
|
+
case "posterUrl":
|
|
2231
|
+
embedUrl.searchParams.set("pst", options.posterUrl);
|
|
2232
|
+
break;
|
|
2233
|
+
case "protocols":
|
|
2234
|
+
embedUrl.searchParams.set("ptc", options.protocols.join(","));
|
|
2235
|
+
break;
|
|
2236
|
+
case "showShare":
|
|
2237
|
+
embedUrl.searchParams.set("sh", "");
|
|
2238
|
+
break;
|
|
2239
|
+
case "showTitle":
|
|
2240
|
+
embedUrl.searchParams.set("st", "");
|
|
2241
|
+
break;
|
|
2242
|
+
case "title":
|
|
2243
|
+
data["og:title"] = options.title;
|
|
2244
|
+
break;
|
|
2245
|
+
case "viewRecordKey":
|
|
2246
|
+
embedUrl.searchParams.set("vrk", options.viewRecordKey);
|
|
2247
|
+
break;
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
2250
|
+
|
|
2251
|
+
if(Object.keys(data).length > 0) {
|
|
2252
|
+
embedUrl.searchParams.set("data", this.utils.B64(JSON.stringify({meta_tags: data})));
|
|
2253
|
+
}
|
|
2254
|
+
|
|
2255
|
+
if(["owner", "editable", "viewable"].includes(permission)) {
|
|
2256
|
+
const token = await this.CreateSignedToken({
|
|
2257
|
+
objectId,
|
|
2258
|
+
versionHash,
|
|
2259
|
+
duration
|
|
2260
|
+
});
|
|
2261
|
+
|
|
2262
|
+
embedUrl.searchParams.set("ath", token);
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2265
|
+
return embedUrl.toString();
|
|
2266
|
+
};
|
|
2267
|
+
|
|
2134
2268
|
/* Links */
|
|
2135
2269
|
|
|
2136
2270
|
/**
|