@eluvio/elv-client-js 3.1.75 → 3.1.76

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.
@@ -1094,6 +1094,8 @@ exports.DownloadFile = function _callee12(_ref13) {
1094
1094
  encryption,
1095
1095
  path,
1096
1096
  headers,
1097
+ ownerCapKey,
1098
+ ownerCap,
1097
1099
  bytesTotal,
1098
1100
  _args14 = arguments;
1099
1101
 
@@ -1139,33 +1141,53 @@ exports.DownloadFile = function _callee12(_ref13) {
1139
1141
  headers = _context14.sent;
1140
1142
  headers.Accept = "*/*"; // If not owner, indicate re-encryption
1141
1143
 
1142
- _context14.t0 = encrypted;
1144
+ ownerCapKey = "eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address));
1145
+ _context14.next = 17;
1146
+ return _regeneratorRuntime.awrap(this.ContentObjectMetadata({
1147
+ libraryId: libraryId,
1148
+ objectId: objectId,
1149
+ metadataSubtree: ownerCapKey
1150
+ }));
1143
1151
 
1144
- if (!_context14.t0) {
1145
- _context14.next = 22;
1152
+ case 17:
1153
+ ownerCap = _context14.sent;
1154
+ _context14.t1 = encrypted;
1155
+
1156
+ if (!_context14.t1) {
1157
+ _context14.next = 26;
1146
1158
  break;
1147
1159
  }
1148
1160
 
1149
- _context14.t1 = this.utils;
1150
- _context14.t2 = this.signer.address;
1151
- _context14.next = 20;
1161
+ _context14.t2 = this.utils;
1162
+ _context14.t3 = this.signer.address;
1163
+ _context14.next = 24;
1152
1164
  return _regeneratorRuntime.awrap(this.ContentObjectOwner({
1153
1165
  objectId: objectId
1154
1166
  }));
1155
1167
 
1156
- case 20:
1157
- _context14.t3 = _context14.sent;
1158
- _context14.t0 = !_context14.t1.EqualAddress.call(_context14.t1, _context14.t2, _context14.t3);
1168
+ case 24:
1169
+ _context14.t4 = _context14.sent;
1170
+ _context14.t1 = !_context14.t2.EqualAddress.call(_context14.t2, _context14.t3, _context14.t4);
1171
+
1172
+ case 26:
1173
+ _context14.t0 = _context14.t1;
1159
1174
 
1160
- case 22:
1161
1175
  if (!_context14.t0) {
1162
- _context14.next = 24;
1176
+ _context14.next = 29;
1177
+ break;
1178
+ }
1179
+
1180
+ _context14.t0 = !ownerCap;
1181
+
1182
+ case 29:
1183
+ if (!_context14.t0) {
1184
+ _context14.next = 31;
1163
1185
  break;
1164
1186
  }
1165
1187
 
1166
1188
  headers["X-Content-Fabric-Decryption-Mode"] = "reencrypt";
1167
1189
 
1168
- case 24:
1190
+ case 31:
1169
1191
  // If using server side decryption, specify in header
1170
1192
  if (encrypted && !clientSideDecryption) {
1171
1193
  headers["X-Content-Fabric-Decryption-Mode"] = "decrypt"; // rep/files_download endpoint doesn't currently support Range header
@@ -1176,13 +1198,13 @@ exports.DownloadFile = function _callee12(_ref13) {
1176
1198
  bytesTotal = fileInfo["."].size;
1177
1199
 
1178
1200
  if (!(encrypted && clientSideDecryption)) {
1179
- _context14.next = 46;
1201
+ _context14.next = 53;
1180
1202
  break;
1181
1203
  }
1182
1204
 
1183
- _context14.t4 = _regeneratorRuntime;
1184
- _context14.t5 = this;
1185
- _context14.next = 31;
1205
+ _context14.t5 = _regeneratorRuntime;
1206
+ _context14.t6 = this;
1207
+ _context14.next = 38;
1186
1208
  return _regeneratorRuntime.awrap(this.EncryptionConk({
1187
1209
  libraryId: libraryId,
1188
1210
  objectId: objectId,
@@ -1190,39 +1212,39 @@ exports.DownloadFile = function _callee12(_ref13) {
1190
1212
  download: true
1191
1213
  }));
1192
1214
 
1193
- case 31:
1194
- _context14.t6 = _context14.sent;
1195
- _context14.t7 = path;
1196
- _context14.t8 = bytesTotal;
1197
- _context14.t9 = headers;
1198
- _context14.t10 = callback;
1199
- _context14.t11 = format;
1200
- _context14.t12 = clientSideDecryption;
1201
- _context14.t13 = chunked;
1202
- _context14.t14 = {
1203
- conk: _context14.t6,
1204
- downloadPath: _context14.t7,
1205
- bytesTotal: _context14.t8,
1206
- headers: _context14.t9,
1207
- callback: _context14.t10,
1208
- format: _context14.t11,
1209
- clientSideDecryption: _context14.t12,
1210
- chunked: _context14.t13
1215
+ case 38:
1216
+ _context14.t7 = _context14.sent;
1217
+ _context14.t8 = path;
1218
+ _context14.t9 = bytesTotal;
1219
+ _context14.t10 = headers;
1220
+ _context14.t11 = callback;
1221
+ _context14.t12 = format;
1222
+ _context14.t13 = clientSideDecryption;
1223
+ _context14.t14 = chunked;
1224
+ _context14.t15 = {
1225
+ conk: _context14.t7,
1226
+ downloadPath: _context14.t8,
1227
+ bytesTotal: _context14.t9,
1228
+ headers: _context14.t10,
1229
+ callback: _context14.t11,
1230
+ format: _context14.t12,
1231
+ clientSideDecryption: _context14.t13,
1232
+ chunked: _context14.t14
1211
1233
  };
1212
- _context14.t15 = _context14.t5.DownloadEncrypted.call(_context14.t5, _context14.t14);
1213
- _context14.next = 43;
1214
- return _context14.t4.awrap.call(_context14.t4, _context14.t15);
1234
+ _context14.t16 = _context14.t6.DownloadEncrypted.call(_context14.t6, _context14.t15);
1235
+ _context14.next = 50;
1236
+ return _context14.t5.awrap.call(_context14.t5, _context14.t16);
1215
1237
 
1216
- case 43:
1238
+ case 50:
1217
1239
  return _context14.abrupt("return", _context14.sent);
1218
1240
 
1219
- case 46:
1241
+ case 53:
1220
1242
  if (!chunkSize) {
1221
1243
  chunkSize = 10000000;
1222
1244
  }
1223
1245
 
1224
- _context14.prev = 47;
1225
- _context14.next = 50;
1246
+ _context14.prev = 54;
1247
+ _context14.next = 57;
1226
1248
  return _regeneratorRuntime.awrap(this.Download({
1227
1249
  downloadPath: path,
1228
1250
  bytesTotal: bytesTotal,
@@ -1233,15 +1255,15 @@ exports.DownloadFile = function _callee12(_ref13) {
1233
1255
  chunkSize: chunkSize
1234
1256
  }));
1235
1257
 
1236
- case 50:
1258
+ case 57:
1237
1259
  return _context14.abrupt("return", _context14.sent);
1238
1260
 
1239
- case 53:
1240
- _context14.prev = 53;
1241
- _context14.t16 = _context14["catch"](47);
1261
+ case 60:
1262
+ _context14.prev = 60;
1263
+ _context14.t17 = _context14["catch"](54);
1242
1264
 
1243
1265
  if (!(encrypted && !clientSideDecryption)) {
1244
- _context14.next = 57;
1266
+ _context14.next = 64;
1245
1267
  break;
1246
1268
  }
1247
1269
 
@@ -1249,15 +1271,15 @@ exports.DownloadFile = function _callee12(_ref13) {
1249
1271
  clientSideDecryption: true
1250
1272
  })));
1251
1273
 
1252
- case 57:
1253
- throw _context14.t16;
1274
+ case 64:
1275
+ throw _context14.t17;
1254
1276
 
1255
- case 58:
1277
+ case 65:
1256
1278
  case "end":
1257
1279
  return _context14.stop();
1258
1280
  }
1259
1281
  }
1260
- }, null, this, [[47, 53]]);
1282
+ }, null, this, [[54, 60]]);
1261
1283
  };
