@eluvio/elv-client-js 4.0.5 → 4.0.6
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/dist/ElvClient-min.js +12 -11
- package/dist/ElvClient-node-min.js +12 -17
- package/dist/ElvFrameClient-min.js +12 -11
- package/dist/ElvPermissionsClient-min.js +10 -9
- package/dist/ElvWalletClient-min.js +11 -10
- package/dist/ElvWalletClient-node-min.js +12 -17
- package/dist/src/AuthorizationClient.js +1556 -2077
- package/dist/src/ContentObjectVerification.js +134 -185
- package/dist/src/Crypto.js +225 -322
- package/dist/src/ElvClient.js +823 -1117
- package/dist/src/ElvWallet.js +64 -106
- package/dist/src/EthClient.js +719 -974
- package/dist/src/FrameClient.js +222 -318
- package/dist/src/HttpClient.js +112 -154
- package/dist/src/Id.js +1 -6
- package/dist/src/LogMessage.js +4 -8
- package/dist/src/PermissionsClient.js +973 -1271
- package/dist/src/RemoteSigner.js +161 -232
- package/dist/src/UserProfileClient.js +781 -1038
- package/dist/src/Utils.js +160 -302
- package/dist/src/Validation.js +2 -17
- package/dist/src/client/ABRPublishing.js +772 -942
- package/dist/src/client/AccessGroups.js +849 -1095
- package/dist/src/client/ContentAccess.js +3263 -4132
- package/dist/src/client/ContentManagement.js +1811 -2283
- package/dist/src/client/Contracts.js +468 -614
- package/dist/src/client/Files.js +1505 -1845
- package/dist/src/client/NFT.js +94 -116
- package/dist/src/client/NTP.js +326 -425
- package/dist/src/index.js +2 -5
- package/dist/src/walletClient/ClientMethods.js +1348 -1735
- package/dist/src/walletClient/Configuration.js +4 -2
- package/dist/src/walletClient/Notifications.js +98 -127
- package/dist/src/walletClient/Profile.js +184 -246
- package/dist/src/walletClient/Utils.js +76 -122
- package/dist/src/walletClient/index.js +1168 -1493
- package/package.json +2 -2
- package/src/Crypto.js +1 -1
- package/src/ElvClient.js +1 -3
- package/src/Utils.js +1 -1
- package/testScripts/Test.js +0 -1
- package/utilities/NFTIngest.js +527 -0
- package/utilities/lib/concerns/LocalFile.js +2 -1
|
@@ -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
|
-
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
_context.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
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
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
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
|
};
|