@eluvio/elv-client-js 4.0.9 → 4.0.10

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.
Files changed (40) hide show
  1. package/dist/ElvClient-min.js +11 -10
  2. package/dist/ElvClient-node-min.js +11 -10
  3. package/dist/ElvFrameClient-min.js +11 -10
  4. package/dist/ElvPermissionsClient-min.js +10 -9
  5. package/dist/ElvWalletClient-min.js +10 -9
  6. package/dist/ElvWalletClient-node-min.js +10 -9
  7. package/dist/src/AuthorizationClient.js +1556 -2077
  8. package/dist/src/ContentObjectVerification.js +134 -185
  9. package/dist/src/Crypto.js +224 -319
  10. package/dist/src/ElvClient.js +822 -1114
  11. package/dist/src/ElvWallet.js +64 -106
  12. package/dist/src/EthClient.js +719 -974
  13. package/dist/src/FrameClient.js +222 -318
  14. package/dist/src/HttpClient.js +112 -154
  15. package/dist/src/Id.js +1 -6
  16. package/dist/src/LogMessage.js +4 -8
  17. package/dist/src/PermissionsClient.js +973 -1271
  18. package/dist/src/RemoteSigner.js +161 -232
  19. package/dist/src/UserProfileClient.js +781 -1038
  20. package/dist/src/Utils.js +159 -299
  21. package/dist/src/Validation.js +2 -17
  22. package/dist/src/client/ABRPublishing.js +772 -942
  23. package/dist/src/client/AccessGroups.js +849 -1095
  24. package/dist/src/client/ContentAccess.js +3322 -4195
  25. package/dist/src/client/ContentManagement.js +1817 -2286
  26. package/dist/src/client/Contracts.js +468 -614
  27. package/dist/src/client/Files.js +1505 -1845
  28. package/dist/src/client/NFT.js +94 -116
  29. package/dist/src/client/NTP.js +326 -425
  30. package/dist/src/index.js +2 -5
  31. package/dist/src/walletClient/ClientMethods.js +1368 -1763
  32. package/dist/src/walletClient/Configuration.js +4 -2
  33. package/dist/src/walletClient/Notifications.js +98 -127
  34. package/dist/src/walletClient/Profile.js +184 -246
  35. package/dist/src/walletClient/Utils.js +76 -122
  36. package/dist/src/walletClient/index.js +1171 -1496
  37. package/package.json +1 -1
  38. package/src/client/ContentManagement.js +24 -29
  39. package/testScripts/CreateMezMonolithic.js +779 -0
  40. package/utilities/ListAccessGroups.js +34 -0
@@ -1,31 +1,26 @@
1
1
  var _typeof = require("@babel/runtime/helpers/typeof");
2
-
3
2
  var _regeneratorRuntime = require("@babel/runtime/regenerator");
4
-
5
3
  var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
6
-
7
4
  var Utils = require("../Utils");
8
-
9
5
  var UrlJoin = require("url-join");
10
-
11
6
  var StateStorePath = function StateStorePath(_ref) {
12
7
  var network = _ref.network,
13
- path = _ref.path;
8
+ path = _ref.path;
14
9
  return UrlJoin(network === "main" ? "/main" : "/dv3", path);
15
10
  };
16
-
17
11
  var UserProfilePath = function UserProfilePath(_ref2) {
18
12
  var network = _ref2.network,
19
- appId = _ref2.appId,
20
- userAddress = _ref2.userAddress,
21
- key = _ref2.key,
22
- type = _ref2.type,
23
- mode = _ref2.mode;
13
+ appId = _ref2.appId,
14
+ userAddress = _ref2.userAddress,
15
+ key = _ref2.key,
16
+ type = _ref2.type,
17
+ mode = _ref2.mode;
24
18
  return StateStorePath({
25
19
  network: network,
26
20
  path: UrlJoin(type === "app" ? "app" : "usr", type === "app" ? appId : "", userAddress, mode === "public" ? "pub" : "pri", key || "")
27
21
  });
28
22
  };
