@eluvio/elv-client-js 4.0.10 → 4.0.11

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 +10 -11
  2. package/dist/ElvClient-node-min.js +10 -11
  3. package/dist/ElvFrameClient-min.js +10 -11
  4. package/dist/ElvPermissionsClient-min.js +9 -10
  5. package/dist/ElvWalletClient-min.js +9 -10
  6. package/dist/ElvWalletClient-node-min.js +9 -10
  7. package/dist/src/AuthorizationClient.js +2070 -1550
  8. package/dist/src/ContentObjectVerification.js +185 -134
  9. package/dist/src/Crypto.js +319 -224
  10. package/dist/src/ElvClient.js +1114 -822
  11. package/dist/src/ElvWallet.js +106 -64
  12. package/dist/src/EthClient.js +974 -719
  13. package/dist/src/FrameClient.js +318 -222
  14. package/dist/src/HttpClient.js +154 -112
  15. package/dist/src/Id.js +6 -1
  16. package/dist/src/LogMessage.js +8 -4
  17. package/dist/src/PermissionsClient.js +1271 -973
  18. package/dist/src/RemoteSigner.js +232 -161
  19. package/dist/src/UserProfileClient.js +1038 -781
  20. package/dist/src/Utils.js +299 -159
  21. package/dist/src/Validation.js +17 -2
  22. package/dist/src/client/ABRPublishing.js +942 -772
  23. package/dist/src/client/AccessGroups.js +1095 -849
  24. package/dist/src/client/ContentAccess.js +4196 -3323
  25. package/dist/src/client/ContentManagement.js +2288 -1814
  26. package/dist/src/client/Contracts.js +614 -468
  27. package/dist/src/client/Files.js +1831 -1490
  28. package/dist/src/client/NFT.js +116 -94
  29. package/dist/src/client/NTP.js +425 -326
  30. package/dist/src/index.js +5 -2
  31. package/dist/src/walletClient/ClientMethods.js +1763 -1368
  32. package/dist/src/walletClient/Configuration.js +2 -4
  33. package/dist/src/walletClient/Notifications.js +127 -98
  34. package/dist/src/walletClient/Profile.js +246 -184
  35. package/dist/src/walletClient/Utils.js +122 -76
  36. package/dist/src/walletClient/index.js +1496 -1171
  37. package/package.json +1 -1
  38. package/src/AuthorizationClient.js +5 -5
  39. package/src/client/Files.js +1 -1
  40. package/testScripts/CreateMezMonolithic.js +0 -779
@@ -1,26 +1,31 @@
1
1
  var _typeof = require("@babel/runtime/helpers/typeof");
2
+
2
3
  var _regeneratorRuntime = require("@babel/runtime/regenerator");
4
+
3
5
  var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
6
+
4
7
  var Utils = require("../Utils");
8
+
5
9
  var UrlJoin = require("url-join");
10
+
6
11
  var StateStorePath = function StateStorePath(_ref) {
7
12
  var network = _ref.network,
8
- path = _ref.path;
13
+ path = _ref.path;
9
14
  return UrlJoin(network === "main" ? "/main" : "/dv3", path);
10
15
  };
16
+
11
17
  var UserProfilePath = function UserProfilePath(_ref2) {
12
18
  var network = _ref2.network,
13
- appId = _ref2.appId,
14
- userAddress = _ref2.userAddress,
15
- key = _ref2.key,
16
- type = _ref2.type,
17
- mode = _ref2.mode;
19
+ appId = _ref2.appId,
20
+ userAddress = _ref2.userAddress,
21
+ key = _ref2.key,
22
+ type = _ref2.type,
23
+ mode = _ref2.mode;
18
24
  return StateStorePath({
19
25
  network: network,
20
26
  path: UrlJoin(type === "app" ? "app" : "usr", type === "app" ? appId : "", userAddress, mode === "public" ? "pub" : "pri", key || "")
21
27
  });
22
28
  };
23
-
24
29
  /**
25
30
  * Methods related to getting and setting user profile data.
26
31
  *
@@ -40,62 +45,77 @@ var UserProfilePath = function UserProfilePath(_ref2) {
40
45
  *
41
46
  * @returns {Promise<Object|String>} - Returns the specified metadata
42
47
  */
48
+
49
+
43
50
  exports.ProfileMetadata = /*#__PURE__*/function () {
44
51
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref3) {
45
52
  var _ref3$type, type, _ref3$mode, mode, appId, userAddress, key, response;
53
+
46
54
  return _regeneratorRuntime.wrap(function _callee$(_context) {
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();
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
+ }
91
111
  }
92
112
  }, _callee, this, [[1, 13]]);
93
113
  }));
114
+
94
115
  return function (_x) {
95
116
  return _ref4.apply(this, arguments);
96
117
  };
97
118
  }();
98
-
99
119
  /**
100
120
  * Set user profile metadata for the current user
101
121
  *
@@ -107,41 +127,47 @@ exports.ProfileMetadata = /*#__PURE__*/function () {
107
127
  * @param {string} key - The metadata key to set
108
128
  * @param {string} value - The metadata value to set
109
129
  */
130
+
131
+
110
132
  exports.SetProfileMetadata = /*#__PURE__*/function () {
111
133
  var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref5) {
112
134
  var _ref5$type, type, _ref5$mode, mode, appId, key, value;
135
+
113
136
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
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();
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
+ }
137
163
  }
138
164
  }, _callee2, this);
139
165
  }));
166
+
140
167
  return function (_x2) {
141
168
  return _ref6.apply(this, arguments);
142
169
  };
143
170
  }();
144
-
145
171
  /**
146
172
  * Remove user profile metadata for the current user
147
173
  *
@@ -152,39 +178,45 @@ exports.SetProfileMetadata = /*#__PURE__*/function () {
152
178
  * @param {string=} appId - Namespace to use for the metadata, if retrieving app metadata.. Uses the app ID specified on client initialization by default.
153
179
  * @param {string} key - The metadata key to set
154
180
  */
181
+
182
+
155
183
  exports.RemoveProfileMetadata = /*#__PURE__*/function () {
156
184
  var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref7) {
157
185
  var _ref7$type, type, _ref7$mode, mode, appId, key;
186
+
158
187
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
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();
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
+ }
180
212
  }
181
213
  }, _callee3, this);
182
214
  }));
215
+
183
216
  return function (_x3) {
184
217
  return _ref8.apply(this, arguments);
185
218
  };
186
219
  }();
187
-
188
220
  /**
189
221
  * Retrieve profile info for the specified user, including address, username and profile image (if set)
190
222
  *
@@ -194,110 +226,140 @@ exports.RemoveProfileMetadata = /*#__PURE__*/function () {
194
226
  *
195
227
  * @returns {Promise<Object>} - Profile info of the specified user
196
228
  */
229
+
230
+
197
231
  exports.Profile = /*#__PURE__*/function () {
198
232
  var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref9) {
199
233
  var userAddress, userName, imageUrl;
200
234
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
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();
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
+ }
250
297
  }
251
298
  }, _callee4, this);
252
299
  }));
300
+
253
301
  return function (_x4) {
254
302
  return _ref10.apply(this, arguments);
255
303
  };
256
304
  }();
305
+
257
306
  exports.UserNameToAddress = /*#__PURE__*/function () {
258
307
  var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref11) {
259
308
  var userName, response;
260
309
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
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();
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
+ }
298
359
  }
299
360
  }, _callee5, this, [[1, 12]]);
300
361
  }));
362
+
301
363
  return function (_x5) {
302
364
  return _ref12.apply(this, arguments);
303
365
  };