1262
1284
  /* Parts */
1263
1285
 
package/package-lock.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-client-js",
3
- "version": "3.1.75",
3
+ "version": "3.1.76",
4
4
  "lockfileVersion": 1,
5
5
  "requires": true,
6
6
  "dependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-client-js",
3
- "version": "3.1.75",
3
+ "version": "3.1.76",
4
4
  "description": "Javascript client for the Eluvio Content Fabric",
5
5
  "main": "src/ElvClient.js",
6
6
  "author": "Kevin Talmadge",
@@ -176,7 +176,10 @@ class AuthorizationClient {
176
176
  let publicKey;
177
177
  if(encryption && encryption !== "none" && objectId && await this.AccessType(objectId) === ACCESS_TYPES.OBJECT) {
178
178
  const owner = await this.Owner({id: objectId});
179
- if(!Utils.EqualAddress(owner, this.client.signer.address)) {
179
+ const ownerCapKey = `eluv.caps.iusr${Utils.AddressToHash(this.client.signer.address)}`;
180
+ const ownerCap = await client.ContentObjectMetadata({libraryId, objectId, metadataSubtree: ownerCapKey});
181
+
182
+ if(!Utils.EqualAddress(owner, this.client.signer.address) && !ownerCap) {
180
183
  const cap = await this.ReEncryptionConk({libraryId, objectId});
181
184
  publicKey = cap.public_key;
182
185
  }
@@ -329,6 +329,7 @@ class FrameClient {
329
329
  "CreateFileUploadJob",
330
330
  "CreateLinks",
331
331
  "CreateNTPInstance",
332
+ "CreateNonOwnerCap",
332
333
  "CreatePart",
333
334
  "CreateProductionMaster",
334
335
  "CreateSignedToken",
@@ -473,9 +473,8 @@ exports.LibraryContentTypes = async function({libraryId}) {
473
473
  * @param {object=} filterOptions - Pagination, sorting and filtering options
474
474
  * @param {number=} filterOptions.start - Start index for pagination
475
475
  * @param {number=} filterOptions.limit - Max number of objects to return
476
- * @param {string=} filterOptions.cacheId - Cache ID corresponding a previous query
477
476
  * @param {(Array<string> | string)=} filterOptions.sort - Sort by the specified key(s)
478
- * @param {boolean=} filterOptions.sortDesc=false - Sort in descending order
477
+ * @param {boolean=} filterOptions.sortDesc - Sort in descending order
479
478
  * @param {(Array<string> | string)=} filterOptions.select - Include only the specified metadata keys (all must start with /public)
480
479
  * @param {(Array<object> | object)=} filterOptions.filter - Filter objects by metadata
481
480
  * @param {string=} filterOptions.filter.key - Key to filter on (must start with /public)
@@ -2408,7 +2407,10 @@ exports.EncryptionConk = async function({libraryId, objectId, versionHash, write
2408
2407
 
2409
2408
  const owner = await this.authClient.Owner({id: objectId});
2410
2409
 
2411
- if(!this.utils.EqualAddress(owner, this.signer.address)) {
2410
+ const ownerCapKey = `eluv.caps.iusr${this.utils.AddressToHash(this.signer.address)}`;
2411
+ const ownerCap = await this.ContentObjectMetadata({libraryId, objectId, metadataSubtree: ownerCapKey});
2412
+
2413
+ if(!this.utils.EqualAddress(owner, this.signer.address) && !ownerCap) {
2412
2414
  if(download) {
2413
2415
  return await this.authClient.ReEncryptionConk({libraryId, objectId, versionHash});
2414
2416
  } else {
@@ -21,7 +21,8 @@ const {
21
21
  ValidateVersion,
22
22
  ValidateWriteToken,
23
23
  ValidateParameters,
24
- ValidatePresence
24
+ ValidatePresence,
25
+ ValidateAddress
25
26
  } = require("../Validation");
26
27
 
27
28
  exports.SetVisibility = async function({id, visibility}) {
@@ -671,6 +672,56 @@ exports.CopyContentObject = async function({libraryId, originalVersionHash, opti
671
672
  return await this.FinalizeContentObject({libraryId, objectId, writeToken});
672
673
  };
673
674
 
675
+ /**
676
+ * Create a non-owner cap key using the specified public key and address
677
+ *
678
+ * @methodGroup Access Requests
679
+ * @namedParams
680
+ * @param {string} libraryId - ID of the library
681
+ * @param {string} objectId - ID of the object
682
+ * @param {string} publicKey - Public key for the target cap
683
+ * @param {string} publicAddress - Public address for the target cap key
684
+ * @param {string} writeToken - Write token for the content object - If specified, info will be retrieved from the write draft instead of creating a new draft and finalizing
685
+ *
686
+ * @returns {Promise<Object>}
687
+ */
688
+ exports.CreateNonOwnerCap = async function({objectId, libraryId, publicKey, publicAddress, writeToken}) {
689
+ publicAddress = ValidateAddress(publicAddress);
690
+ const userCapKey = `eluv.caps.iusr${this.utils.AddressToHash(this.signer.address)}`;
691
+ const userCapValue = await this.ContentObjectMetadata({objectId, libraryId, metadataSubtree: userCapKey});
692
+
693
+ if(!userCapValue) {
694
+ throw Error("No user cap found for current user");
695
+ }
696
+
697
+ const userConk = await this.Crypto.DecryptCap(userCapValue, this.signer.signingKey.privateKey);
698
+
699
+ const targetUserCapKey = `eluv.caps.iusr${this.utils.AddressToHash(publicAddress)}`;
700
+ const targetUserCapValue = await this.Crypto.EncryptConk(userConk, publicKey);
701
+
702
+ const finalize = !writeToken;
703
+ if(!writeToken) {
704
+ writeToken = await this.EditContentObject({libraryId, objectId}).writeToken;
705
+ }
706
+
707
+ this.ReplaceMetadata({
708
+ libraryId,
709
+ objectId,
710
+ writeToken,
711
+ metadataSubtree: targetUserCapKey,
712
+ metadata: targetUserCapValue
713
+ });
714
+
715
+ if(finalize) {
716
+ await this.FinalizeContentObject({
717
+ libraryId,
718
+ objectId,
719
+ writeToken,
720
+ commitMessage: "Create non-owner cap"
721
+ });
722
+ }
723
+ };
724
+
674
725
  /**
675
726
  * Create a new content object draft from an existing object.
676
727
  *
@@ -641,7 +641,10 @@ exports.DownloadFile = async function({
641
641
  headers.Accept = "*/*";
642
642
 
643
643
  // If not owner, indicate re-encryption
644
- if(encrypted && !this.utils.EqualAddress(this.signer.address, await this.ContentObjectOwner({objectId}))) {
644
+ const ownerCapKey = `eluv.caps.iusr${this.utils.AddressToHash(this.signer.address)}`;
645
+ const ownerCap = await this.ContentObjectMetadata({libraryId, objectId, metadataSubtree: ownerCapKey});
646
+
647
+ if(encrypted && !this.utils.EqualAddress(this.signer.address, await this.ContentObjectOwner({objectId})) && !ownerCap) {
645
648
  headers["X-Content-Fabric-Decryption-Mode"] = "reencrypt";
646
649
  }
647
650
 
Binary file
@@ -22,7 +22,22 @@ const eventSiteSpec = {
22
22
  localization: {
23
23
  localizations: Object.keys(languageOptions)
24
24
  },
25
- associated_assets: [],
25
+ associated_assets: [
26
+ {
27
+ name: "promos",
28
+ label: "Promos (Apple TV)",
29
+ indexed: true,
30
+ slugged: true,
31
+ defaultable: true,
32
+ orderable: true
33
+ },
34
+ {
35
+ name: "channels",
36
+ label: "Channels (Apple TV)",
37
+ indexed: true,
38
+ defaultable: true
39
+ },
40
+ ],
26
41
  info_fields: [
27
42
  {
28
43
  "label": "Basic Info",
@@ -59,6 +74,11 @@ const eventSiteSpec = {
59
74
  "default_value": "Inaccessible",
60
75
  "hint": "Specify the current state of the event. Inaccessible and ended events will not be visible to users."
61
76
  },
77
+ {
78
+ "label": "Accessible (Apple TV)",
79
+ "name": "accessible",
80
+ "type": "checkbox"
81
+ },
62
82
  {
63
83
  "name": "theme",
64
84
  "type": "select",
@@ -1002,6 +1022,11 @@ const eventSiteSpec = {
1002
1022
  "name": "header_drops",
1003
1023
  "type": "header"
1004
1024
  },
1025
+ {
1026
+ "name": "hide_upcoming_events",
1027
+ "type": "checkbox",
1028
+ "default_value": false
1029
+ },
1005
1030
  {
1006
1031
  "name": "marketplace_drops",
1007
1032
  "type": "list",