23
+
29
24
  /**
30
25
  * Methods related to getting and setting user profile data.
31
26
  *
@@ -45,77 +40,62 @@ var UserProfilePath = function UserProfilePath(_ref2) {
45
40
  *
46
41
  * @returns {Promise<Object|String>} - Returns the specified metadata
47
42
  */
48
-
49
-
50
43
  exports.ProfileMetadata = /*#__PURE__*/function () {
51
44
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref3) {
52
45
  var _ref3$type, type, _ref3$mode, mode, appId, userAddress, key, response;
53
-
54
46
  return _regeneratorRuntime.wrap(function _callee$(_context) {
55
- while (1) {
56
- switch (_context.prev = _context.next) {
57
- case 0:
58
- _ref3$type = _ref3.type, type = _ref3$type === void 0 ? "app" : _ref3$type, _ref3$mode = _ref3.mode, mode = _ref3$mode === void 0 ? "public" : _ref3$mode, appId = _ref3.appId, userAddress = _ref3.userAddress, key = _ref3.key;
59
- _context.prev = 1;
60
- _context.next = 4;
61
- return this.stateStoreClient.Request({
62
- path: UserProfilePath({
63
- network: this.network,
64
- appId: appId || this.appId,
65
- userAddress: userAddress || this.UserAddress(),
66
- type: type,
67
- mode: mode,
68
- key: key
69
- }),
70
- headers: mode === "private" ? {
71
- Authorization: "Bearer ".concat(this.AuthToken())
72
- } : undefined
73
- });
74
-
75
- case 4:
76
- response = _context.sent;
77
-
78
- if (response.ok) {
79
- _context.next = 7;
80
- break;
81
- }
82
-
83
- throw response;
84
-
85
- case 7:
86
- _context.next = 9;
87
- return Utils.ResponseToJson(response);
88
-
89
- case 9:
90
- _context.t0 = key;
91
- return _context.abrupt("return", _context.sent[_context.t0]);
92
-
93
- case 13:
94
- _context.prev = 13;
95
- _context.t1 = _context["catch"](1);
96
-
97
- if (!(_context.t1.status === 404)) {
98
- _context.next = 17;
99
- break;
100
- }
101
-
102
- return _context.abrupt("return", undefined);
103
-
104
- case 17:
105
- throw _context.t1;
106
-
107
- case 18:
108
- case "end":
109
- return _context.stop();
110
- }
47
+ while (1) switch (_context.prev = _context.next) {
48
+ case 0:
49
+ _ref3$type = _ref3.type, type = _ref3$type === void 0 ? "app" : _ref3$type, _ref3$mode = _ref3.mode, mode = _ref3$mode === void 0 ? "public" : _ref3$mode, appId = _ref3.appId, userAddress = _ref3.userAddress, key = _ref3.key;
50
+ _context.prev = 1;
51
+ _context.next = 4;
52
+ return this.stateStoreClient.Request({
53
+ path: UserProfilePath({
54
+ network: this.network,
55
+ appId: appId || this.appId,
56
+ userAddress: userAddress || this.UserAddress(),
57
+ type: type,
58
+ mode: mode,
59
+ key: key
60
+ }),
61
+ headers: mode === "private" ? {
62
+ Authorization: "Bearer ".concat(this.AuthToken())
63
+ } : undefined
64
+ });
65
+ case 4:
66
+ response = _context.sent;
67
+ if (response.ok) {
68
+ _context.next = 7;
69
+ break;
70
+ }
71
+ throw response;
72
+ case 7:
73
+ _context.next = 9;
74
+ return Utils.ResponseToJson(response);
75
+ case 9:
76
+ _context.t0 = key;
77
+ return _context.abrupt("return", _context.sent[_context.t0]);
78
+ case 13:
79
+ _context.prev = 13;
80
+ _context.t1 = _context["catch"](1);
81
+ if (!(_context.t1.status === 404)) {
82
+ _context.next = 17;
83
+ break;
84
+ }
85
+ return _context.abrupt("return", undefined);
86
+ case 17:
87
+ throw _context.t1;
88
+ case 18:
89
+ case "end":
90
+ return _context.stop();
111
91
  }
112
92
  }, _callee, this, [[1, 13]]);
113
93
  }));
114
-
115
94
  return function (_x) {
116
95
  return _ref4.apply(this, arguments);
117
96
  };
