@eluvio/elv-client-js 4.0.111 → 4.0.113
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/package.json +1 -1
- package/src/FrameClient.js +2 -0
- package/dist/ElvClient-min.js +0 -67
- package/dist/ElvClient-node-min.js +0 -66
- package/dist/ElvFrameClient-min.js +0 -60
- package/dist/ElvPermissionsClient-min.js +0 -60
- package/dist/ElvWalletClient-min.js +0 -67
- package/dist/ElvWalletClient-node-min.js +0 -66
- package/dist/src/AuthorizationClient.js +0 -2157
- package/dist/src/ContentObjectAudit.js +0 -175
- package/dist/src/ContentObjectVerification.js +0 -281
- package/dist/src/Crypto.js +0 -412
- package/dist/src/ElvClient.js +0 -2049
- package/dist/src/ElvWallet.js +0 -245
- package/dist/src/EthClient.js +0 -1154
- package/dist/src/FrameClient.js +0 -485
- package/dist/src/HttpClient.js +0 -315
- package/dist/src/Id.js +0 -21
- package/dist/src/LogMessage.js +0 -25
- package/dist/src/PermissionsClient.js +0 -1544
- package/dist/src/RemoteSigner.js +0 -385
- package/dist/src/UserProfileClient.js +0 -1450
- package/dist/src/Utils.js +0 -894
- package/dist/src/Validation.js +0 -121
- package/dist/src/abr_profiles/abr_profile_live_drm.js +0 -1661
- package/dist/src/abr_profiles/abr_profile_live_to_vod.js +0 -1606
- package/dist/src/client/ABRPublishing.js +0 -1018
- package/dist/src/client/AccessGroups.js +0 -1503
- package/dist/src/client/ContentAccess.js +0 -5173
- package/dist/src/client/ContentManagement.js +0 -2680
- package/dist/src/client/Contracts.js +0 -1520
- package/dist/src/client/Files.js +0 -2181
- package/dist/src/client/LiveConf.js +0 -567
- package/dist/src/client/LiveStream.js +0 -2638
- package/dist/src/client/NFT.js +0 -162
- package/dist/src/client/NTP.js +0 -581
- package/dist/src/contracts/v2/AccessIndexor.js +0 -831
- package/dist/src/contracts/v2/Accessible.js +0 -31
- package/dist/src/contracts/v2/BaseAccessControlGroup.js +0 -1263
- package/dist/src/contracts/v2/BaseAccessWallet.js +0 -1609
- package/dist/src/contracts/v2/BaseAccessWalletFactory.js +0 -93
- package/dist/src/contracts/v2/BaseContent.js +0 -1076
- package/dist/src/contracts/v2/BaseContentFactory.js +0 -219
- package/dist/src/contracts/v2/BaseContentSpace.js +0 -1352
- package/dist/src/contracts/v2/BaseContentType.js +0 -364
- package/dist/src/contracts/v2/BaseFactory.js +0 -107
- package/dist/src/contracts/v2/BaseGroupFactory.js +0 -93
- package/dist/src/contracts/v2/BaseLibrary.js +0 -1041
- package/dist/src/contracts/v2/BaseLibraryFactory.js +0 -96
- package/dist/src/contracts/v2/Certifyer.js +0 -86
- package/dist/src/contracts/v2/Container.js +0 -540
- package/dist/src/contracts/v2/Content.js +0 -443
- package/dist/src/contracts/v2/Editable.js +0 -306
- package/dist/src/contracts/v2/ExternalUserWallet.js +0 -379
- package/dist/src/contracts/v2/IFactorySpace.js +0 -57
- package/dist/src/contracts/v2/IKmsSpace.js +0 -52
- package/dist/src/contracts/v2/INodeSpace.js +0 -18
- package/dist/src/contracts/v2/IUserSpace.js +0 -18
- package/dist/src/contracts/v2/LvRecordableStream.js +0 -1037
- package/dist/src/contracts/v2/LvRecording.js +0 -627
- package/dist/src/contracts/v2/LvStreamRightsHolder.js +0 -562
- package/dist/src/contracts/v2/MetaObject.js +0 -119
- package/dist/src/contracts/v2/Node.js +0 -167
- package/dist/src/contracts/v2/NodeSpace.js +0 -273
- package/dist/src/contracts/v2/Ownable.js +0 -87
- package/dist/src/contracts/v2/PaymentService.js +0 -627
- package/dist/src/contracts/v2/Precompile.js +0 -15
- package/dist/src/contracts/v2/Transactable.js +0 -82
- package/dist/src/contracts/v2/UserSpace.js +0 -29
- package/dist/src/contracts/v2/Utils.js +0 -18
- package/dist/src/contracts/v2/Verifier.js +0 -53
- package/dist/src/contracts/v2/strings.js +0 -4
- package/dist/src/contracts/v3/AccessIndexor.js +0 -774
- package/dist/src/contracts/v3/Accessible.js +0 -232
- package/dist/src/contracts/v3/Adminable.js +0 -107
- package/dist/src/contracts/v3/AvailsDelivery.js +0 -586
- package/dist/src/contracts/v3/BaseAccessControlGroup.js +0 -1603
- package/dist/src/contracts/v3/BaseAccessWallet.js +0 -1628
- package/dist/src/contracts/v3/BaseAccessWalletFactory.js +0 -112
- package/dist/src/contracts/v3/BaseContent.js +0 -1312
- package/dist/src/contracts/v3/BaseContentFactory.js +0 -183
- package/dist/src/contracts/v3/BaseContentFactoryExt.js +0 -175
- package/dist/src/contracts/v3/BaseContentSpace.js +0 -1515
- package/dist/src/contracts/v3/BaseContentType.js +0 -527
- package/dist/src/contracts/v3/BaseFactory.js +0 -126
- package/dist/src/contracts/v3/BaseGroupFactory.js +0 -112
- package/dist/src/contracts/v3/BaseLibrary.js +0 -1204
- package/dist/src/contracts/v3/BaseLibraryFactory.js +0 -115
- package/dist/src/contracts/v3/BaseTenantSpace.js +0 -1587
- package/dist/src/contracts/v3/Certifyer.js +0 -86
- package/dist/src/contracts/v3/Container.js +0 -739
- package/dist/src/contracts/v3/Content.js +0 -438
- package/dist/src/contracts/v3/CounterObject.js +0 -243
- package/dist/src/contracts/v3/Editable.js +0 -519
- package/dist/src/contracts/v3/EncToken.js +0 -4
- package/dist/src/contracts/v3/ExternalUserWallet.js +0 -587
- package/dist/src/contracts/v3/IAdmin.js +0 -18
- package/dist/src/contracts/v3/IFactorySpace.js +0 -57
- package/dist/src/contracts/v3/IKmsSpace.js +0 -52
- package/dist/src/contracts/v3/INodeSpace.js +0 -18
- package/dist/src/contracts/v3/IUserSpace.js +0 -32
- package/dist/src/contracts/v3/LvRecordableStream.js +0 -1032
- package/dist/src/contracts/v3/LvRecording.js +0 -650
- package/dist/src/contracts/v3/LvStreamRightsHolder.js +0 -557
- package/dist/src/contracts/v3/MetaObject.js +0 -144
- package/dist/src/contracts/v3/Node.js +0 -178
- package/dist/src/contracts/v3/NodeSpace.js +0 -284
- package/dist/src/contracts/v3/Ownable.js +0 -98
- package/dist/src/contracts/v3/PaymentService.js +0 -622
- package/dist/src/contracts/v3/Precompile.js +0 -26
- package/dist/src/contracts/v3/TenantFuncsBase.js +0 -351
- package/dist/src/contracts/v3/Transactable.js +0 -82
- package/dist/src/contracts/v3/UserSpace.js +0 -43
- package/dist/src/contracts/v3/Utils.js +0 -18
- package/dist/src/contracts/v3/Verifier.js +0 -53
- package/dist/src/contracts/v3/strings.js +0 -4
- package/dist/src/contracts/v3b/BaseAccessControlGroup.js +0 -1704
- package/dist/src/events/Topics.js +0 -1793
- package/dist/src/index.js +0 -8
- package/dist/src/walletClient/ClientMethods.js +0 -3102
- package/dist/src/walletClient/Configuration.js +0 -38
- package/dist/src/walletClient/Notifications.js +0 -168
- package/dist/src/walletClient/Profile.js +0 -332
- package/dist/src/walletClient/Utils.js +0 -281
- package/dist/src/walletClient/index.js +0 -2106
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
var WalletConfiguration = {
|
|
2
|
-
demo: {
|
|
3
|
-
configUrl: "https://demov3.net955210.contentfabric.io/config",
|
|
4
|
-
stateStoreUrls: ["https://appsvc.svc.eluv.io/dv3"],
|
|
5
|
-
badgerAddress: "0x39e9d567137217e8f7dae73bf168db28d242bb31",
|
|
6
|
-
staging: {
|
|
7
|
-
siteLibraryId: "ilib36Wi5fJDLXix8ckL7ZfaAJwJXWGD",
|
|
8
|
-
siteId: "iq__2gkNh8CCZqFFnoRpEUmz7P3PaBQG",
|
|
9
|
-
purchaseMode: "develop",
|
|
10
|
-
appUrl: "https://wallet.demov3.contentfabric.io"
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
main: {
|
|
14
|
-
configUrl: "https://main.net955305.contentfabric.io/config",
|
|
15
|
-
stateStoreUrls: ["https://appsvc.svc.eluv.io/main"],
|
|
16
|
-
badgerAddress: "0xa042a585bbbac4419ba39c397f35ab749fc470f0",
|
|
17
|
-
staging: {
|
|
18
|
-
siteLibraryId: "ilib2GdaYEFxB7HyLPhSDPKMyPLhV8x9",
|
|
19
|
-
siteId: "iq__inauxD1KLyKWPHargCWjdCh2ayr",
|
|
20
|
-
purchaseMode: "production",
|
|
21
|
-
appUrl: "https://wallet.preview.contentfabric.io"
|
|
22
|
-
},
|
|
23
|
-
production: {
|
|
24
|
-
siteLibraryId: "ilib2GdaYEFxB7HyLPhSDPKMyPLhV8x9",
|
|
25
|
-
siteId: "iq__suqRJUt2vmXsyiWS5ZaSGwtFU9R",
|
|
26
|
-
purchaseMode: "production",
|
|
27
|
-
appUrl: "https://wallet.contentfabric.io"
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
__MARKETPLACE_ORDER: ["PREVIEW", "b63413a5-ce07-4848-b763-b4d97f4870ec", "masked-singer-brazil-marketplace", "eluvio-live-marketplace-globo-taf", "de228e92-ed45-4fe0-8e52-658cf366e962", "wwe-marketplace-main", "maskverse-marketplace", "dolly-marketplace", "eluvio-live-marketplace-sonark", "cirkay-marketplace", "eluvio-live-marketplace-fuudge", "oc-marketplace", "emp-marketplace", "microsoft", "indieflix-marketplace", "angels-airwaves-marketplace", "realcannonballrun-marketplace"]
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
// No production environment on demo
|
|
34
|
-
WalletConfiguration.demo.production = WalletConfiguration.demo.staging;
|
|
35
|
-
|
|
36
|
-
// Allow demo to be referred to as demov3
|
|
37
|
-
WalletConfiguration.demov3 = WalletConfiguration.demo;
|
|
38
|
-
module.exports = WalletConfiguration;
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
var _regeneratorRuntime = require("@babel/runtime/regenerator");
|
|
2
|
-
var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
|
|
3
|
-
/**
|
|
4
|
-
* Methods related to notifications for the current user.
|
|
5
|
-
*
|
|
6
|
-
* @module Notifications
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
var Utils = require("../Utils");
|
|
10
|
-
var UrlJoin = require("url-join");
|
|
11
|
-
var NotificationPath = function NotificationPath(_ref) {
|
|
12
|
-
var network = _ref.network,
|
|
13
|
-
path = _ref.path;
|
|
14
|
-
return UrlJoin("/push", network === "main" ? "/main" : "/dv3", path);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Push a notification to a user
|
|
19
|
-
*
|
|
20
|
-
* @methodGroup Notifications
|
|
21
|
-
* @param {string} tenantId - The tenant associated with this notification
|
|
22
|
-
* @param {string} eventType - The type of the notification
|
|
23
|
-
* @param {(Object | string)=} data - Data associated with this notification
|
|
24
|
-
* @param {string=} userAddress - Address of the user to notify. If not specified, it will be sent to the current user.
|
|
25
|
-
*/
|
|
26
|
-
exports.PushNotification = /*#__PURE__*/function () {
|
|
27
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref2) {
|
|
28
|
-
var tenantId, eventType, data, userAddress;
|
|
29
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
30
|
-
while (1) switch (_context.prev = _context.next) {
|
|
31
|
-
case 0:
|
|
32
|
-
tenantId = _ref2.tenantId, eventType = _ref2.eventType, data = _ref2.data, userAddress = _ref2.userAddress;
|
|
33
|
-
_context.next = 3;
|
|
34
|
-
return this.stateStoreClient.Request({
|
|
35
|
-
method: "POST",
|
|
36
|
-
path: NotificationPath({
|
|
37
|
-
network: this.network,
|
|
38
|
-
path: UrlJoin("notify_user", userAddress || this.UserAddress(), tenantId, eventType)
|
|
39
|
-
}),
|
|
40
|
-
body: data,
|
|
41
|
-
headers: {
|
|
42
|
-
Authorization: "Bearer ".concat(this.AuthToken())
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
case 3:
|
|
46
|
-
case "end":
|
|
47
|
-
return _context.stop();
|
|
48
|
-
}
|
|
49
|
-
}, _callee, this);
|
|
50
|
-
}));
|
|
51
|
-
return function (_x) {
|
|
52
|
-
return _ref3.apply(this, arguments);
|
|
53
|
-
};
|
|
54
|
-
}();
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Add a listener to receive new notifications.
|
|
58
|
-
*
|
|
59
|
-
* @methodGroup Notifications
|
|
60
|
-
* @param {function} onMessage - Callback invoked when a new notification is received
|
|
61
|
-
*
|
|
62
|
-
* @returns {Promise<EventSource>} - An EventSource instance listening for notifications. Use source.close() to close the listener.
|
|
63
|
-
*/
|
|
64
|
-
exports.AddNotificationListener = /*#__PURE__*/function () {
|
|
65
|
-
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref4) {
|
|
66
|
-
var onMessage, url, source;
|
|
67
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
68
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
69
|
-
case 0:
|
|
70
|
-
onMessage = _ref4.onMessage;
|
|
71
|
-
if (onMessage) {
|
|
72
|
-
_context2.next = 3;
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
throw Error("Eluvio Wallet Client: No onMessage callback provided to AddNotificationListener");
|
|
76
|
-
case 3:
|
|
77
|
-
url = new URL(this.stateStoreClient.BaseURI().toString());
|
|
78
|
-
url.pathname = NotificationPath({
|
|
79
|
-
network: this.network,
|
|
80
|
-
path: UrlJoin("register", this.UserAddress(), this.AuthToken())
|
|
81
|
-
});
|
|
82
|
-
source = new EventSource(url);
|
|
83
|
-
source.onmessage = function (event) {
|
|
84
|
-
var parsedMessage = JSON.parse(event.data);
|
|
85
|
-
try {
|
|
86
|
-
parsedMessage.data = JSON.parse(parsedMessage.data);
|
|
87
|
-
// eslint-disable-next-line no-empty
|
|
88
|
-
} catch (error) {}
|
|
89
|
-
onMessage(parsedMessage);
|
|
90
|
-
};
|
|
91
|
-
return _context2.abrupt("return", source);
|
|
92
|
-
case 8:
|
|
93
|
-
case "end":
|
|
94
|
-
return _context2.stop();
|
|
95
|
-
}
|
|
96
|
-
}, _callee2, this);
|
|
97
|
-
}));
|
|
98
|
-
return function (_x2) {
|
|
99
|
-
return _ref5.apply(this, arguments);
|
|
100
|
-
};
|
|
101
|
-
}();
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Retrieve notifications for the current user.
|
|
105
|
-
*
|
|
106
|
-
* @methodGroup Notifications
|
|
107
|
-
* @param {integer=} limit=10 - The maximum number of notifications to return
|
|
108
|
-
* @param {string=} tenantId - Filter notifications to only those related to the specified tenant
|
|
109
|
-
* @param {Array<string>=} types - Filter notifications to only the specified types
|
|
110
|
-
* @param {string=} offsetId - Return notifications older than the specified ID
|
|
111
|
-
*
|
|
112
|
-
* @returns {Promise<Array<Object>>} - A list of notifications for the specified parameters
|
|
113
|
-
*/
|
|
114
|
-
exports.Notifications = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
115
|
-
var _ref7,
|
|
116
|
-
tenantId,
|
|
117
|
-
types,
|
|
118
|
-
offsetId,
|
|
119
|
-
_ref7$limit,
|
|
120
|
-
limit,
|
|
121
|
-
queryParams,
|
|
122
|
-
_yield$Utils$Response,
|
|
123
|
-
records,
|
|
124
|
-
_args3 = arguments;
|
|
125
|
-
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
126
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
127
|
-
case 0:
|
|
128
|
-
_ref7 = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {}, tenantId = _ref7.tenantId, types = _ref7.types, offsetId = _ref7.offsetId, _ref7$limit = _ref7.limit, limit = _ref7$limit === void 0 ? 10 : _ref7$limit;
|
|
129
|
-
queryParams = {
|
|
130
|
-
limit: limit
|
|
131
|
-
};
|
|
132
|
-
if (tenantId) {
|
|
133
|
-
queryParams.tenant_id = tenantId;
|
|
134
|
-
}
|
|
135
|
-
if (types) {
|
|
136
|
-
queryParams.types = Array.isArray(types) ? types.join(",") : types;
|
|
137
|
-
}
|
|
138
|
-
if (offsetId) {
|
|
139
|
-
queryParams.offset_by = offsetId;
|
|
140
|
-
}
|
|
141
|
-
_context3.next = 7;
|
|
142
|
-
return Utils.ResponseToJson(this.stateStoreClient.Request({
|
|
143
|
-
method: "GET",
|
|
144
|
-
path: NotificationPath({
|
|
145
|
-
network: this.network,
|
|
146
|
-
path: UrlJoin("history", this.UserAddress())
|
|
147
|
-
}),
|
|
148
|
-
queryParams: queryParams,
|
|
149
|
-
headers: {
|
|
150
|
-
Authorization: "Bearer ".concat(this.AuthToken())
|
|
151
|
-
}
|
|
152
|
-
}));
|
|
153
|
-
case 7:
|
|
154
|
-
_yield$Utils$Response = _context3.sent;
|
|
155
|
-
records = _yield$Utils$Response.records;
|
|
156
|
-
return _context3.abrupt("return", records.map(function (record) {
|
|
157
|
-
try {
|
|
158
|
-
record.data = JSON.parse(record.data);
|
|
159
|
-
// eslint-disable-next-line no-empty
|
|
160
|
-
} catch (error) {}
|
|
161
|
-
return record;
|
|
162
|
-
}));
|
|
163
|
-
case 10:
|
|
164
|
-
case "end":
|
|
165
|
-
return _context3.stop();
|
|
166
|
-
}
|
|
167
|
-
}, _callee3, this);
|
|
168
|
-
}));
|
|
@@ -1,332 +0,0 @@
|
|
|
1
|
-
var _defineProperty = require("@babel/runtime/helpers/defineProperty");
|
|
2
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
3
|
-
var _regeneratorRuntime = require("@babel/runtime/regenerator");
|
|
4
|
-
var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
|
|
5
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
|
-
var Utils = require("../Utils");
|
|
8
|
-
var UrlJoin = require("url-join");
|
|
9
|
-
var StateStorePath = function StateStorePath(_ref) {
|
|
10
|
-
var network = _ref.network,
|
|
11
|
-
path = _ref.path;
|
|
12
|
-
return UrlJoin(network === "main" ? "/main" : "/dv3", path);
|
|
13
|
-
};
|
|
14
|
-
var UserProfilePath = function UserProfilePath(_ref2) {
|
|
15
|
-
var network = _ref2.network,
|
|
16
|
-
appId = _ref2.appId,
|
|
17
|
-
userAddress = _ref2.userAddress,
|
|
18
|
-
key = _ref2.key,
|
|
19
|
-
type = _ref2.type,
|
|
20
|
-
mode = _ref2.mode;
|
|
21
|
-
return StateStorePath({
|
|
22
|
-
network: network,
|
|
23
|
-
path: UrlJoin(type === "app" ? "app" : "usr", type === "app" ? appId : "", userAddress, mode === "public" ? "pub" : "pri", key || "")
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Methods related to getting and setting user profile data.
|
|
29
|
-
*
|
|
30
|
-
* @module ProfileMethods
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Retrieve user profile metadata for the specified user
|
|
35
|
-
*
|
|
36
|
-
* @methodGroup ProfileMetadata
|
|
37
|
-
* @namedParams
|
|
38
|
-
* @param {string=} type="app" - Specify `app` or `user` metadata.
|
|
39
|
-
* @param {string=} mode="public" - Specify `public` or `private` metadata. If private is specified, you may only retrieve metadata for the current user.
|
|
40
|
-
* @param {string=} appId - Namespace to use for the metadata, if retrieving app metadata. Uses the app ID specified on client initialization by default.
|
|
41
|
-
* @param {string=} userAddress - User to retrieve metadata for. If not specified, will retrieve metadata for the current user
|
|
42
|
-
* @param {string=} key - The metadata key to retrieve
|
|
43
|
-
*
|
|
44
|
-
* @returns {Promise<Object|String>} - Returns the specified metadata
|
|
45
|
-
*/
|
|
46
|
-
exports.ProfileMetadata = /*#__PURE__*/function () {
|
|
47
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref3) {
|
|
48
|
-
var _ref3$type, type, _ref3$mode, mode, appId, userAddress, key, response;
|
|
49
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
50
|
-
while (1) switch (_context.prev = _context.next) {
|
|
51
|
-
case 0:
|
|
52
|
-
_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;
|
|
53
|
-
_context.prev = 1;
|
|
54
|
-
_context.next = 4;
|
|
55
|
-
return this.stateStoreClient.Request({
|
|
56
|
-
path: UserProfilePath({
|
|
57
|
-
network: this.network,
|
|
58
|
-
appId: appId || this.appId,
|
|
59
|
-
userAddress: userAddress || this.UserAddress(),
|
|
60
|
-
type: type,
|
|
61
|
-
mode: mode,
|
|
62
|
-
key: key
|
|
63
|
-
}),
|
|
64
|
-
headers: mode === "private" ? {
|
|
65
|
-
Authorization: "Bearer ".concat(this.AuthToken())
|
|
66
|
-
} : undefined
|
|
67
|
-
});
|
|
68
|
-
case 4:
|
|
69
|
-
response = _context.sent;
|
|
70
|
-
if (response.ok) {
|
|
71
|
-
_context.next = 7;
|
|
72
|
-
break;
|
|
73
|
-
}
|
|
74
|
-
throw response;
|
|
75
|
-
case 7:
|
|
76
|
-
_context.next = 9;
|
|
77
|
-
return Utils.ResponseToJson(response);
|
|
78
|
-
case 9:
|
|
79
|
-
_context.t0 = key;
|
|
80
|
-
return _context.abrupt("return", _context.sent[_context.t0]);
|
|
81
|
-
case 13:
|
|
82
|
-
_context.prev = 13;
|
|
83
|
-
_context.t1 = _context["catch"](1);
|
|
84
|
-
if (!(_context.t1.status === 404)) {
|
|
85
|
-
_context.next = 17;
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
return _context.abrupt("return", undefined);
|
|
89
|
-
case 17:
|
|
90
|
-
throw _context.t1;
|
|
91
|
-
case 18:
|
|
92
|
-
case "end":
|
|
93
|
-
return _context.stop();
|
|
94
|
-
}
|
|
95
|
-
}, _callee, this, [[1, 13]]);
|
|
96
|
-
}));
|
|
97
|
-
return function (_x) {
|
|
98
|
-
return _ref4.apply(this, arguments);
|
|
99
|
-
};
|
|
100
|
-
}();
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Set user profile metadata for the current user
|
|
104
|
-
*
|
|
105
|
-
* @methodGroup ProfileMetadata
|
|
106
|
-
* @namedParams
|
|
107
|
-
* @param {string=} type="app" - Specify `app` or `user` metadata.
|
|
108
|
-
* @param {string=} mode="public" - Specify `public` or `private` metadata.
|
|
109
|
-
* @param {string=} appId - Namespace to use for the metadata, if retrieving app metadata. Uses the app ID specified on client initialization by default.
|
|
110
|
-
* @param {string} key - The metadata key to set
|
|
111
|
-
* @param {string} value - The metadata value to set
|
|
112
|
-
*/
|
|
113
|
-
exports.SetProfileMetadata = /*#__PURE__*/function () {
|
|
114
|
-
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref5) {
|
|
115
|
-
var _ref5$type, type, _ref5$mode, mode, appId, key, value;
|
|
116
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
117
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
118
|
-
case 0:
|
|
119
|
-
_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;
|
|
120
|
-
_context2.next = 3;
|
|
121
|
-
return this.stateStoreClient.Request({
|
|
122
|
-
method: "POST",
|
|
123
|
-
path: UserProfilePath({
|
|
124
|
-
network: this.network,
|
|
125
|
-
appId: appId || this.appId,
|
|
126
|
-
userAddress: this.UserAddress(),
|
|
127
|
-
type: type,
|
|
128
|
-
mode: mode,
|
|
129
|
-
key: key
|
|
130
|
-
}),
|
|
131
|
-
body: value,
|
|
132
|
-
bodyType: _typeof(value) === "object" ? "JSON" : "string",
|
|
133
|
-
headers: {
|
|
134
|
-
Authorization: "Bearer ".concat(this.AuthToken())
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
case 3:
|
|
138
|
-
case "end":
|
|
139
|
-
return _context2.stop();
|
|
140
|
-
}
|
|
141
|
-
}, _callee2, this);
|
|
142
|
-
}));
|
|
143
|
-
return function (_x2) {
|
|
144
|
-
return _ref6.apply(this, arguments);
|
|
145
|
-
};
|
|
146
|
-
}();
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Remove user profile metadata for the current user
|
|
150
|
-
*
|
|
151
|
-
* @methodGroup ProfileMetadata
|
|
152
|
-
* @namedParams
|
|
153
|
-
* @param {string=} type="app" - Specify `app` or `user` metadata.
|
|
154
|
-
* @param {string=} mode="public" - Specify `public` or `private` metadata.
|
|
155
|
-
* @param {string=} appId - Namespace to use for the metadata, if retrieving app metadata.. Uses the app ID specified on client initialization by default.
|
|
156
|
-
* @param {string} key - The metadata key to set
|
|
157
|
-
*/
|
|
158
|
-
exports.RemoveProfileMetadata = /*#__PURE__*/function () {
|
|
159
|
-
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref7) {
|
|
160
|
-
var _ref7$type, type, _ref7$mode, mode, appId, key;
|
|
161
|
-
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
162
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
163
|
-
case 0:
|
|
164
|
-
_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;
|
|
165
|
-
_context3.next = 3;
|
|
166
|
-
return this.stateStoreClient.Request({
|
|
167
|
-
method: "DELETE",
|
|
168
|
-
path: UserProfilePath({
|
|
169
|
-
network: this.network,
|
|
170
|
-
appId: appId || this.appId,
|
|
171
|
-
userAddress: this.UserAddress(),
|
|
172
|
-
type: type,
|
|
173
|
-
mode: mode,
|
|
174
|
-
key: key
|
|
175
|
-
}),
|
|
176
|
-
headers: {
|
|
177
|
-
Authorization: "Bearer ".concat(this.AuthToken())
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
case 3:
|
|
181
|
-
case "end":
|
|
182
|
-
return _context3.stop();
|
|
183
|
-
}
|
|
184
|
-
}, _callee3, this);
|
|
185
|
-
}));
|
|
186
|
-
return function (_x3) {
|
|
187
|
-
return _ref8.apply(this, arguments);
|
|
188
|
-
};
|
|
189
|
-
}();
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Retrieve profile info for the specified user, including address, username, profile image (if set) and badges (if any)
|
|
193
|
-
*
|
|
194
|
-
* @methodGroup Profile
|
|
195
|
-
* @param {string=} userAddress - Address of the user
|
|
196
|
-
* @param {string=} userName - Username of the user
|
|
197
|
-
*
|
|
198
|
-
* @returns {Promise<Object>} - Profile info of the specified user
|
|
199
|
-
*/
|
|
200
|
-
exports.Profile = /*#__PURE__*/function () {
|
|
201
|
-
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref9) {
|
|
202
|
-
var userAddress, userName, imageUrl, badgeData, badges;
|
|
203
|
-
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
204
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
205
|
-
case 0:
|
|
206
|
-
userAddress = _ref9.userAddress, userName = _ref9.userName;
|
|
207
|
-
if (!userName) {
|
|
208
|
-
_context4.next = 5;
|
|
209
|
-
break;
|
|
210
|
-
}
|
|
211
|
-
_context4.next = 4;
|
|
212
|
-
return this.UserNameToAddress({
|
|
213
|
-
userName: userName
|
|
214
|
-
});
|
|
215
|
-
case 4:
|
|
216
|
-
userAddress = _context4.sent;
|
|
217
|
-
case 5:
|
|
218
|
-
if (userAddress) {
|
|
219
|
-
_context4.next = 7;
|
|
220
|
-
break;
|
|
221
|
-
}
|
|
222
|
-
throw Error("Eluvio Wallet Client: Unable to determine profile - user address not specified");
|
|
223
|
-
case 7:
|
|
224
|
-
if (userName) {
|
|
225
|
-
_context4.next = 11;
|
|
226
|
-
break;
|
|
227
|
-
}
|
|
228
|
-
_context4.next = 10;
|
|
229
|
-
return this.ProfileMetadata({
|
|
230
|
-
type: "user",
|
|
231
|
-
userAddress: userAddress,
|
|
232
|
-
key: "username"
|
|
233
|
-
});
|
|
234
|
-
case 10:
|
|
235
|
-
userName = _context4.sent;
|
|
236
|
-
case 11:
|
|
237
|
-
_context4.next = 13;
|
|
238
|
-
return this.ProfileMetadata({
|
|
239
|
-
type: "user",
|
|
240
|
-
userAddress: userAddress,
|
|
241
|
-
key: "icon_url"
|
|
242
|
-
});
|
|
243
|
-
case 13:
|
|
244
|
-
imageUrl = _context4.sent;
|
|
245
|
-
_context4.next = 16;
|
|
246
|
-
return this.ProfileMetadata({
|
|
247
|
-
type: "app",
|
|
248
|
-
mode: "public",
|
|
249
|
-
appId: "elv-badge-srv",
|
|
250
|
-
userAddress: this.badgerAddress,
|
|
251
|
-
key: "badges_".concat(Utils.FormatAddress(userAddress))
|
|
252
|
-
});
|
|
253
|
-
case 16:
|
|
254
|
-
badgeData = _context4.sent;
|
|
255
|
-
badges = [];
|
|
256
|
-
if (badgeData) {
|
|
257
|
-
try {
|
|
258
|
-
badgeData = JSON.parse(badgeData).badges;
|
|
259
|
-
badges = Object.keys(badgeData).map(function (badgeName) {
|
|
260
|
-
return _objectSpread(_objectSpread({}, badgeData[badgeName]), {}, {
|
|
261
|
-
name: badgeName
|
|
262
|
-
});
|
|
263
|
-
});
|
|
264
|
-
} catch (error) {
|
|
265
|
-
this.Log("Failed to load badge info for ".concat(userName || userAddress), true);
|
|
266
|
-
this.Log(error, true);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
return _context4.abrupt("return", {
|
|
270
|
-
userAddress: Utils.FormatAddress(userAddress),
|
|
271
|
-
userName: userName,
|
|
272
|
-
imageUrl: imageUrl,
|
|
273
|
-
badges: badges
|
|
274
|
-
});
|
|
275
|
-
case 20:
|
|
276
|
-
case "end":
|
|
277
|
-
return _context4.stop();
|
|
278
|
-
}
|
|
279
|
-
}, _callee4, this);
|
|
280
|
-
}));
|
|
281
|
-
return function (_x4) {
|
|
282
|
-
return _ref10.apply(this, arguments);
|
|
283
|
-
};
|
|
284
|
-
}();
|
|
285
|
-
exports.UserNameToAddress = /*#__PURE__*/function () {
|
|
286
|
-
var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref11) {
|
|
287
|
-
var userName, response;
|
|
288
|
-
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
289
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
290
|
-
case 0:
|
|
291
|
-
userName = _ref11.userName;
|
|
292
|
-
_context5.prev = 1;
|
|
293
|
-
_context5.next = 4;
|
|
294
|
-
return this.stateStoreClient.Request({
|
|
295
|
-
method: "GET",
|
|
296
|
-
path: StateStorePath({
|
|
297
|
-
network: this.network,
|
|
298
|
-
path: UrlJoin("usr", "profile_for_username", userName)
|
|
299
|
-
})
|
|
300
|
-
});
|
|
301
|
-
case 4:
|
|
302
|
-
response = _context5.sent;
|
|
303
|
-
if (response.ok) {
|
|
304
|
-
_context5.next = 7;
|
|
305
|
-
break;
|
|
306
|
-
}
|
|
307
|
-
throw response;
|
|
308
|
-
case 7:
|
|
309
|
-
_context5.next = 9;
|
|
310
|
-
return Utils.ResponseToJson(response);
|
|
311
|
-
case 9:
|
|
312
|
-
return _context5.abrupt("return", _context5.sent.address);
|
|
313
|
-
case 12:
|
|
314
|
-
_context5.prev = 12;
|
|
315
|
-
_context5.t0 = _context5["catch"](1);
|
|
316
|
-
if (!(_context5.t0.status !== 404)) {
|
|
317
|
-
_context5.next = 16;
|
|
318
|
-
break;
|
|
319
|
-
}
|
|
320
|
-
throw _context5.t0;
|
|
321
|
-
case 16:
|
|
322
|
-
return _context5.abrupt("return", undefined);
|
|
323
|
-
case 17:
|
|
324
|
-
case "end":
|
|
325
|
-
return _context5.stop();
|
|
326
|
-
}
|
|
327
|
-
}, _callee5, this, [[1, 12]]);
|
|
328
|
-
}));
|
|
329
|
-
return function (_x5) {
|
|
330
|
-
return _ref12.apply(this, arguments);
|
|
331
|
-
};
|
|
332
|
-
}();
|