@eluvio/elv-client-js 4.0.50 → 4.0.52

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-client-js",
3
- "version": "4.0.50",
3
+ "version": "4.0.52",
4
4
  "description": "Javascript client for the Eluvio Content Fabric",
5
5
  "main": "src/index.js",
6
6
  "author": "Kevin Talmadge",
@@ -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
  *
@@ -2131,6 +2131,17 @@ exports.ContentObjectImageUrl = async function({libraryId, objectId, versionHash
2131
2131
  return this.objectImageUrls[versionHash];
2132
2132
  };
2133
2133
 
2134
+ const EmbedMediaTypes = {
2135
+ "video": "v",
2136
+ "live_video": "lv",
2137
+ "audio": "a",
2138
+ "image": "i",
2139
+ "html": "h",
2140
+ "ebook": "b",
2141
+ "gallery": "g",
2142
+ "link": "l"
2143
+ };
2144
+
2134
2145
  /**
2135
2146
  * Get an embed URL for the specified object
2136
2147
  *
@@ -2139,24 +2150,32 @@ exports.ContentObjectImageUrl = async function({libraryId, objectId, versionHash
2139
2150
  * @param {string} objectId - ID of the object
2140
2151
  * @param {string} versionHash - Version hash of the object
2141
2152
  * @param {number} duration - Time until the token expires, in milliseconds (1 day = 24 * 60 * 60 * 1000 = 86400000)
2153
+ * @param {string=} mediaType=video - The type of the media. Available options:
2154
+ - `video`
2155
+ - `live_video`
2156
+ - `audio`
2157
+ - `image`
2158
+ - `gallery`
2159
+ - `ebook`
2160
+ - `html`
2142
2161
  * @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: 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
2162
+ - `autoplay` - If enabled, video will autoplay. Note that videos block autoplay of videos with audio by default
2163
+ - `capLevelToPlayerSize` - Caps video quality to player size
2164
+ - `clipEnd` - End time for the video
2165
+ - `clipStart` - Start time for the video
2166
+ - `controls` - Sets the player control visibility. Values: browserDefault | autoHide | show | hide | hideWithVolume. Defaults to autoHide
2167
+ - `description` - Sets the page description
2168
+ - `directLink` - If enabled, sets direct link
2169
+ - `linkPath` - Video link path
2170
+ - `loop` - If enabled, video will loop
2171
+ - `muted` - Mutes the player
2172
+ - `offerings` - Offerings to play, as an array
2173
+ - `posterUrl` - URL of the player poster image
2174
+ - `protocols` - Video protocols, as an array
2175
+ - `showShare` - Show social media share buttons
2176
+ - `showTitle` - Shows the video title, which is set from the title option (if set) or the metadata
2177
+ - `title` - Sets the page title
2178
+ - `viewRecordKey` - Contains record key
2160
2179
  *
2161
2180
  * @returns {Promise<string>} - Will return an embed URL
2162
2181
  */
@@ -2164,6 +2183,7 @@ exports.EmbedUrl = async function({
2164
2183
  objectId,
2165
2184
  versionHash,
2166
2185
  duration=86400000,
2186
+ mediaType="video",
2167
2187
  options={}
2168
2188
  }) {
2169
2189
  if(versionHash) {
@@ -2198,6 +2218,8 @@ exports.EmbedUrl = async function({
2198
2218
  embedUrl.searchParams.set("oid", objectId);
2199
2219
  }
2200
2220
 
2221
+ embedUrl.searchParams.set("mt", EmbedMediaTypes[mediaType.toLowerCase()] || "v");
2222
+
2201
2223
  const data = {};
2202
2224
  for(const option of Object.keys(options)) {
2203
2225
  switch(option) {