118
97
  }();
98
+
119
99
  /**
120
100
  * Set user profile metadata for the current user
121
101
  *
@@ -127,47 +107,41 @@ exports.ProfileMetadata = /*#__PURE__*/function () {
127
107
  * @param {string} key - The metadata key to set
128
108
  * @param {string} value - The metadata value to set
129
109
  */
130
-
131
-
132
110
  exports.SetProfileMetadata = /*#__PURE__*/function () {
133
111
  var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref5) {
134
112
  var _ref5$type, type, _ref5$mode, mode, appId, key, value;
135
-
136
113
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
137
- while (1) {
138
- switch (_context2.prev = _context2.next) {
139
- case 0:
140
- _ref5$type = _ref5.type, type = _ref5$type === void 0 ? "app" : _ref5$type, _ref5$mode = _ref5.mode, mode = _ref5$mode === void 0 ? "public" : _ref5$mode, appId = _ref5.appId, key = _ref5.key, value = _ref5.value;
141
- _context2.next = 3;
142
- return this.stateStoreClient.Request({
143
- method: "POST",
144
- path: UserProfilePath({
145
- network: this.network,
146
- appId: appId || this.appId,
147
- userAddress: this.UserAddress(),
148
- type: type,
149
- mode: mode,
150
- key: key
151
- }),
152
- body: value,
153
- bodyType: _typeof(value) === "object" ? "JSON" : "string",
154
- headers: {
155
- Authorization: "Bearer ".concat(this.AuthToken())
156
- }
157
- });
158
-
159
- case 3:
160
- case "end":
161
- return _context2.stop();
162
- }
114
+ while (1) switch (_context2.prev = _context2.next) {
115
+ case 0:
116
+ _ref5$type = _ref5.type, type = _ref5$type === void 0 ? "app" : _ref5$type, _ref5$mode = _ref5.mode, mode = _ref5$mode === void 0 ? "public" : _ref5$mode, appId = _ref5.appId, key = _ref5.key, value = _ref5.value;
117
+ _context2.next = 3;
118
+ return this.stateStoreClient.Request({
119
+ method: "POST",
120
+ path: UserProfilePath({
121
+ network: this.network,
122
+ appId: appId || this.appId,
123
+ userAddress: this.UserAddress(),
124
+ type: type,
125
+ mode: mode,
126
+ key: key
127
+ }),
128
+ body: value,
129
+ bodyType: _typeof(value) === "object" ? "JSON" : "string",
130
+ headers: {
131
+ Authorization: "Bearer ".concat(this.AuthToken())
132
+ }
133
+ });
134
+ case 3:
135
+ case "end":
136
+ return _context2.stop();
163
137
  }
164
138
  }, _callee2, this);
165
139
  }));
166
-
167
140
  return function (_x2) {
168
141
  return _ref6.apply(this, arguments);
169
142
  };
170
143
  }();
