@eluvio/elv-client-js 4.0.114 → 4.0.115

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 (129) hide show
  1. package/dist/ElvClient-min.js +67 -0
  2. package/dist/ElvClient-node-min.js +66 -0
  3. package/dist/ElvFrameClient-min.js +60 -0
  4. package/dist/ElvPermissionsClient-min.js +60 -0
  5. package/dist/ElvWalletClient-min.js +67 -0
  6. package/dist/ElvWalletClient-node-min.js +66 -0
  7. package/dist/src/AuthorizationClient.js +2169 -0
  8. package/dist/src/ContentObjectAudit.js +175 -0
  9. package/dist/src/ContentObjectVerification.js +281 -0
  10. package/dist/src/Crypto.js +412 -0
  11. package/dist/src/ElvClient.js +2044 -0
  12. package/dist/src/ElvWallet.js +245 -0
  13. package/dist/src/EthClient.js +1154 -0
  14. package/dist/src/FrameClient.js +485 -0
  15. package/dist/src/HttpClient.js +315 -0
  16. package/dist/src/Id.js +21 -0
  17. package/dist/src/LogMessage.js +25 -0
  18. package/dist/src/PermissionsClient.js +1544 -0
  19. package/dist/src/RemoteSigner.js +385 -0
  20. package/dist/src/UserProfileClient.js +1450 -0
  21. package/dist/src/Utils.js +894 -0
  22. package/dist/src/Validation.js +121 -0
  23. package/dist/src/abr_profiles/abr_profile_live_drm.js +1661 -0
  24. package/dist/src/abr_profiles/abr_profile_live_to_vod.js +1606 -0
  25. package/dist/src/client/ABRPublishing.js +1018 -0
  26. package/dist/src/client/AccessGroups.js +1503 -0
  27. package/dist/src/client/ContentAccess.js +5195 -0
  28. package/dist/src/client/ContentManagement.js +2680 -0
  29. package/dist/src/client/Contracts.js +1520 -0
  30. package/dist/src/client/Files.js +2181 -0
  31. package/dist/src/client/LiveConf.js +569 -0
  32. package/dist/src/client/LiveStream.js +2640 -0
  33. package/dist/src/client/NFT.js +162 -0
  34. package/dist/src/client/NTP.js +581 -0
  35. package/dist/src/contracts/v2/AccessIndexor.js +831 -0
  36. package/dist/src/contracts/v2/Accessible.js +31 -0
  37. package/dist/src/contracts/v2/BaseAccessControlGroup.js +1263 -0
  38. package/dist/src/contracts/v2/BaseAccessWallet.js +1609 -0
  39. package/dist/src/contracts/v2/BaseAccessWalletFactory.js +93 -0
  40. package/dist/src/contracts/v2/BaseContent.js +1076 -0
  41. package/dist/src/contracts/v2/BaseContentFactory.js +219 -0
  42. package/dist/src/contracts/v2/BaseContentSpace.js +1352 -0
  43. package/dist/src/contracts/v2/BaseContentType.js +364 -0
  44. package/dist/src/contracts/v2/BaseFactory.js +107 -0
  45. package/dist/src/contracts/v2/BaseGroupFactory.js +93 -0
  46. package/dist/src/contracts/v2/BaseLibrary.js +1041 -0
  47. package/dist/src/contracts/v2/BaseLibraryFactory.js +96 -0
  48. package/dist/src/contracts/v2/Certifyer.js +86 -0
  49. package/dist/src/contracts/v2/Container.js +540 -0
  50. package/dist/src/contracts/v2/Content.js +443 -0
  51. package/dist/src/contracts/v2/Editable.js +306 -0
  52. package/dist/src/contracts/v2/ExternalUserWallet.js +379 -0
  53. package/dist/src/contracts/v2/IFactorySpace.js +57 -0
  54. package/dist/src/contracts/v2/IKmsSpace.js +52 -0
  55. package/dist/src/contracts/v2/INodeSpace.js +18 -0
  56. package/dist/src/contracts/v2/IUserSpace.js +18 -0
  57. package/dist/src/contracts/v2/LvRecordableStream.js +1037 -0
  58. package/dist/src/contracts/v2/LvRecording.js +627 -0
  59. package/dist/src/contracts/v2/LvStreamRightsHolder.js +562 -0
  60. package/dist/src/contracts/v2/MetaObject.js +119 -0
  61. package/dist/src/contracts/v2/Node.js +167 -0
  62. package/dist/src/contracts/v2/NodeSpace.js +273 -0
  63. package/dist/src/contracts/v2/Ownable.js +87 -0
  64. package/dist/src/contracts/v2/PaymentService.js +627 -0
  65. package/dist/src/contracts/v2/Precompile.js +15 -0
  66. package/dist/src/contracts/v2/Transactable.js +82 -0
  67. package/dist/src/contracts/v2/UserSpace.js +29 -0
  68. package/dist/src/contracts/v2/Utils.js +18 -0
  69. package/dist/src/contracts/v2/Verifier.js +53 -0
  70. package/dist/src/contracts/v2/strings.js +4 -0
  71. package/dist/src/contracts/v3/AccessIndexor.js +774 -0
  72. package/dist/src/contracts/v3/Accessible.js +232 -0
  73. package/dist/src/contracts/v3/Adminable.js +107 -0
  74. package/dist/src/contracts/v3/AvailsDelivery.js +586 -0
  75. package/dist/src/contracts/v3/BaseAccessControlGroup.js +1603 -0
  76. package/dist/src/contracts/v3/BaseAccessWallet.js +1628 -0
  77. package/dist/src/contracts/v3/BaseAccessWalletFactory.js +112 -0
  78. package/dist/src/contracts/v3/BaseContent.js +1312 -0
  79. package/dist/src/contracts/v3/BaseContentFactory.js +183 -0
  80. package/dist/src/contracts/v3/BaseContentFactoryExt.js +175 -0
  81. package/dist/src/contracts/v3/BaseContentSpace.js +1515 -0
  82. package/dist/src/contracts/v3/BaseContentType.js +527 -0
  83. package/dist/src/contracts/v3/BaseFactory.js +126 -0
  84. package/dist/src/contracts/v3/BaseGroupFactory.js +112 -0
  85. package/dist/src/contracts/v3/BaseLibrary.js +1204 -0
  86. package/dist/src/contracts/v3/BaseLibraryFactory.js +115 -0
  87. package/dist/src/contracts/v3/BaseTenantSpace.js +1587 -0
  88. package/dist/src/contracts/v3/Certifyer.js +86 -0
  89. package/dist/src/contracts/v3/Container.js +739 -0
  90. package/dist/src/contracts/v3/Content.js +438 -0
  91. package/dist/src/contracts/v3/CounterObject.js +243 -0
  92. package/dist/src/contracts/v3/Editable.js +519 -0
  93. package/dist/src/contracts/v3/EncToken.js +4 -0
  94. package/dist/src/contracts/v3/ExternalUserWallet.js +587 -0
  95. package/dist/src/contracts/v3/IAdmin.js +18 -0
  96. package/dist/src/contracts/v3/IFactorySpace.js +57 -0
  97. package/dist/src/contracts/v3/IKmsSpace.js +52 -0
  98. package/dist/src/contracts/v3/INodeSpace.js +18 -0
  99. package/dist/src/contracts/v3/IUserSpace.js +32 -0
  100. package/dist/src/contracts/v3/LvRecordableStream.js +1032 -0
  101. package/dist/src/contracts/v3/LvRecording.js +650 -0
  102. package/dist/src/contracts/v3/LvStreamRightsHolder.js +557 -0
  103. package/dist/src/contracts/v3/MetaObject.js +144 -0
  104. package/dist/src/contracts/v3/Node.js +178 -0
  105. package/dist/src/contracts/v3/NodeSpace.js +284 -0
  106. package/dist/src/contracts/v3/Ownable.js +98 -0
  107. package/dist/src/contracts/v3/PaymentService.js +622 -0
  108. package/dist/src/contracts/v3/Precompile.js +26 -0
  109. package/dist/src/contracts/v3/TenantFuncsBase.js +351 -0
  110. package/dist/src/contracts/v3/Transactable.js +82 -0
  111. package/dist/src/contracts/v3/UserSpace.js +43 -0
  112. package/dist/src/contracts/v3/Utils.js +18 -0
  113. package/dist/src/contracts/v3/Verifier.js +53 -0
  114. package/dist/src/contracts/v3/strings.js +4 -0
  115. package/dist/src/contracts/v3b/BaseAccessControlGroup.js +1704 -0
  116. package/dist/src/events/Topics.js +1793 -0
  117. package/dist/src/index.js +8 -0
  118. package/dist/src/walletClient/ClientMethods.js +3102 -0
  119. package/dist/src/walletClient/Configuration.js +38 -0
  120. package/dist/src/walletClient/Notifications.js +168 -0
  121. package/dist/src/walletClient/Profile.js +332 -0
  122. package/dist/src/walletClient/Utils.js +281 -0
  123. package/dist/src/walletClient/index.js +2106 -0
  124. package/package.json +1 -1
  125. package/src/AuthorizationClient.js +24 -16
  126. package/src/ElvClient.js +19 -0
  127. package/src/client/ContentAccess.js +10 -1
  128. package/src/client/LiveConf.js +10 -8
  129. package/src/client/LiveStream.js +6 -4
@@ -0,0 +1,38 @@
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;
@@ -0,0 +1,168 @@
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
+ }));
@@ -0,0 +1,332 @@
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
+ }();