@eluvio/elv-client-js 3.1.63 → 3.1.67

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.
@@ -51,18 +51,18 @@ exports.MintNFT = function _callee(_ref) {
51
51
  ValidatePresence("email or address", email || address);
52
52
  ValidatePresence("collectionId", collectionId);
53
53
  ValidatePresence("items", items);
54
- ValidateObject(collectionId);
54
+ ValidateObject(collectionId); // If address not specified, make call to initialize address for email
55
55
 
56
- if (address) {
57
- _context.next = 22;
58
- break;
59
- }
60
-
61
- // If address not specified, make call to initialize address for email
62
56
  accountInitializationBody = {
63
- ts: Date.now(),
64
- email: email
57
+ ts: Date.now()
65
58
  };
59
+
60
+ if (email) {
61
+ accountInitializationBody.email = email;
62
+ } else {
63
+ accountInitializationBody.addr = address;
64
+ }
65
+
66
66
  _context.next = 10;
67
67
  return _regeneratorRuntime.awrap(this.Sign(JSON.stringify(accountInitializationBody)));
68
68
 
@@ -90,8 +90,6 @@ exports.MintNFT = function _callee(_ref) {
90
90
  _ref2 = _context.sent;
91
91
  addr = _ref2.addr;
92
92
  address = this.utils.FormatAddress(addr);
93
-
94
- case 22:
95
93
  requestBody = {
96
94
  "tickets": null,
97
95
  "products": items.map(function (item) {
@@ -111,6 +109,8 @@ exports.MintNFT = function _callee(_ref) {
111
109
 
112
110
  if (email) {
113
111
  requestBody.email = email;
112
+ } else {
113
+ requestBody.addr = address;
114
114
  }
115
115
 
116
116
  requestBody.extra.elv_addr = address;
package/package-lock.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-client-js",
3
- "version": "3.1.63",
3
+ "version": "3.1.67",
4
4
  "lockfileVersion": 1,
5
5
  "requires": true,
6
6
  "dependencies": {
@@ -3205,6 +3205,11 @@
3205
3205
  "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=",
3206
3206
  "dev": true
3207
3207
  },
3208
+ "country-codes-list": {
3209
+ "version": "1.6.8",
3210
+ "resolved": "https://registry.npmjs.org/country-codes-list/-/country-codes-list-1.6.8.tgz",
3211
+ "integrity": "sha512-wsqH44Yx3pTyPA77jYt2Nxso6kXziMwxI37fJFQLcd/3ome8Gqz6areaeG1w8zfeU9i+cZvJA3k2Mo5EW7rAtg=="
3212
+ },
3208
3213
  "create-ecdh": {
3209
3214
  "version": "4.0.3",
3210
3215
  "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz",
@@ -7731,9 +7736,9 @@
7731
7736
  }
7732
7737
  },
7733
7738
  "minizlib": {
7734
- "version": "2.1.0",
7735
- "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.0.tgz",
7736
- "integrity": "sha512-EzTZN/fjSvifSX0SlqUERCN39o6T40AMarPbv0MrarSFtIITCBh7bi+dU8nxGFHuqs9jdIAeoYoKuQAAASsPPA==",
7739
+ "version": "2.1.2",
7740
+ "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz",
7741
+ "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==",
7737
7742
  "dev": true,
7738
7743
  "requires": {
7739
7744
  "minipass": "^3.0.0",
@@ -8813,9 +8818,9 @@
8813
8818
  "dev": true
8814
8819
  },
8815
8820
  "path-parse": {
8816
- "version": "1.0.6",
8817
- "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz",
8818
- "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==",
8821
+ "version": "1.0.7",
8822
+ "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
8823
+ "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
8819
8824
  "dev": true
8820
8825
  },
8821
8826
  "path-to-regexp": {
@@ -10635,15 +10640,15 @@
10635
10640
  "dev": true
10636
10641
  },
10637
10642
  "tar": {
10638
- "version": "6.0.2",
10639
- "resolved": "https://registry.npmjs.org/tar/-/tar-6.0.2.tgz",
10640
- "integrity": "sha512-Glo3jkRtPcvpDlAs/0+hozav78yoXKFr+c4wgw62NNMO3oo4AaJdCo21Uu7lcwr55h39W2XD1LMERc64wtbItg==",
10643
+ "version": "6.1.11",
10644
+ "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.11.tgz",
10645
+ "integrity": "sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA==",
10641
10646
  "dev": true,
10642
10647
  "requires": {
10643
10648
  "chownr": "^2.0.0",
10644
10649
  "fs-minipass": "^2.0.0",
10645
10650
  "minipass": "^3.0.0",
10646
- "minizlib": "^2.1.0",
10651
+ "minizlib": "^2.1.1",
10647
10652
  "mkdirp": "^1.0.3",
10648
10653
  "yallist": "^4.0.0"
10649
10654
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-client-js",
3
- "version": "3.1.63",
3
+ "version": "3.1.67",
4
4
  "description": "Javascript client for the Eluvio Content Fabric",
5
5
  "main": "src/ElvClient.js",
6
6
  "author": "Kevin Talmadge",
@@ -45,6 +45,7 @@
45
45
  "/contracts",
46
46
  "/src",
47
47
  "/testScripts",
48
+ "/typeSpecs",
48
49
  "/utilities",
49
50
  "TestConfiguration.json",
50
51
  "LICENSE",
@@ -64,6 +65,7 @@
64
65
  "buffer": "^5.2.1",
65
66
  "cbor": "^4.1.5",
66
67
  "columnify": "^1.5.4",
68
+ "country-codes-list": "^1.6.8",
67
69
  "crocks": "^0.12.4",
68
70
  "deep-equal": "^1.0.1",
69
71
  "ellipsize": "^0.1.0",
@@ -134,6 +134,12 @@ class AuthorizationClient {
134
134
  this.noCache = true;
135
135
  }
136
136
 
137
+ if(this.client.signer && this.client.signer.remoteSigner) {
138
+ // Channel auth not supported for remote signer, use a self-signed no-auth token instead
139
+ noAuth = true;
140
+ channelAuth = false;
141
+ }
142
+
137
143
  let authorizationToken;
138
144
  if(channelAuth) {
139
145
  authorizationToken = await this.GenerateChannelContentToken({
package/src/ElvClient.js CHANGED
@@ -349,6 +349,7 @@ class ElvClient {
349
349
  this.contentTypes = {};
350
350
  this.encryptionConks = {};
351
351
  this.stateChannelAccess = {};
352
+ this.objectTenantIds = {};
352
353
  this.objectLibraryIds = {};
353
354
  this.objectImageUrls = {};
354
355
  this.visibilityInfo = {};
@@ -589,12 +590,14 @@ class ElvClient {
589
590
  * @namedParams
590
591
  * @param {string=} idToken - OAuth ID token
591
592
  * @param {string=} authToken - Eluvio authorization token previously issued from OAuth ID token
593
+ * @param {string=} tenantId - If specified, user will be associated with the tenant
592
594
  */
593
- async SetRemoteSigner({idToken, authToken, address}) {
595
+ async SetRemoteSigner({idToken, authToken, tenantId, address}) {
594
596
  const signer = new RemoteSigner({
595
597
  rpcUris: this.authServiceURIs,
596
598
  idToken,
597
599
  authToken,
600
+ tenantId,
598
601
  address,
599
602
  provider: this.ethClient.provider
600
603
  });
@@ -864,6 +867,13 @@ class ElvClient {
864
867
  this.staticToken = token;
865
868
  }
866
869
 
870
+ /**
871
+ * Clear the set static token for the client
872
+ */
873
+ ClearStaticToken() {
874
+ this.staticToken = undefined;
875
+ }
876
+
867
877
  /**
868
878
  * Authorize the client against the specified policy.
869
879
  *
@@ -288,6 +288,7 @@ class FrameClient {
288
288
  "CallContractMethod",
289
289
  "CallContractMethodAndWait",
290
290
  "ClearCache",
291
+ "ClearStaticToken",
291
292
  "Collection",
292
293
  "ConfigUrl",
293
294
  "ContentLibraries",
@@ -14,6 +14,8 @@ class RemoteSigner extends Ethers.Signer {
14
14
  }) {
15
15
  super();
16
16
 
17
+ this.remoteSigner = true;
18
+
17
19
  this.HttpClient = new HttpClient({uris: rpcUris});
18
20
  this.idToken = idToken;
19
21
  this.tenantId = tenantId;
@@ -616,6 +616,35 @@ exports.ContentObjectOwner = async function({objectId}) {
616
616
  );
617
617
  };
618
618
 
619
+ /**
620
+ * Retrieve the tenant ID associated with the specified content object
621
+ *
622
+ * @methodGroup Content Objects
623
+ *
624
+ * @namedParams
625
+ * @param {string=} objectId - ID of the object
626
+ * @param {string=} versionHash - Version hash of the object
627
+ *
628
+ * @returns {Promise<string>} - Tenant ID of the object
629
+ */
630
+ exports.ContentObjectTenantId = async function({objectId, versionHash}) {
631
+ versionHash ? ValidateVersion(versionHash) : ValidateObject(objectId);
632
+
633
+ if(versionHash) { objectId = this.utils.DecodeVersionHash(versionHash).objectId; }
634
+
635
+ if(!this.objectTenantIds[objectId]) {
636
+ this.objectTenantIds[objectId] = await this.authClient.MakeElvMasterCall({
637
+ methodName: "elv_getTenantById",
638
+ params: [
639
+ this.contentSpaceId,
640
+ objectId
641
+ ]
642
+ });
643
+ }
644
+
645
+ return this.objectTenantIds[objectId];
646
+ };
647
+
619
648
  /**
620
649
  * Retrieve the library ID for the specified content object
621
650
  *
package/src/client/NFT.js CHANGED
@@ -38,31 +38,31 @@ exports.MintNFT = async function({tenantId, email, address, collectionId, items,
38
38
 
39
39
  ValidateObject(collectionId);
40
40
 
41
- if(!address) {
42
- // If address not specified, make call to initialize address for email
43
- const accountInitializationBody = {
44
- ts: Date.now(),
45
- email
46
- };
47
-
48
- const accountInitializationSignature = await this.Sign(
49
- JSON.stringify(accountInitializationBody)
50
- );
51
-
52
- const {addr} = await this.utils.ResponseToJson(
53
- await this.authClient.MakeAuthServiceRequest({
54
- method: "POST",
55
- path: `/as/tnt/prov/eth/${tenantId}`,
56
- body: accountInitializationBody,
57
- headers: {
58
- "Authorization": `Bearer ${accountInitializationSignature}`
59
- }
60
- })
61
- );
62
-
63
- address = this.utils.FormatAddress(addr);
41
+ // If address not specified, make call to initialize address for email
42
+ let accountInitializationBody = { ts: Date.now() };
43
+ if(email) {
44
+ accountInitializationBody.email = email;
45
+ } else {
46
+ accountInitializationBody.addr = address;
64
47
  }
65
48
 
49
+ const accountInitializationSignature = await this.Sign(
50
+ JSON.stringify(accountInitializationBody)
51
+ );
52
+
53
+ const {addr} = await this.utils.ResponseToJson(
54
+ await this.authClient.MakeAuthServiceRequest({
55
+ method: "POST",
56
+ path: `/as/tnt/prov/eth/${tenantId}`,
57
+ body: accountInitializationBody,
58
+ headers: {
59
+ "Authorization": `Bearer ${accountInitializationSignature}`
60
+ }
61
+ })
62
+ );
63
+
64
+ address = this.utils.FormatAddress(addr);
65
+
66
66
  let requestBody = {
67
67
  "tickets": null,
68
68
  "products": items.map(item => ({
@@ -79,10 +79,13 @@ exports.MintNFT = async function({tenantId, email, address, collectionId, items,
79
79
  }
80
80
  };
81
81
 
82
+
82
83
  ValidateAddress(address);
83
84
 
84
85
  if(email) {
85
86
  requestBody.email = email;
87
+ } else {
88
+ requestBody.addr = address;
86
89
  }
87
90
 
88
91
  requestBody.extra.elv_addr = address;
@@ -14,6 +14,15 @@ const reportTypes = [
14
14
  "Views Over Program Duration"
15
15
  ];
16
16
 
17
+ const liveTypes = [
18
+ { name: "Eluvio LIVE Drop Event Site", spec: require("../typeSpecs/DropEventSite") },
19
+ { name: "Eluvio LIVE Event Site", spec: require("../typeSpecs/EventSite") },
20
+ { name: "Eluvio LIVE Marketplace", spec: require("../typeSpecs/Marketplace") },
21
+ { name: "Eluvio LIVE Tenant", spec: require("../typeSpecs/EventTenant") },
22
+ { name: "NFT Collection", spec: require("../typeSpecs/NFTCollection") },
23
+ { name: "NFT Template", spec: require("../typeSpecs/NFTTemplate") }
24
+ ];
25
+
17
26
  const STANDARD_DRM_CERT={
18
27
  elv: {
19
28
  media: {
@@ -63,12 +72,17 @@ const SetLibraryPermissions = async (client, libraryId, tenantAdmins, contentAdm
63
72
  const SetObjectPermissions = async (client, objectId, tenantAdmins, contentAdmins, contentUsers) => {
64
73
  let promises = [
65
74
  // Tenant admins
75
+ client.AddContentObjectGroupPermission({objectId, groupAddress: tenantAdmins, permission: "see"}),
76
+ client.AddContentObjectGroupPermission({objectId, groupAddress: tenantAdmins, permission: "access"}),
66
77
  client.AddContentObjectGroupPermission({objectId, groupAddress: tenantAdmins, permission: "manage"}),
67
78
 
68
79
  // Content admins
80
+ client.AddContentObjectGroupPermission({objectId, groupAddress: contentAdmins, permission: "see"}),
81
+ client.AddContentObjectGroupPermission({objectId, groupAddress: contentAdmins, permission: "access"}),
69
82
  client.AddContentObjectGroupPermission({objectId, groupAddress: contentAdmins, permission: "manage"}),
70
83
 
71
84
  // Content users
85
+ client.AddContentObjectGroupPermission({objectId, groupAddress: contentUsers, permission: "see"}),
72
86
  client.AddContentObjectGroupPermission({objectId, groupAddress: contentUsers, permission: "access"})
73
87
  ];
74
88
 
@@ -241,7 +255,7 @@ const InitializeTenant = async ({configUrl, kmsId, tenantName}) => {
241
255
  "playlists",
242
256
  "gallery",
243
257
  "live_stream"
244
- ],
258
+ ]
245
259
  }
246
260
  }
247
261
  }
@@ -258,6 +272,23 @@ const InitializeTenant = async ({configUrl, kmsId, tenantName}) => {
258
272
  console.log(`\t${tenantName} - Channel: ${channelTypeId}`);
259
273
  console.log(`\t${tenantName} - Live Stream: ${streamTypeId}`);
260
274
 
275
+ for(let i = 0; i < liveTypes.length; i++) {
276
+ const typeId = await client.CreateContentType({
277
+ name: `${tenantName} - ${liveTypes[i].name}`,
278
+ metadata: {
279
+ ...typeMetadata,
280
+ public: {
281
+ ...typeMetadata.public,
282
+ title_configuration: liveTypes[i].spec
283
+ }
284
+ }
285
+ });
286
+
287
+ await SetObjectPermissions(client, typeId, tenantAdminGroupAddress, contentAdminGroupAddress, contentUserGroupAddress);
288
+
289
+ console.log(`\t${tenantName} - ${liveTypes[i].name}: ${typeId}`);
290
+ }
291
+
261
292
 
262
293
  /* Create libraries - Properties, Title Masters, Title Mezzanines and add each to the groups */
263
294
 
@@ -13,6 +13,25 @@ const Test = async () => {
13
13
  });
14
14
 
15
15
  client.SetSigner({signer});
16
+
17
+
18
+ const ethUrl = "https://host-216-66-40-19.contentfabric.io/eth";
19
+ const asUrl = "https://host-66-220-3-86.contentfabric.io";
20
+
21
+ client.SetNodes({
22
+ ethereumURIs: [
23
+ ethUrl
24
+ ],
25
+ authServiceURIs: [
26
+ asUrl
27
+ ]
28
+ });
29
+
30
+ console.log(
31
+ await client.ContentObjectTenantId({
32
+ objectId: "iq__3PXRZX5NCzPQsfTEquCctB2K3KJh"
33
+ })
34
+ )
16
35
  } catch(error) {
17
36
  console.error(error);
18
37
  console.error(JSON.stringify(error, null, 2));
@@ -0,0 +1,80 @@
1
+ const defaultSpec = {
2
+ "profile": {
3
+ name: "Default",
4
+ version: "0.1",
5
+ },
6
+ manageApp: "default",
7
+ controls: [
8
+ "images",
9
+ "playlists"
10
+ ],
11
+ asset_types: [
12
+ "primary",
13
+ "clip"
14
+ ],
15
+ title_types: [
16
+ "collection",
17
+ "episode",
18
+ "season",
19
+ "series",
20
+ "site",
21
+ "title"
22
+ ],
23
+ default_image_keys: [
24
+ "portrait",
25
+ "landscape"
26
+ ],
27
+ info_fields: [
28
+ {name: "release_date", type: "date"},
29
+ {name: "synopsis", type: "textarea"},
30
+ {name: "copyright"},
31
+ {name: "creator"},
32
+ {name: "runtime", type: "integer"},
33
+ ],
34
+ localizations: [],
35
+ associated_assets: [
36
+ {
37
+ name: "titles",
38
+ label: "Titles",
39
+ indexed: true,
40
+ slugged: true,
41
+ defaultable: true,
42
+ orderable: true
43
+ },
44
+ {
45
+ name: "series",
46
+ label: "Series",
47
+ asset_types: ["primary"],
48
+ title_types: ["series"],
49
+ for_title_types: ["site", "collection"],
50
+ indexed: true,
51
+ slugged: true,
52
+ defaultable: false,
53
+ orderable: true
54
+ },
55
+ {
56
+ name: "seasons",
57
+ label: "Seasons",
58
+ asset_types: ["primary"],
59
+ title_types: ["season"],
60
+ for_title_types: ["series"],
61
+ indexed: true,
62
+ slugged: true,
63
+ defaultable: false,
64
+ orderable: true
65
+ },
66
+ {
67
+ name: "episodes",
68
+ label: "Episodes",
69
+ asset_types: ["primary"],
70
+ title_types: ["episode"],
71
+ for_title_types: ["season"],
72
+ indexed: true,
73
+ slugged: true,
74
+ defaultable: false,
75
+ orderable: true
76
+ }
77
+ ]
78
+ };
79
+
80
+ module.exports = defaultSpec;