144
+
171
145
  /**
172
146
  * Remove user profile metadata for the current user
173
147
  *
@@ -178,45 +152,39 @@ exports.SetProfileMetadata = /*#__PURE__*/function () {
178
152
  * @param {string=} appId - Namespace to use for the metadata, if retrieving app metadata.. Uses the app ID specified on client initialization by default.
179
153
  * @param {string} key - The metadata key to set
180
154
  */
181
-
182
-
183
155
  exports.RemoveProfileMetadata = /*#__PURE__*/function () {
184
156
  var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref7) {
185
157
  var _ref7$type, type, _ref7$mode, mode, appId, key;
186
-
187
158
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
188
- while (1) {
189
- switch (_context3.prev = _context3.next) {
190
- case 0:
191
- _ref7$type = _ref7.type, type = _ref7$type === void 0 ? "app" : _ref7$type, _ref7$mode = _ref7.mode, mode = _ref7$mode === void 0 ? "public" : _ref7$mode, appId = _ref7.appId, key = _ref7.key;
192
- _context3.next = 3;
193
- return this.stateStoreClient.Request({
194
- method: "DELETE",
195
- path: UserProfilePath({
196
- network: this.network,
197
- appId: appId || this.appId,
198
- userAddress: this.UserAddress(),
199
- type: type,
200
- mode: mode,
201
- key: key
202
- }),
203
- headers: {
204
- Authorization: "Bearer ".concat(this.AuthToken())
205
- }
206
- });
207
-
208
- case 3:
209
- case "end":
210
- return _context3.stop();
211
- }
159
+ while (1) switch (_context3.prev = _context3.next) {
160
+ case 0:
161
+ _ref7$type = _ref7.type, type = _ref7$type === void 0 ? "app" : _ref7$type, _ref7$mode = _ref7.mode, mode = _ref7$mode === void 0 ? "public" : _ref7$mode, appId = _ref7.appId, key = _ref7.key;
162
+ _context3.next = 3;
163
+ return this.stateStoreClient.Request({
164
+ method: "DELETE",
165
+ path: UserProfilePath({
166
+ network: this.network,
167
+ appId: appId || this.appId,
168
+ userAddress: this.UserAddress(),
169
+ type: type,
170
+ mode: mode,
171
+ key: key
172
+ }),
173
+ headers: {
174
+ Authorization: "Bearer ".concat(this.AuthToken())
175
+ }
176
+ });
177
+ case 3:
178
+ case "end":
179
+ return _context3.stop();
212
180
  }
213
181
  }, _callee3, this);
214
182
  }));
215
-
216
183
  return function (_x3) {
217
184
  return _ref8.apply(this, arguments);
218
185
  };
219
186
  }();
187
+
220
188
  /**
221
189
  * Retrieve profile info for the specified user, including address, username and profile image (if set)
222
190
  *
@@ -226,140 +194,110 @@ exports.RemoveProfileMetadata = /*#__PURE__*/function () {
226
194
  *
227
195
  * @returns {Promise<Object>} - Profile info of the specified user
228
196
  */
229
-
230
-
231
197
  exports.Profile = /*#__PURE__*/function () {
232
198
  var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref9) {
233
199
  var userAddress, userName, imageUrl;
234
200
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
235
- while (1) {
236
- switch (_context4.prev = _context4.next) {
237
- case 0:
238
- userAddress = _ref9.userAddress, userName = _ref9.userName;
239
-
240
- if (!userName) {
241
- _context4.next = 5;
242
- break;
243
- }
244
-
245
- _context4.next = 4;
246
- return this.UserNameToAddress({
247
- userName: userName
248
- });
249
-
250
- case 4:
251
- userAddress = _context4.sent;
252
-
253
- case 5:
254
- if (userAddress) {
255
- _context4.next = 7;
256
- break;
257
- }
258
-
259
- throw Error("Eluvio Wallet Client: Unable to determine profile - user address not specified");
260
-
261
- case 7:
262
- if (userName) {
263
- _context4.next = 11;
264
- break;
265
- }
266
-
267
- _context4.next = 10;
268
- return this.ProfileMetadata({
269
- type: "user",
270
- userAddress: userAddress,
271
- key: "username"
272
- });
273
-
274
- case 10:
275
- userName = _context4.sent;
276
-
277
- case 11:
278
- _context4.next = 13;
279
- return this.ProfileMetadata({
280
- type: "user",
281
- userAddress: userAddress,
282
- key: "icon_url"
283
- });
284
-
285
- case 13:
286
- imageUrl = _context4.sent;
287
- return _context4.abrupt("return", {
288
- userAddress: Utils.FormatAddress(userAddress),
289
- userName: userName,
290
- imageUrl: imageUrl
291
- });
292
-
293
- case 15:
294
- case "end":
295
- return _context4.stop();
296
- }
201
+ while (1) switch (_context4.prev = _context4.next) {
202
+ case 0:
203
+ userAddress = _ref9.userAddress, userName = _ref9.userName;
204
+ if (!userName) {
205
+ _context4.next = 5;
206
+ break;
207
+ }
208
+ _context4.next = 4;
209
+ return this.UserNameToAddress({
210
+ userName: userName
211
+ });
212
+ case 4:
213
+ userAddress = _context4.sent;
214
+ case 5:
215
+ if (userAddress) {
216
+ _context4.next = 7;
217
+ break;
218
+ }
219
+ throw Error("Eluvio Wallet Client: Unable to determine profile - user address not specified");
220
+ case 7:
221
+ if (userName) {
222
+ _context4.next = 11;
223
+ break;
224
+ }
225
+ _context4.next = 10;
226
+ return this.ProfileMetadata({
227
+ type: "user",
228
+ userAddress: userAddress,
229
+ key: "username"
230
+ });
231
+ case 10:
232
+ userName = _context4.sent;
233
+ case 11:
234
+ _context4.next = 13;
235
+ return this.ProfileMetadata({
236
+ type: "user",
237
+ userAddress: userAddress,
238
+ key: "icon_url"
239
+ });
240
+ case 13:
241
+ imageUrl = _context4.sent;
242
+ return _context4.abrupt("return", {
243
+ userAddress: Utils.FormatAddress(userAddress),
244
+ userName: userName,
245
+ imageUrl: imageUrl
246
+ });
247
+ case 15:
248
+ case "end":
249
+ return _context4.stop();
297
250
  }
298
251
  }, _callee4, this);
299
252
  }));
