@eluvio/elv-client-js 4.0.7 → 4.0.9
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 +10 -11
- package/dist/ElvClient-node-min.js +10 -11
- package/dist/ElvFrameClient-min.js +10 -11
- package/dist/ElvPermissionsClient-min.js +9 -10
- package/dist/ElvWalletClient-min.js +10 -11
- package/dist/ElvWalletClient-node-min.js +9 -10
- package/dist/src/AuthorizationClient.js +2069 -1548
- package/dist/src/ContentObjectVerification.js +185 -134
- package/dist/src/Crypto.js +323 -226
- package/dist/src/ElvClient.js +1118 -824
- package/dist/src/ElvWallet.js +106 -64
- package/dist/src/EthClient.js +974 -719
- package/dist/src/FrameClient.js +318 -222
- package/dist/src/HttpClient.js +154 -112
- package/dist/src/Id.js +6 -1
- package/dist/src/LogMessage.js +8 -4
- package/dist/src/PermissionsClient.js +1271 -973
- package/dist/src/RemoteSigner.js +232 -161
- package/dist/src/UserProfileClient.js +1038 -781
- package/dist/src/Utils.js +302 -160
- package/dist/src/Validation.js +17 -2
- package/dist/src/client/ABRPublishing.js +942 -772
- package/dist/src/client/AccessGroups.js +1095 -849
- package/dist/src/client/ContentAccess.js +4198 -3272
- package/dist/src/client/ContentManagement.js +2284 -1812
- package/dist/src/client/Contracts.js +614 -468
- package/dist/src/client/Files.js +1831 -1491
- package/dist/src/client/NFT.js +116 -94
- package/dist/src/client/NTP.js +425 -326
- package/dist/src/index.js +5 -2
- package/dist/src/walletClient/ClientMethods.js +1766 -1350
- package/dist/src/walletClient/Configuration.js +2 -4
- package/dist/src/walletClient/Notifications.js +127 -98
- package/dist/src/walletClient/Profile.js +246 -184
- package/dist/src/walletClient/Utils.js +124 -78
- package/dist/src/walletClient/index.js +1498 -1169
- package/package.json +1 -1
- package/src/Crypto.js +2 -2
- package/src/ElvClient.js +2 -2
- package/src/Utils.js +1 -1
- package/src/client/ContentAccess.js +27 -10
- package/src/client/Files.js +1 -1
- package/src/walletClient/ClientMethods.js +18 -10
- package/src/walletClient/Utils.js +2 -2
- package/src/walletClient/index.js +7 -2
|
@@ -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
|
-
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
_context.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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)
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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)
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
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)
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
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
|
};
|