300
-
301
253
  return function (_x4) {
302
254
  return _ref10.apply(this, arguments);
303
255
  };
304
256
  }();
305
-
306
257
  exports.UserNameToAddress = /*#__PURE__*/function () {
307
258
  var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref11) {
308
259
  var userName, response;
309
260
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
310
- while (1) {
311
- switch (_context5.prev = _context5.next) {
312
- case 0:
313
- userName = _ref11.userName;
314
- _context5.prev = 1;
315
- _context5.next = 4;
316
- return this.stateStoreClient.Request({
317
- method: "GET",
318
- path: StateStorePath({
319
- network: this.network,
320
- path: UrlJoin("usr", "profile_for_username", userName)
321
- })
322
- });
323
-
324
- case 4:
325
- response = _context5.sent;
326
-
327
- if (response.ok) {
328
- _context5.next = 7;
329
- break;
330
- }
331
-
332
- throw response;
333
-
334
- case 7:
335
- _context5.next = 9;
336
- return Utils.ResponseToJson(response);
337
-
338
- case 9:
339
- return _context5.abrupt("return", _context5.sent.address);
340
-
341
- case 12:
342
- _context5.prev = 12;
343
- _context5.t0 = _context5["catch"](1);
344
-
345
- if (!(_context5.t0.status !== 404)) {
346
- _context5.next = 16;
347
- break;
348
- }
349
-
350
- throw _context5.t0;
351
-
352
- case 16:
353
- return _context5.abrupt("return", undefined);
354
-
355
- case 17:
356
- case "end":
357
- return _context5.stop();
358
- }
261
+ while (1) switch (_context5.prev = _context5.next) {
262
+ case 0:
263
+ userName = _ref11.userName;
264
+ _context5.prev = 1;
265
+ _context5.next = 4;
266
+ return this.stateStoreClient.Request({
267
+ method: "GET",
268
+ path: StateStorePath({
269
+ network: this.network,
270
+ path: UrlJoin("usr", "profile_for_username", userName)
271
+ })
272
+ });
273
+ case 4:
274
+ response = _context5.sent;
275
+ if (response.ok) {
276
+ _context5.next = 7;
277
+ break;
278
+ }
279
+ throw response;
280
+ case 7:
281
+ _context5.next = 9;
282
+ return Utils.ResponseToJson(response);
283
+ case 9:
284
+ return _context5.abrupt("return", _context5.sent.address);
285
+ case 12:
286
+ _context5.prev = 12;
287
+ _context5.t0 = _context5["catch"](1);
288
+ if (!(_context5.t0.status !== 404)) {
289
+ _context5.next = 16;
290
+ break;
291
+ }
292
+ throw _context5.t0;
293
+ case 16:
294
+ return _context5.abrupt("return", undefined);
295
+ case 17:
296
+ case "end":
297
+ return _context5.stop();
359
298
  }
360
299
  }, _callee5, this, [[1, 12]]);
361
300
  }));
362
-
363
301
  return function (_x5) {
364
302
  return _ref12.apply(this, arguments);
365
303
  };