@eluvio/elv-client-js 4.0.112 → 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/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 -2022
- 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,1450 +0,0 @@
|
|
|
1
|
-
var _regeneratorRuntime = require("@babel/runtime/regenerator");
|
|
2
|
-
var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
|
|
3
|
-
var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
|
|
4
|
-
var _createClass = require("@babel/runtime/helpers/createClass");
|
|
5
|
-
var Utils = require("./Utils");
|
|
6
|
-
var UrlJoin = require("url-join");
|
|
7
|
-
var _require = require("./FrameClient"),
|
|
8
|
-
FrameClient = _require.FrameClient;
|
|
9
|
-
var _require2 = require("./LogMessage"),
|
|
10
|
-
LogMessage = _require2.LogMessage;
|
|
11
|
-
var UserProfileClient = /*#__PURE__*/function () {
|
|
12
|
-
"use strict";
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Methods used to access and modify information about the user
|
|
16
|
-
*
|
|
17
|
-
* <h4 id="PromptsAndAccessLevels">A note about access level and prompts: </h4>
|
|
18
|
-
*
|
|
19
|
-
* Note: This section only applies to applications working within Eluvio Core
|
|
20
|
-
*
|
|
21
|
-
* Users can choose whether or not their info is shared to applications. A user
|
|
22
|
-
* may choose to allow open access to their profile, no access to their profile, or
|
|
23
|
-
* they may choose to be prompted to give access when an application requests it. The
|
|
24
|
-
* user's access level can be determined using the <a href="#AccessLevel">AccessLevel</a>
|
|
25
|
-
* method.
|
|
26
|
-
*
|
|
27
|
-
* By default, users will be prompted to give access. For methods that access the user's private information,
|
|
28
|
-
* Eluvio Core will intercept the request and prompt the user for permission before proceeding. In
|
|
29
|
-
* these cases, the normal FrameClient timeout period will be ignored, and the response will come
|
|
30
|
-
* only after the user accepts or rejects the request.
|
|
31
|
-
*
|
|
32
|
-
* Access and modification of user metadata is namespaced to the requesting application when using the
|
|
33
|
-
* FrameClient. Public user metadata can be accessed using the PublicUserMetadata method.
|
|
34
|
-
*
|
|
35
|
-
* If the user refuses to give permission, an error will be thrown. Otherwise, the request will proceed
|
|
36
|
-
* as normal.
|
|
37
|
-
*
|
|
38
|
-
* <h4>Usage</h4>
|
|
39
|
-
*
|
|
40
|
-
* Access the UserProfileClient from ElvClient or FrameClient via client.userProfileClient
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
let client = ElvClient.FromConfiguration({configuration: ClientConfiguration});
|
|
44
|
-
let wallet = client.GenerateWallet();
|
|
45
|
-
let signer = wallet.AddAccount({
|
|
46
|
-
accountName: "Alice",
|
|
47
|
-
privateKey: "0x0000000000000000000000000000000000000000000000000000000000000000"
|
|
48
|
-
});
|
|
49
|
-
client.SetSigner({signer});
|
|
50
|
-
await client.userProfileClient.UserMetadata()
|
|
51
|
-
let frameClient = new FrameClient();
|
|
52
|
-
await client.userProfileClient.UserMetadata()
|
|
53
|
-
*
|
|
54
|
-
*/
|
|
55
|
-
function UserProfileClient(_ref) {
|
|
56
|
-
var client = _ref.client,
|
|
57
|
-
debug = _ref.debug;
|
|
58
|
-
_classCallCheck(this, UserProfileClient);
|
|
59
|
-
this.client = client;
|
|
60
|
-
this.debug = debug;
|
|
61
|
-
this.userWalletAddresses = {};
|
|
62
|
-
this.walletAddress = undefined;
|
|
63
|
-
this.walletAddressRetrieved = false;
|
|
64
|
-
}
|
|
65
|
-
_createClass(UserProfileClient, [{
|
|
66
|
-
key: "Log",
|
|
67
|
-
value: function Log(message) {
|
|
68
|
-
var error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
69
|
-
LogMessage(this, message, error);
|
|
70
|
-
}
|
|
71
|
-
}, {
|
|
72
|
-
key: "CreateWallet",
|
|
73
|
-
value: function () {
|
|
74
|
-
var _CreateWallet = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
75
|
-
var balance, walletCreationEvent, abi, libraryId, objectId, createResponse;
|
|
76
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
77
|
-
while (1) switch (_context.prev = _context.next) {
|
|
78
|
-
case 0:
|
|
79
|
-
if (!this.creatingWallet) {
|
|
80
|
-
_context.next = 6;
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
case 1:
|
|
84
|
-
if (!this.creatingWallet) {
|
|
85
|
-
_context.next = 6;
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
_context.next = 4;
|
|
89
|
-
return new Promise(function (resolve) {
|
|
90
|
-
return setTimeout(resolve, 500);
|
|
91
|
-
});
|
|
92
|
-
case 4:
|
|
93
|
-
_context.next = 1;
|
|
94
|
-
break;
|
|
95
|
-
case 6:
|
|
96
|
-
this.creatingWallet = true;
|
|
97
|
-
_context.prev = 7;
|
|
98
|
-
if (!(!this.walletAddress || Utils.EqualAddress(this.walletAddress, Utils.nullAddress))) {
|
|
99
|
-
_context.next = 23;
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
this.Log("Creating user wallet for user ".concat(this.client.signer.address));
|
|
103
|
-
|
|
104
|
-
// Don't attempt to create a user wallet if user has no funds
|
|
105
|
-
_context.next = 12;
|
|
106
|
-
return this.client.GetBalance({
|
|
107
|
-
address: this.client.signer.address
|
|
108
|
-
});
|
|
109
|
-
case 12:
|
|
110
|
-
balance = _context.sent;
|
|
111
|
-
if (!(balance < 0.05)) {
|
|
112
|
-
_context.next = 15;
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
return _context.abrupt("return", undefined);
|
|
116
|
-
case 15:
|
|
117
|
-
_context.next = 17;
|
|
118
|
-
return this.client.CallContractMethodAndWait({
|
|
119
|
-
contractAddress: Utils.HashToAddress(this.client.contentSpaceId),
|
|
120
|
-
methodName: "createAccessWallet",
|
|
121
|
-
methodArgs: []
|
|
122
|
-
});
|
|
123
|
-
case 17:
|
|
124
|
-
walletCreationEvent = _context.sent;
|
|
125
|
-
_context.next = 20;
|
|
126
|
-
return this.client.ContractAbi({
|
|
127
|
-
contractAddress: this.client.contentSpaceAddress
|
|
128
|
-
});
|
|
129
|
-
case 20:
|
|
130
|
-
abi = _context.sent;
|
|
131
|
-
this.walletAddress = this.client.ExtractValueFromEvent({
|
|
132
|
-
abi: abi,
|
|
133
|
-
event: walletCreationEvent,
|
|
134
|
-
eventName: "CreateAccessWallet",
|
|
135
|
-
eventValue: "wallet"
|
|
136
|
-
});
|
|
137
|
-
this.userWalletAddresses[Utils.FormatAddress(this.client.signer.address)] = this.walletAddress;
|
|
138
|
-
case 23:
|
|
139
|
-
// Check if wallet object is created
|
|
140
|
-
libraryId = this.client.contentSpaceLibraryId;
|
|
141
|
-
objectId = Utils.AddressToObjectId(this.walletAddress);
|
|
142
|
-
_context.prev = 25;
|
|
143
|
-
_context.next = 28;
|
|
144
|
-
return this.client.ContentObject({
|
|
145
|
-
libraryId: libraryId,
|
|
146
|
-
objectId: objectId
|
|
147
|
-
});
|
|
148
|
-
case 28:
|
|
149
|
-
_context.next = 39;
|
|
150
|
-
break;
|
|
151
|
-
case 30:
|
|
152
|
-
_context.prev = 30;
|
|
153
|
-
_context.t0 = _context["catch"](25);
|
|
154
|
-
if (!(_context.t0.status === 404)) {
|
|
155
|
-
_context.next = 39;
|
|
156
|
-
break;
|
|
157
|
-
}
|
|
158
|
-
this.Log("Creating wallet object for user ".concat(this.client.signer.address));
|
|
159
|
-
_context.next = 36;
|
|
160
|
-
return this.client.CreateContentObject({
|
|
161
|
-
libraryId: libraryId,
|
|
162
|
-
objectId: objectId
|
|
163
|
-
});
|
|
164
|
-
case 36:
|
|
165
|
-
createResponse = _context.sent;
|
|
166
|
-
_context.next = 39;
|
|
167
|
-
return this.client.FinalizeContentObject({
|
|
168
|
-
libraryId: libraryId,
|
|
169
|
-
objectId: objectId,
|
|
170
|
-
writeToken: createResponse.write_token,
|
|
171
|
-
commitMessage: "Create user wallet object"
|
|
172
|
-
});
|
|
173
|
-
case 39:
|
|
174
|
-
_context.next = 45;
|
|
175
|
-
break;
|
|
176
|
-
case 41:
|
|
177
|
-
_context.prev = 41;
|
|
178
|
-
_context.t1 = _context["catch"](7);
|
|
179
|
-
// eslint-disable-next-line no-console
|
|
180
|
-
console.error("Failed to create wallet contract:");
|
|
181
|
-
// eslint-disable-next-line no-console
|
|
182
|
-
console.error(_context.t1);
|
|
183
|
-
case 45:
|
|
184
|
-
_context.prev = 45;
|
|
185
|
-
this.creatingWallet = false;
|
|
186
|
-
return _context.finish(45);
|
|
187
|
-
case 48:
|
|
188
|
-
case "end":
|
|
189
|
-
return _context.stop();
|
|
190
|
-
}
|
|
191
|
-
}, _callee, this, [[7, 41, 45, 48], [25, 30]]);
|
|
192
|
-
}));
|
|
193
|
-
function CreateWallet() {
|
|
194
|
-
return _CreateWallet.apply(this, arguments);
|
|
195
|
-
}
|
|
196
|
-
return CreateWallet;
|
|
197
|
-
}()
|
|
198
|
-
/**
|
|
199
|
-
* Get the contract address of the current user's BaseAccessWallet contract
|
|
200
|
-
*
|
|
201
|
-
* @return {Promise<string>} - The contract address of the current user's wallet contract
|
|
202
|
-
*/
|
|
203
|
-
}, {
|
|
204
|
-
key: "WalletAddress",
|
|
205
|
-
value: function () {
|
|
206
|
-
var _WalletAddress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
207
|
-
var autoCreate,
|
|
208
|
-
walletAddress,
|
|
209
|
-
_args2 = arguments;
|
|
210
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
211
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
212
|
-
case 0:
|
|
213
|
-
autoCreate = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : true;
|
|
214
|
-
if (!(this.walletAddress || this.walletAddressRetrieved)) {
|
|
215
|
-
_context2.next = 3;
|
|
216
|
-
break;
|
|
217
|
-
}
|
|
218
|
-
return _context2.abrupt("return", this.walletAddress);
|
|
219
|
-
case 3:
|
|
220
|
-
if (!this.walletAddressPromise) {
|
|
221
|
-
this.walletAddressPromise = this.client.CallContractMethod({
|
|
222
|
-
contractAddress: Utils.HashToAddress(this.client.contentSpaceId),
|
|
223
|
-
methodName: "userWallets",
|
|
224
|
-
methodArgs: [this.client.signer.address]
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
_context2.next = 6;
|
|
228
|
-
return this.walletAddressPromise;
|
|
229
|
-
case 6:
|
|
230
|
-
walletAddress = _context2.sent;
|
|
231
|
-
if (!Utils.EqualAddress(walletAddress, Utils.nullAddress)) {
|
|
232
|
-
this.walletAddress = walletAddress;
|
|
233
|
-
}
|
|
234
|
-
if (!(!this.walletAddress && autoCreate)) {
|
|
235
|
-
_context2.next = 11;
|
|
236
|
-
break;
|
|
237
|
-
}
|
|
238
|
-
_context2.next = 11;
|
|
239
|
-
return this.CreateWallet();
|
|
240
|
-
case 11:
|
|
241
|
-
this.walletAddressRetrieved = true;
|
|
242
|
-
return _context2.abrupt("return", this.walletAddress);
|
|
243
|
-
case 13:
|
|
244
|
-
case "end":
|
|
245
|
-
return _context2.stop();
|
|
246
|
-
}
|
|
247
|
-
}, _callee2, this);
|
|
248
|
-
}));
|
|
249
|
-
function WalletAddress() {
|
|
250
|
-
return _WalletAddress.apply(this, arguments);
|
|
251
|
-
}
|
|
252
|
-
return WalletAddress;
|
|
253
|
-
}()
|
|
254
|
-
/**
|
|
255
|
-
* Get the user wallet address for the specified user, if it exists
|
|
256
|
-
*
|
|
257
|
-
* @namedParams
|
|
258
|
-
* @param {string} address - The address of the user
|
|
259
|
-
*
|
|
260
|
-
* @return {Promise<string>} - The wallet address of the specified user, if it exists
|
|
261
|
-
*/
|
|
262
|
-
}, {
|
|
263
|
-
key: "UserWalletAddress",
|
|
264
|
-
value: function () {
|
|
265
|
-
var _UserWalletAddress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref2) {
|
|
266
|
-
var address, walletAddress;
|
|
267
|
-
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
268
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
269
|
-
case 0:
|
|
270
|
-
address = _ref2.address;
|
|
271
|
-
if (!Utils.EqualAddress(address, this.client.signer.address)) {
|
|
272
|
-
_context3.next = 5;
|
|
273
|
-
break;
|
|
274
|
-
}
|
|
275
|
-
_context3.next = 4;
|
|
276
|
-
return this.WalletAddress();
|
|
277
|
-
case 4:
|
|
278
|
-
return _context3.abrupt("return", _context3.sent);
|
|
279
|
-
case 5:
|
|
280
|
-
if (this.userWalletAddresses[address]) {
|
|
281
|
-
_context3.next = 11;
|
|
282
|
-
break;
|
|
283
|
-
}
|
|
284
|
-
this.Log("Retrieving user wallet address for user ".concat(address));
|
|
285
|
-
_context3.next = 9;
|
|
286
|
-
return this.client.CallContractMethod({
|
|
287
|
-
contractAddress: Utils.HashToAddress(this.client.contentSpaceId),
|
|
288
|
-
methodName: "userWallets",
|
|
289
|
-
methodArgs: [address]
|
|
290
|
-
});
|
|
291
|
-
case 9:
|
|
292
|
-
walletAddress = _context3.sent;
|
|
293
|
-
if (!Utils.EqualAddress(walletAddress, Utils.nullAddress)) {
|
|
294
|
-
this.userWalletAddresses[address] = walletAddress;
|
|
295
|
-
}
|
|
296
|
-
case 11:
|
|
297
|
-
return _context3.abrupt("return", this.userWalletAddresses[address]);
|
|
298
|
-
case 12:
|
|
299
|
-
case "end":
|
|
300
|
-
return _context3.stop();
|
|
301
|
-
}
|
|
302
|
-
}, _callee3, this);
|
|
303
|
-
}));
|
|
304
|
-
function UserWalletAddress(_x) {
|
|
305
|
-
return _UserWalletAddress.apply(this, arguments);
|
|
306
|
-
}
|
|
307
|
-
return UserWalletAddress;
|
|
308
|
-
}()
|
|
309
|
-
/**
|
|
310
|
-
* Retrieve the user wallet object information (library ID and object ID)
|
|
311
|
-
*
|
|
312
|
-
* The user's wallet can be modified in the same way as any other object, using
|
|
313
|
-
* EditContentObject to get a write token, modification methods to change it,
|
|
314
|
-
* and FinalizeContentObject to finalize the draft
|
|
315
|
-
*
|
|
316
|
-
* @return {Promise<{Object}>} - An object containing the libraryId and objectId for the wallet object.
|
|
317
|
-
*/
|
|
318
|
-
}, {
|
|
319
|
-
key: "UserWalletObjectInfo",
|
|
320
|
-
value: function () {
|
|
321
|
-
var _UserWalletObjectInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
322
|
-
var _ref3,
|
|
323
|
-
address,
|
|
324
|
-
walletAddress,
|
|
325
|
-
_args4 = arguments;
|
|
326
|
-
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
327
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
328
|
-
case 0:
|
|
329
|
-
_ref3 = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {}, address = _ref3.address;
|
|
330
|
-
if (!address) {
|
|
331
|
-
_context4.next = 7;
|
|
332
|
-
break;
|
|
333
|
-
}
|
|
334
|
-
_context4.next = 4;
|
|
335
|
-
return this.UserWalletAddress({
|
|
336
|
-
address: address
|
|
337
|
-
});
|
|
338
|
-
case 4:
|
|
339
|
-
_context4.t0 = _context4.sent;
|
|
340
|
-
_context4.next = 10;
|
|
341
|
-
break;
|
|
342
|
-
case 7:
|
|
343
|
-
_context4.next = 9;
|
|
344
|
-
return this.WalletAddress();
|
|
345
|
-
case 9:
|
|
346
|
-
_context4.t0 = _context4.sent;
|
|
347
|
-
case 10:
|
|
348
|
-
walletAddress = _context4.t0;
|
|
349
|
-
return _context4.abrupt("return", {
|
|
350
|
-
libraryId: this.client.contentSpaceLibraryId,
|
|
351
|
-
objectId: walletAddress ? Utils.AddressToObjectId(walletAddress) : ""
|
|
352
|
-
});
|
|
353
|
-
case 12:
|
|
354
|
-
case "end":
|
|
355
|
-
return _context4.stop();
|
|
356
|
-
}
|
|
357
|
-
}, _callee4, this);
|
|
358
|
-
}));
|
|
359
|
-
function UserWalletObjectInfo() {
|
|
360
|
-
return _UserWalletObjectInfo.apply(this, arguments);
|
|
361
|
-
}
|
|
362
|
-
return UserWalletObjectInfo;
|
|
363
|
-
}()
|
|
364
|
-
/**
|
|
365
|
-
* Access the specified user's public profile metadata
|
|
366
|
-
*
|
|
367
|
-
* @namedParams
|
|
368
|
-
* @param {string=} address - The address of the user
|
|
369
|
-
* @param {string=} metadataSubtree - Subtree of the metadata to retrieve
|
|
370
|
-
* @param {Object=} queryParams={} - Additional query params for the call
|
|
371
|
-
* @param {Array<string>=} select - Limit the returned metadata to the specified attributes
|
|
372
|
-
* - Note: Selection is relative to "metadataSubtree". For example, metadataSubtree="public" and select=["name", "description"] would select "public/name" and "public/description"
|
|
373
|
-
* @param {boolean=} resolveLinks=false - If specified, links in the metadata will be resolved
|
|
374
|
-
* @param {boolean=} resolveIncludeSource=false - If specified, resolved links will include the hash of the link at the root of the metadata
|
|
375
|
-
Example:
|
|
376
|
-
{
|
|
377
|
-
"resolved-link": {
|
|
378
|
-
".": {
|
|
379
|
-
"source": "hq__HPXNia6UtXyuUr6G3Lih8PyUhvYYHuyLTt3i7qSfYgYBB7sF1suR7ky7YRXsUARUrTB1Um1x5a"
|
|
380
|
-
},
|
|
381
|
-
"public": {
|
|
382
|
-
"name": "My Linked Object",
|
|
383
|
-
}
|
|
384
|
-
...
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
* @param {boolean=} resolveIgnoreErrors=false - If specified, link errors within the requested metadata will not cause the entire response to result in an error
|
|
388
|
-
* @param {number=} linkDepthLimit=1 - Limit link resolution to the specified depth. Default link depth is 1 (only links directly in the object's metadata will be resolved)
|
|
389
|
-
*
|
|
390
|
-
* @return {Promise<Object|string>}
|
|
391
|
-
*/
|
|
392
|
-
}, {
|
|
393
|
-
key: "PublicUserMetadata",
|
|
394
|
-
value: function () {
|
|
395
|
-
var _PublicUserMetadata = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref4) {
|
|
396
|
-
var address, _ref4$metadataSubtree, metadataSubtree, _ref4$queryParams, queryParams, _ref4$select, select, _ref4$resolveLinks, resolveLinks, _ref4$resolveIncludeS, resolveIncludeSource, _ref4$resolveIgnoreEr, resolveIgnoreErrors, _ref4$linkDepthLimit, linkDepthLimit, walletAddress, _yield$this$UserWalle, libraryId, objectId;
|
|
397
|
-
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
398
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
399
|
-
case 0:
|
|
400
|
-
address = _ref4.address, _ref4$metadataSubtree = _ref4.metadataSubtree, metadataSubtree = _ref4$metadataSubtree === void 0 ? "/" : _ref4$metadataSubtree, _ref4$queryParams = _ref4.queryParams, queryParams = _ref4$queryParams === void 0 ? {} : _ref4$queryParams, _ref4$select = _ref4.select, select = _ref4$select === void 0 ? [] : _ref4$select, _ref4$resolveLinks = _ref4.resolveLinks, resolveLinks = _ref4$resolveLinks === void 0 ? false : _ref4$resolveLinks, _ref4$resolveIncludeS = _ref4.resolveIncludeSource, resolveIncludeSource = _ref4$resolveIncludeS === void 0 ? false : _ref4$resolveIncludeS, _ref4$resolveIgnoreEr = _ref4.resolveIgnoreErrors, resolveIgnoreErrors = _ref4$resolveIgnoreEr === void 0 ? false : _ref4$resolveIgnoreEr, _ref4$linkDepthLimit = _ref4.linkDepthLimit, linkDepthLimit = _ref4$linkDepthLimit === void 0 ? 1 : _ref4$linkDepthLimit;
|
|
401
|
-
if (address) {
|
|
402
|
-
_context5.next = 3;
|
|
403
|
-
break;
|
|
404
|
-
}
|
|
405
|
-
return _context5.abrupt("return");
|
|
406
|
-
case 3:
|
|
407
|
-
_context5.next = 5;
|
|
408
|
-
return this.UserWalletAddress({
|
|
409
|
-
address: address
|
|
410
|
-
});
|
|
411
|
-
case 5:
|
|
412
|
-
walletAddress = _context5.sent;
|
|
413
|
-
if (walletAddress) {
|
|
414
|
-
_context5.next = 8;
|
|
415
|
-
break;
|
|
416
|
-
}
|
|
417
|
-
return _context5.abrupt("return");
|
|
418
|
-
case 8:
|
|
419
|
-
metadataSubtree = UrlJoin("public", metadataSubtree || "/");
|
|
420
|
-
_context5.next = 11;
|
|
421
|
-
return this.UserWalletObjectInfo({
|
|
422
|
-
address: address
|
|
423
|
-
});
|
|
424
|
-
case 11:
|
|
425
|
-
_yield$this$UserWalle = _context5.sent;
|
|
426
|
-
libraryId = _yield$this$UserWalle.libraryId;
|
|
427
|
-
objectId = _yield$this$UserWalle.objectId;
|
|
428
|
-
if (objectId) {
|
|
429
|
-
_context5.next = 16;
|
|
430
|
-
break;
|
|
431
|
-
}
|
|
432
|
-
return _context5.abrupt("return");
|
|
433
|
-
case 16:
|
|
434
|
-
_context5.next = 18;
|
|
435
|
-
return this.client.ContentObjectMetadata({
|
|
436
|
-
libraryId: libraryId,
|
|
437
|
-
objectId: objectId,
|
|
438
|
-
queryParams: queryParams,
|
|
439
|
-
select: select,
|
|
440
|
-
metadataSubtree: metadataSubtree,
|
|
441
|
-
resolveLinks: resolveLinks,
|
|
442
|
-
resolveIncludeSource: resolveIncludeSource,
|
|
443
|
-
resolveIgnoreErrors: resolveIgnoreErrors,
|
|
444
|
-
linkDepthLimit: linkDepthLimit
|
|
445
|
-
});
|
|
446
|
-
case 18:
|
|
447
|
-
return _context5.abrupt("return", _context5.sent);
|
|
448
|
-
case 19:
|
|
449
|
-
case "end":
|
|
450
|
-
return _context5.stop();
|
|
451
|
-
}
|
|
452
|
-
}, _callee5, this);
|
|
453
|
-
}));
|
|
454
|
-
function PublicUserMetadata(_x2) {
|
|
455
|
-
return _PublicUserMetadata.apply(this, arguments);
|
|
456
|
-
}
|
|
457
|
-
return PublicUserMetadata;
|
|
458
|
-
}()
|
|
459
|
-
/**
|
|
460
|
-
* Access the current user's metadata
|
|
461
|
-
*
|
|
462
|
-
* Note: Subject to user's access level
|
|
463
|
-
*
|
|
464
|
-
* @see <a href="#PromptsAndAccessLevels">Prompts and access levels</a>
|
|
465
|
-
*
|
|
466
|
-
* @namedParams
|
|
467
|
-
* @param {string=} metadataSubtree - Subtree of the metadata to retrieve
|
|
468
|
-
* @param {Object=} queryParams={} - Additional query params for the call
|
|
469
|
-
* @param {Array<string>=} select - Limit the returned metadata to the specified attributes
|
|
470
|
-
* - Note: Selection is relative to "metadataSubtree". For example, metadataSubtree="public" and select=["name", "description"] would select "public/name" and "public/description"
|
|
471
|
-
* @param {boolean=} resolveLinks=false - If specified, links in the metadata will be resolved
|
|
472
|
-
* @param {boolean=} resolveIncludeSource=false - If specified, resolved links will include the hash of the link at the root of the metadata
|
|
473
|
-
Example:
|
|
474
|
-
{
|
|
475
|
-
"resolved-link": {
|
|
476
|
-
".": {
|
|
477
|
-
"source": "hq__HPXNia6UtXyuUr6G3Lih8PyUhvYYHuyLTt3i7qSfYgYBB7sF1suR7ky7YRXsUARUrTB1Um1x5a"
|
|
478
|
-
},
|
|
479
|
-
"public": {
|
|
480
|
-
"name": "My Linked Object",
|
|
481
|
-
}
|
|
482
|
-
...
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
* @param {boolean=} resolveIgnoreErrors=false - If specified, link errors within the requested metadata will not cause the entire response to result in an error
|
|
486
|
-
* @param {number=} linkDepthLimit=1 - Limit link resolution to the specified depth. Default link depth is 1 (only links directly in the object's metadata will be resolved)
|
|
487
|
-
*
|
|
488
|
-
* @return {Promise<Object|string>} - The user's profile metadata - returns undefined if no metadata set or subtree doesn't exist
|
|
489
|
-
*/
|
|
490
|
-
}, {
|
|
491
|
-
key: "UserMetadata",
|
|
492
|
-
value: function () {
|
|
493
|
-
var _UserMetadata = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
494
|
-
var _ref5,
|
|
495
|
-
_ref5$metadataSubtree,
|
|
496
|
-
metadataSubtree,
|
|
497
|
-
_ref5$queryParams,
|
|
498
|
-
queryParams,
|
|
499
|
-
_ref5$select,
|
|
500
|
-
select,
|
|
501
|
-
_ref5$resolveLinks,
|
|
502
|
-
resolveLinks,
|
|
503
|
-
_ref5$resolveIncludeS,
|
|
504
|
-
resolveIncludeSource,
|
|
505
|
-
_ref5$resolveIgnoreEr,
|
|
506
|
-
resolveIgnoreErrors,
|
|
507
|
-
_ref5$linkDepthLimit,
|
|
508
|
-
linkDepthLimit,
|
|
509
|
-
_yield$this$UserWalle2,
|
|
510
|
-
libraryId,
|
|
511
|
-
objectId,
|
|
512
|
-
_args6 = arguments;
|
|
513
|
-
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
514
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
515
|
-
case 0:
|
|
516
|
-
_ref5 = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {}, _ref5$metadataSubtree = _ref5.metadataSubtree, metadataSubtree = _ref5$metadataSubtree === void 0 ? "/" : _ref5$metadataSubtree, _ref5$queryParams = _ref5.queryParams, queryParams = _ref5$queryParams === void 0 ? {} : _ref5$queryParams, _ref5$select = _ref5.select, select = _ref5$select === void 0 ? [] : _ref5$select, _ref5$resolveLinks = _ref5.resolveLinks, resolveLinks = _ref5$resolveLinks === void 0 ? false : _ref5$resolveLinks, _ref5$resolveIncludeS = _ref5.resolveIncludeSource, resolveIncludeSource = _ref5$resolveIncludeS === void 0 ? false : _ref5$resolveIncludeS, _ref5$resolveIgnoreEr = _ref5.resolveIgnoreErrors, resolveIgnoreErrors = _ref5$resolveIgnoreEr === void 0 ? false : _ref5$resolveIgnoreEr, _ref5$linkDepthLimit = _ref5.linkDepthLimit, linkDepthLimit = _ref5$linkDepthLimit === void 0 ? 1 : _ref5$linkDepthLimit;
|
|
517
|
-
this.Log("Accessing private user metadata at ".concat(metadataSubtree));
|
|
518
|
-
_context6.next = 4;
|
|
519
|
-
return this.UserWalletObjectInfo();
|
|
520
|
-
case 4:
|
|
521
|
-
_yield$this$UserWalle2 = _context6.sent;
|
|
522
|
-
libraryId = _yield$this$UserWalle2.libraryId;
|
|
523
|
-
objectId = _yield$this$UserWalle2.objectId;
|
|
524
|
-
_context6.next = 9;
|
|
525
|
-
return this.client.ContentObjectMetadata({
|
|
526
|
-
libraryId: libraryId,
|
|
527
|
-
objectId: objectId,
|
|
528
|
-
metadataSubtree: metadataSubtree,
|
|
529
|
-
queryParams: queryParams,
|
|
530
|
-
select: select,
|
|
531
|
-
resolveLinks: resolveLinks,
|
|
532
|
-
resolveIncludeSource: resolveIncludeSource,
|
|
533
|
-
resolveIgnoreErrors: resolveIgnoreErrors,
|
|
534
|
-
linkDepthLimit: linkDepthLimit
|
|
535
|
-
});
|
|
536
|
-
case 9:
|
|
537
|
-
return _context6.abrupt("return", _context6.sent);
|
|
538
|
-
case 10:
|
|
539
|
-
case "end":
|
|
540
|
-
return _context6.stop();
|
|
541
|
-
}
|
|
542
|
-
}, _callee6, this);
|
|
543
|
-
}));
|
|
544
|
-
function UserMetadata() {
|
|
545
|
-
return _UserMetadata.apply(this, arguments);
|
|
546
|
-
}
|
|
547
|
-
return UserMetadata;
|
|
548
|
-
}()
|
|
549
|
-
/**
|
|
550
|
-
* Merge the current user's profile metadata
|
|
551
|
-
*
|
|
552
|
-
* @namedParams
|
|
553
|
-
* @param {Object} metadata - New metadata
|
|
554
|
-
* @param {string=} metadataSubtree - Subtree to merge into - modifies root metadata if not specified
|
|
555
|
-
*/
|
|
556
|
-
}, {
|
|
557
|
-
key: "MergeUserMetadata",
|
|
558
|
-
value: function () {
|
|
559
|
-
var _MergeUserMetadata = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref6) {
|
|
560
|
-
var _ref6$metadataSubtree, metadataSubtree, _ref6$metadata, metadata, _yield$this$UserWalle3, libraryId, objectId, editRequest;
|
|
561
|
-
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
562
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
563
|
-
case 0:
|
|
564
|
-
_ref6$metadataSubtree = _ref6.metadataSubtree, metadataSubtree = _ref6$metadataSubtree === void 0 ? "/" : _ref6$metadataSubtree, _ref6$metadata = _ref6.metadata, metadata = _ref6$metadata === void 0 ? {} : _ref6$metadata;
|
|
565
|
-
this.Log("Merging user metadata at ".concat(metadataSubtree));
|
|
566
|
-
_context7.next = 4;
|
|
567
|
-
return this.UserWalletObjectInfo();
|
|
568
|
-
case 4:
|
|
569
|
-
_yield$this$UserWalle3 = _context7.sent;
|
|
570
|
-
libraryId = _yield$this$UserWalle3.libraryId;
|
|
571
|
-
objectId = _yield$this$UserWalle3.objectId;
|
|
572
|
-
_context7.next = 9;
|
|
573
|
-
return this.client.EditContentObject({
|
|
574
|
-
libraryId: libraryId,
|
|
575
|
-
objectId: objectId
|
|
576
|
-
});
|
|
577
|
-
case 9:
|
|
578
|
-
editRequest = _context7.sent;
|
|
579
|
-
_context7.next = 12;
|
|
580
|
-
return this.client.MergeMetadata({
|
|
581
|
-
libraryId: libraryId,
|
|
582
|
-
objectId: objectId,
|
|
583
|
-
writeToken: editRequest.write_token,
|
|
584
|
-
metadataSubtree: metadataSubtree,
|
|
585
|
-
metadata: metadata
|
|
586
|
-
});
|
|
587
|
-
case 12:
|
|
588
|
-
_context7.next = 14;
|
|
589
|
-
return this.client.FinalizeContentObject({
|
|
590
|
-
libraryId: libraryId,
|
|
591
|
-
objectId: objectId,
|
|
592
|
-
writeToken: editRequest.write_token,
|
|
593
|
-
commitMessage: "Merge user metadata"
|
|
594
|
-
});
|
|
595
|
-
case 14:
|
|
596
|
-
case "end":
|
|
597
|
-
return _context7.stop();
|
|
598
|
-
}
|
|
599
|
-
}, _callee7, this);
|
|
600
|
-
}));
|
|
601
|
-
function MergeUserMetadata(_x3) {
|
|
602
|
-
return _MergeUserMetadata.apply(this, arguments);
|
|
603
|
-
}
|
|
604
|
-
return MergeUserMetadata;
|
|
605
|
-
}()
|
|
606
|
-
/**
|
|
607
|
-
* Replace the current user's profile metadata
|
|
608
|
-
*
|
|
609
|
-
* @namedParams
|
|
610
|
-
* @param {Object} metadata - New metadata
|
|
611
|
-
* @param {string=} metadataSubtree - Subtree to replace - modifies root metadata if not specified
|
|
612
|
-
*/
|
|
613
|
-
}, {
|
|
614
|
-
key: "ReplaceUserMetadata",
|
|
615
|
-
value: function () {
|
|
616
|
-
var _ReplaceUserMetadata = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref7) {
|
|
617
|
-
var _ref7$metadataSubtree, metadataSubtree, _ref7$metadata, metadata, _yield$this$UserWalle4, libraryId, objectId, editRequest;
|
|
618
|
-
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
619
|
-
while (1) switch (_context8.prev = _context8.next) {
|
|
620
|
-
case 0:
|
|
621
|
-
_ref7$metadataSubtree = _ref7.metadataSubtree, metadataSubtree = _ref7$metadataSubtree === void 0 ? "/" : _ref7$metadataSubtree, _ref7$metadata = _ref7.metadata, metadata = _ref7$metadata === void 0 ? {} : _ref7$metadata;
|
|
622
|
-
this.Log("Replacing user metadata at ".concat(metadataSubtree));
|
|
623
|
-
_context8.next = 4;
|
|
624
|
-
return this.UserWalletObjectInfo();
|
|
625
|
-
case 4:
|
|
626
|
-
_yield$this$UserWalle4 = _context8.sent;
|
|
627
|
-
libraryId = _yield$this$UserWalle4.libraryId;
|
|
628
|
-
objectId = _yield$this$UserWalle4.objectId;
|
|
629
|
-
_context8.next = 9;
|
|
630
|
-
return this.client.EditContentObject({
|
|
631
|
-
libraryId: libraryId,
|
|
632
|
-
objectId: objectId
|
|
633
|
-
});
|
|
634
|
-
case 9:
|
|
635
|
-
editRequest = _context8.sent;
|
|
636
|
-
_context8.next = 12;
|
|
637
|
-
return this.client.ReplaceMetadata({
|
|
638
|
-
libraryId: libraryId,
|
|
639
|
-
objectId: objectId,
|
|
640
|
-
writeToken: editRequest.write_token,
|
|
641
|
-
metadataSubtree: metadataSubtree,
|
|
642
|
-
metadata: metadata
|
|
643
|
-
});
|
|
644
|
-
case 12:
|
|
645
|
-
_context8.next = 14;
|
|
646
|
-
return this.client.FinalizeContentObject({
|
|
647
|
-
libraryId: libraryId,
|
|
648
|
-
objectId: objectId,
|
|
649
|
-
writeToken: editRequest.write_token,
|
|
650
|
-
commitMessage: "Replace user metadata"
|
|
651
|
-
});
|
|
652
|
-
case 14:
|
|
653
|
-
case "end":
|
|
654
|
-
return _context8.stop();
|
|
655
|
-
}
|
|
656
|
-
}, _callee8, this);
|
|
657
|
-
}));
|
|
658
|
-
function ReplaceUserMetadata(_x4) {
|
|
659
|
-
return _ReplaceUserMetadata.apply(this, arguments);
|
|
660
|
-
}
|
|
661
|
-
return ReplaceUserMetadata;
|
|
662
|
-
}()
|
|
663
|
-
/**
|
|
664
|
-
* Delete the specified subtree from the users profile metadata
|
|
665
|
-
*
|
|
666
|
-
* @namedParams
|
|
667
|
-
* @param {string=} metadataSubtree - Subtree to delete - deletes all metadata if not specified
|
|
668
|
-
*/
|
|
669
|
-
}, {
|
|
670
|
-
key: "DeleteUserMetadata",
|
|
671
|
-
value: function () {
|
|
672
|
-
var _DeleteUserMetadata = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref8) {
|
|
673
|
-
var _ref8$metadataSubtree, metadataSubtree, _yield$this$UserWalle5, libraryId, objectId, editRequest;
|
|
674
|
-
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
675
|
-
while (1) switch (_context9.prev = _context9.next) {
|
|
676
|
-
case 0:
|
|
677
|
-
_ref8$metadataSubtree = _ref8.metadataSubtree, metadataSubtree = _ref8$metadataSubtree === void 0 ? "/" : _ref8$metadataSubtree;
|
|
678
|
-
this.Log("Deleting user metadata at ".concat(metadataSubtree));
|
|
679
|
-
_context9.next = 4;
|
|
680
|
-
return this.UserWalletObjectInfo();
|
|
681
|
-
case 4:
|
|
682
|
-
_yield$this$UserWalle5 = _context9.sent;
|
|
683
|
-
libraryId = _yield$this$UserWalle5.libraryId;
|
|
684
|
-
objectId = _yield$this$UserWalle5.objectId;
|
|
685
|
-
_context9.next = 9;
|
|
686
|
-
return this.client.EditContentObject({
|
|
687
|
-
libraryId: libraryId,
|
|
688
|
-
objectId: objectId
|
|
689
|
-
});
|
|
690
|
-
case 9:
|
|
691
|
-
editRequest = _context9.sent;
|
|
692
|
-
_context9.next = 12;
|
|
693
|
-
return this.client.DeleteMetadata({
|
|
694
|
-
libraryId: libraryId,
|
|
695
|
-
objectId: objectId,
|
|
696
|
-
writeToken: editRequest.write_token,
|
|
697
|
-
metadataSubtree: metadataSubtree
|
|
698
|
-
});
|
|
699
|
-
case 12:
|
|
700
|
-
_context9.next = 14;
|
|
701
|
-
return this.client.FinalizeContentObject({
|
|
702
|
-
libraryId: libraryId,
|
|
703
|
-
objectId: objectId,
|
|
704
|
-
writeToken: editRequest.write_token,
|
|
705
|
-
commitMessage: "Delete user metadata"
|
|
706
|
-
});
|
|
707
|
-
case 14:
|
|
708
|
-
case "end":
|
|
709
|
-
return _context9.stop();
|
|
710
|
-
}
|
|
711
|
-
}, _callee9, this);
|
|
712
|
-
}));
|
|
713
|
-
function DeleteUserMetadata(_x5) {
|
|
714
|
-
return _DeleteUserMetadata.apply(this, arguments);
|
|
715
|
-
}
|
|
716
|
-
return DeleteUserMetadata;
|
|
717
|
-
}()
|
|
718
|
-
/**
|
|
719
|
-
* Return the permissions the current user allows for apps to access their profile.
|
|
720
|
-
*
|
|
721
|
-
* "private" - No access allowed
|
|
722
|
-
* "prompt" - (default) - When access is requested by an app, the user will be prompted to give permission
|
|
723
|
-
* "public - Public - Any access allowed
|
|
724
|
-
*
|
|
725
|
-
* @return {Promise<string>} - Access setting
|
|
726
|
-
*/
|
|
727
|
-
}, {
|
|
728
|
-
key: "AccessLevel",
|
|
729
|
-
value: function () {
|
|
730
|
-
var _AccessLevel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
|
|
731
|
-
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
732
|
-
while (1) switch (_context10.prev = _context10.next) {
|
|
733
|
-
case 0:
|
|
734
|
-
_context10.next = 2;
|
|
735
|
-
return this.UserMetadata({
|
|
736
|
-
metadataSubtree: "access_level"
|
|
737
|
-
});
|
|
738
|
-
case 2:
|
|
739
|
-
_context10.t0 = _context10.sent;
|
|
740
|
-
if (_context10.t0) {
|
|
741
|
-
_context10.next = 5;
|
|
742
|
-
break;
|
|
743
|
-
}
|
|
744
|
-
_context10.t0 = "prompt";
|
|
745
|
-
case 5:
|
|
746
|
-
return _context10.abrupt("return", _context10.t0);
|
|
747
|
-
case 6:
|
|
748
|
-
case "end":
|
|
749
|
-
return _context10.stop();
|
|
750
|
-
}
|
|
751
|
-
}, _callee10, this);
|
|
752
|
-
}));
|
|
753
|
-
function AccessLevel() {
|
|
754
|
-
return _AccessLevel.apply(this, arguments);
|
|
755
|
-
}
|
|
756
|
-
return AccessLevel;
|
|
757
|
-
}()
|
|
758
|
-
/**
|
|
759
|
-
* Set the current user's access level.
|
|
760
|
-
*
|
|
761
|
-
* Note: This method is not accessible to applications. Eluvio core will drop the request.
|
|
762
|
-
*
|
|
763
|
-
* @namedParams
|
|
764
|
-
* @param level
|
|
765
|
-
*/
|
|
766
|
-
}, {
|
|
767
|
-
key: "SetAccessLevel",
|
|
768
|
-
value: function () {
|
|
769
|
-
var _SetAccessLevel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref9) {
|
|
770
|
-
var level;
|
|
771
|
-
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
772
|
-
while (1) switch (_context11.prev = _context11.next) {
|
|
773
|
-
case 0:
|
|
774
|
-
level = _ref9.level;
|
|
775
|
-
level = level.toLowerCase();
|
|
776
|
-
if (["private", "prompt", "public"].includes(level)) {
|
|
777
|
-
_context11.next = 4;
|
|
778
|
-
break;
|
|
779
|
-
}
|
|
780
|
-
throw new Error("Invalid access level: " + level);
|
|
781
|
-
case 4:
|
|
782
|
-
_context11.next = 6;
|
|
783
|
-
return this.ReplaceUserMetadata({
|
|
784
|
-
metadataSubtree: "access_level",
|
|
785
|
-
metadata: level
|
|
786
|
-
});
|
|
787
|
-
case 6:
|
|
788
|
-
case "end":
|
|
789
|
-
return _context11.stop();
|
|
790
|
-
}
|
|
791
|
-
}, _callee11, this);
|
|
792
|
-
}));
|
|
793
|
-
function SetAccessLevel(_x6) {
|
|
794
|
-
return _SetAccessLevel.apply(this, arguments);
|
|
795
|
-
}
|
|
796
|
-
return SetAccessLevel;
|
|
797
|
-
}()
|
|
798
|
-
/**
|
|
799
|
-
* Return the ID of the tenant admin group set for current user
|
|
800
|
-
*
|
|
801
|
-
* @return {Promise<string>} - Tenant ID
|
|
802
|
-
*/
|
|
803
|
-
}, {
|
|
804
|
-
key: "TenantId",
|
|
805
|
-
value: function () {
|
|
806
|
-
var _TenantId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
|
|
807
|
-
var _yield$this$UserWalle6, objectId;
|
|
808
|
-
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
809
|
-
while (1) switch (_context12.prev = _context12.next) {
|
|
810
|
-
case 0:
|
|
811
|
-
if (this.tenantId) {
|
|
812
|
-
_context12.next = 8;
|
|
813
|
-
break;
|
|
814
|
-
}
|
|
815
|
-
_context12.next = 3;
|
|
816
|
-
return this.UserWalletObjectInfo();
|
|
817
|
-
case 3:
|
|
818
|
-
_yield$this$UserWalle6 = _context12.sent;
|
|
819
|
-
objectId = _yield$this$UserWalle6.objectId;
|
|
820
|
-
_context12.next = 7;
|
|
821
|
-
return this.client.TenantId({
|
|
822
|
-
objectId: objectId
|
|
823
|
-
});
|
|
824
|
-
case 7:
|
|
825
|
-
this.tenantId = _context12.sent;
|
|
826
|
-
case 8:
|
|
827
|
-
return _context12.abrupt("return", this.tenantId);
|
|
828
|
-
case 9:
|
|
829
|
-
case "end":
|
|
830
|
-
return _context12.stop();
|
|
831
|
-
}
|
|
832
|
-
}, _callee12, this);
|
|
833
|
-
}));
|
|
834
|
-
function TenantId() {
|
|
835
|
-
return _TenantId.apply(this, arguments);
|
|
836
|
-
}
|
|
837
|
-
return TenantId;
|
|
838
|
-
}()
|
|
839
|
-
/**
|
|
840
|
-
* Set the current user's tenant admin group ID
|
|
841
|
-
*
|
|
842
|
-
* Note: This method is not accessible to applications. Eluvio core will drop the request.
|
|
843
|
-
*
|
|
844
|
-
* @namedParams
|
|
845
|
-
* @param {string} id - The tenant ID in hash format
|
|
846
|
-
* @param {string} address - The group address to use in the hash if id is not provided
|
|
847
|
-
*/
|
|
848
|
-
}, {
|
|
849
|
-
key: "SetTenantId",
|
|
850
|
-
value: function () {
|
|
851
|
-
var _SetTenantId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref10) {
|
|
852
|
-
var id, address, _yield$this$UserWalle7, objectId, tenantInfo;
|
|
853
|
-
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
854
|
-
while (1) switch (_context13.prev = _context13.next) {
|
|
855
|
-
case 0:
|
|
856
|
-
id = _ref10.id, address = _ref10.address;
|
|
857
|
-
if (!(id && (!id.startsWith("iten") || !Utils.ValidHash(id)))) {
|
|
858
|
-
_context13.next = 3;
|
|
859
|
-
break;
|
|
860
|
-
}
|
|
861
|
-
throw Error("Invalid tenant ID: ".concat(id));
|
|
862
|
-
case 3:
|
|
863
|
-
if (!address) {
|
|
864
|
-
_context13.next = 7;
|
|
865
|
-
break;
|
|
866
|
-
}
|
|
867
|
-
if (Utils.ValidAddress(address)) {
|
|
868
|
-
_context13.next = 6;
|
|
869
|
-
break;
|
|
870
|
-
}
|
|
871
|
-
throw Error("Invalid address: ".concat(address));
|
|
872
|
-
case 6:
|
|
873
|
-
id = "iten".concat(Utils.AddressToHash(address));
|
|
874
|
-
case 7:
|
|
875
|
-
_context13.next = 9;
|
|
876
|
-
return this.UserWalletObjectInfo();
|
|
877
|
-
case 9:
|
|
878
|
-
_yield$this$UserWalle7 = _context13.sent;
|
|
879
|
-
objectId = _yield$this$UserWalle7.objectId;
|
|
880
|
-
_context13.next = 13;
|
|
881
|
-
return this.client.SetTenantId({
|
|
882
|
-
objectId: objectId,
|
|
883
|
-
tenantId: id
|
|
884
|
-
});
|
|
885
|
-
case 13:
|
|
886
|
-
tenantInfo = _context13.sent;
|
|
887
|
-
this.tenantContractId = tenantInfo.tenantContractId;
|
|
888
|
-
this.tenantId = tenantInfo.tenantId;
|
|
889
|
-
case 16:
|
|
890
|
-
case "end":
|
|
891
|
-
return _context13.stop();
|
|
892
|
-
}
|
|
893
|
-
}, _callee13, this);
|
|
894
|
-
}));
|
|
895
|
-
function SetTenantId(_x7) {
|
|
896
|
-
return _SetTenantId.apply(this, arguments);
|
|
897
|
-
}
|
|
898
|
-
return SetTenantId;
|
|
899
|
-
}()
|
|
900
|
-
/**
|
|
901
|
-
* Return the ID of the tenant contract this user belongs to, if set.
|
|
902
|
-
*
|
|
903
|
-
* @return {Promise<string>} - Tenant Contract ID
|
|
904
|
-
*/
|
|
905
|
-
}, {
|
|
906
|
-
key: "TenantContractId",
|
|
907
|
-
value: function () {
|
|
908
|
-
var _TenantContractId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
|
|
909
|
-
var _yield$this$UserWalle8, objectId;
|
|
910
|
-
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
911
|
-
while (1) switch (_context14.prev = _context14.next) {
|
|
912
|
-
case 0:
|
|
913
|
-
if (this.tenantContractId) {
|
|
914
|
-
_context14.next = 8;
|
|
915
|
-
break;
|
|
916
|
-
}
|
|
917
|
-
_context14.next = 3;
|
|
918
|
-
return this.UserWalletObjectInfo();
|
|
919
|
-
case 3:
|
|
920
|
-
_yield$this$UserWalle8 = _context14.sent;
|
|
921
|
-
objectId = _yield$this$UserWalle8.objectId;
|
|
922
|
-
_context14.next = 7;
|
|
923
|
-
return this.client.TenantContractId({
|
|
924
|
-
objectId: objectId
|
|
925
|
-
});
|
|
926
|
-
case 7:
|
|
927
|
-
this.tenantContractId = _context14.sent;
|
|
928
|
-
case 8:
|
|
929
|
-
return _context14.abrupt("return", this.tenantContractId);
|
|
930
|
-
case 9:
|
|
931
|
-
case "end":
|
|
932
|
-
return _context14.stop();
|
|
933
|
-
}
|
|
934
|
-
}, _callee14, this);
|
|
935
|
-
}));
|
|
936
|
-
function TenantContractId() {
|
|
937
|
-
return _TenantContractId.apply(this, arguments);
|
|
938
|
-
}
|
|
939
|
-
return TenantContractId;
|
|
940
|
-
}()
|
|
941
|
-
/**
|
|
942
|
-
* Set the current user's tenant contract.
|
|
943
|
-
*
|
|
944
|
-
* Note: This method is not accessible to applications. Eluvio core will drop the request.
|
|
945
|
-
*
|
|
946
|
-
* @namedParams
|
|
947
|
-
* @param {string} tenantContractId - The tenant contract ID in hash format
|
|
948
|
-
* @param {string} address - The tenant address to use in the hash if id is not provided
|
|
949
|
-
*/
|
|
950
|
-
}, {
|
|
951
|
-
key: "SetTenantContractId",
|
|
952
|
-
value: function () {
|
|
953
|
-
var _SetTenantContractId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref11) {
|
|
954
|
-
var tenantContractId, _yield$this$UserWalle9, objectId, tenantInfo;
|
|
955
|
-
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
956
|
-
while (1) switch (_context15.prev = _context15.next) {
|
|
957
|
-
case 0:
|
|
958
|
-
tenantContractId = _ref11.tenantContractId;
|
|
959
|
-
_context15.next = 3;
|
|
960
|
-
return this.UserWalletObjectInfo();
|
|
961
|
-
case 3:
|
|
962
|
-
_yield$this$UserWalle9 = _context15.sent;
|
|
963
|
-
objectId = _yield$this$UserWalle9.objectId;
|
|
964
|
-
_context15.next = 7;
|
|
965
|
-
return this.client.SetTenantContractId({
|
|
966
|
-
objectId: objectId,
|
|
967
|
-
tenantContractId: tenantContractId
|
|
968
|
-
});
|
|
969
|
-
case 7:
|
|
970
|
-
tenantInfo = _context15.sent;
|
|
971
|
-
this.tenantContractId = tenantInfo.tenantContractId;
|
|
972
|
-
this.tenantId = tenantInfo.tenantId;
|
|
973
|
-
case 10:
|
|
974
|
-
case "end":
|
|
975
|
-
return _context15.stop();
|
|
976
|
-
}
|
|
977
|
-
}, _callee15, this);
|
|
978
|
-
}));
|
|
979
|
-
function SetTenantContractId(_x8) {
|
|
980
|
-
return _SetTenantContractId.apply(this, arguments);
|
|
981
|
-
}
|
|
982
|
-
return SetTenantContractId;
|
|
983
|
-
}()
|
|
984
|
-
}, {
|
|
985
|
-
key: "ResetTenantId",
|
|
986
|
-
value: function () {
|
|
987
|
-
var _ResetTenantId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16() {
|
|
988
|
-
var _yield$this$UserWalle10, objectId;
|
|
989
|
-
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
990
|
-
while (1) switch (_context16.prev = _context16.next) {
|
|
991
|
-
case 0:
|
|
992
|
-
_context16.next = 2;
|
|
993
|
-
return this.UserWalletObjectInfo();
|
|
994
|
-
case 2:
|
|
995
|
-
_yield$this$UserWalle10 = _context16.sent;
|
|
996
|
-
objectId = _yield$this$UserWalle10.objectId;
|
|
997
|
-
_context16.next = 6;
|
|
998
|
-
return this.client.ResetTenantId({
|
|
999
|
-
objectId: objectId
|
|
1000
|
-
});
|
|
1001
|
-
case 6:
|
|
1002
|
-
this.tenantId = this.client.TenantId({
|
|
1003
|
-
objectId: objectId
|
|
1004
|
-
});
|
|
1005
|
-
this.tenantContractId = this.client.TenantContractId({
|
|
1006
|
-
objectId: objectId
|
|
1007
|
-
});
|
|
1008
|
-
case 8:
|
|
1009
|
-
case "end":
|
|
1010
|
-
return _context16.stop();
|
|
1011
|
-
}
|
|
1012
|
-
}, _callee16, this);
|
|
1013
|
-
}));
|
|
1014
|
-
function ResetTenantId() {
|
|
1015
|
-
return _ResetTenantId.apply(this, arguments);
|
|
1016
|
-
}
|
|
1017
|
-
return ResetTenantId;
|
|
1018
|
-
}()
|
|
1019
|
-
/**
|
|
1020
|
-
* Get the URL of the current user's profile image
|
|
1021
|
-
*
|
|
1022
|
-
* Note: Part hash of profile image will be appended to the URL as a query parameter to invalidate
|
|
1023
|
-
* browser caching when the image is updated
|
|
1024
|
-
*
|
|
1025
|
-
* @namedParams
|
|
1026
|
-
* @param {string=} address - The address of the user. If not specified, the address of the current user will be used.
|
|
1027
|
-
* @param {number=} height - If specified, the image will be scaled to the specified maximum height
|
|
1028
|
-
*
|
|
1029
|
-
* @see <a href="Utils.html#.ResizeImage">Utils#ResizeImage</a>
|
|
1030
|
-
*
|
|
1031
|
-
* @return {Promise<string | undefined>} - URL of the user's profile image. Will be undefined if no profile image is set.
|
|
1032
|
-
*/
|
|
1033
|
-
}, {
|
|
1034
|
-
key: "UserProfileImage",
|
|
1035
|
-
value: function () {
|
|
1036
|
-
var _UserProfileImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17() {
|
|
1037
|
-
var _ref12,
|
|
1038
|
-
address,
|
|
1039
|
-
height,
|
|
1040
|
-
walletAddress,
|
|
1041
|
-
_yield$this$UserWalle11,
|
|
1042
|
-
libraryId,
|
|
1043
|
-
objectId,
|
|
1044
|
-
_args17 = arguments;
|
|
1045
|
-
return _regeneratorRuntime.wrap(function _callee17$(_context17) {
|
|
1046
|
-
while (1) switch (_context17.prev = _context17.next) {
|
|
1047
|
-
case 0:
|
|
1048
|
-
_ref12 = _args17.length > 0 && _args17[0] !== undefined ? _args17[0] : {}, address = _ref12.address, height = _ref12.height;
|
|
1049
|
-
if (!address) {
|
|
1050
|
-
_context17.next = 7;
|
|
1051
|
-
break;
|
|
1052
|
-
}
|
|
1053
|
-
_context17.next = 4;
|
|
1054
|
-
return this.UserWalletAddress({
|
|
1055
|
-
address: address
|
|
1056
|
-
});
|
|
1057
|
-
case 4:
|
|
1058
|
-
walletAddress = _context17.sent;
|
|
1059
|
-
_context17.next = 9;
|
|
1060
|
-
break;
|
|
1061
|
-
case 7:
|
|
1062
|
-
address = this.client.signer.address;
|
|
1063
|
-
walletAddress = this.walletAddress;
|
|
1064
|
-
case 9:
|
|
1065
|
-
if (walletAddress) {
|
|
1066
|
-
_context17.next = 11;
|
|
1067
|
-
break;
|
|
1068
|
-
}
|
|
1069
|
-
return _context17.abrupt("return");
|
|
1070
|
-
case 11:
|
|
1071
|
-
_context17.next = 13;
|
|
1072
|
-
return this.UserWalletObjectInfo({
|
|
1073
|
-
address: address
|
|
1074
|
-
});
|
|
1075
|
-
case 13:
|
|
1076
|
-
_yield$this$UserWalle11 = _context17.sent;
|
|
1077
|
-
libraryId = _yield$this$UserWalle11.libraryId;
|
|
1078
|
-
objectId = _yield$this$UserWalle11.objectId;
|
|
1079
|
-
return _context17.abrupt("return", this.client.ContentObjectImageUrl({
|
|
1080
|
-
libraryId: libraryId,
|
|
1081
|
-
objectId: objectId,
|
|
1082
|
-
height: height,
|
|
1083
|
-
imagePath: "public/profile_image"
|
|
1084
|
-
}));
|
|
1085
|
-
case 17:
|
|
1086
|
-
case "end":
|
|
1087
|
-
return _context17.stop();
|
|
1088
|
-
}
|
|
1089
|
-
}, _callee17, this);
|
|
1090
|
-
}));
|
|
1091
|
-
function UserProfileImage() {
|
|
1092
|
-
return _UserProfileImage.apply(this, arguments);
|
|
1093
|
-
}
|
|
1094
|
-
return UserProfileImage;
|
|
1095
|
-
}()
|
|
1096
|
-
/**
|
|
1097
|
-
* Set a new profile image for the current user
|
|
1098
|
-
*
|
|
1099
|
-
* @namedParams
|
|
1100
|
-
* @param {blob} image - The new profile image for the current user
|
|
1101
|
-
*/
|
|
1102
|
-
}, {
|
|
1103
|
-
key: "SetUserProfileImage",
|
|
1104
|
-
value: function () {
|
|
1105
|
-
var _SetUserProfileImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref13) {
|
|
1106
|
-
var image, size, _yield$this$UserWalle12, libraryId, objectId, editRequest;
|
|
1107
|
-
return _regeneratorRuntime.wrap(function _callee18$(_context18) {
|
|
1108
|
-
while (1) switch (_context18.prev = _context18.next) {
|
|
1109
|
-
case 0:
|
|
1110
|
-
image = _ref13.image;
|
|
1111
|
-
this.Log("Setting profile image for user ".concat(this.client.signer.address));
|
|
1112
|
-
size = image.length || image.byteLength || image.size;
|
|
1113
|
-
if (!(size > 5000000)) {
|
|
1114
|
-
_context18.next = 5;
|
|
1115
|
-
break;
|
|
1116
|
-
}
|
|
1117
|
-
throw Error("Maximum profile image size is 5MB");
|
|
1118
|
-
case 5:
|
|
1119
|
-
_context18.next = 7;
|
|
1120
|
-
return this.UserWalletObjectInfo();
|
|
1121
|
-
case 7:
|
|
1122
|
-
_yield$this$UserWalle12 = _context18.sent;
|
|
1123
|
-
libraryId = _yield$this$UserWalle12.libraryId;
|
|
1124
|
-
objectId = _yield$this$UserWalle12.objectId;
|
|
1125
|
-
_context18.next = 12;
|
|
1126
|
-
return this.client.EditContentObject({
|
|
1127
|
-
libraryId: libraryId,
|
|
1128
|
-
objectId: objectId
|
|
1129
|
-
});
|
|
1130
|
-
case 12:
|
|
1131
|
-
editRequest = _context18.sent;
|
|
1132
|
-
_context18.next = 15;
|
|
1133
|
-
return this.client.SetContentObjectImage({
|
|
1134
|
-
libraryId: libraryId,
|
|
1135
|
-
objectId: objectId,
|
|
1136
|
-
writeToken: editRequest.write_token,
|
|
1137
|
-
image: image,
|
|
1138
|
-
imageName: "profile_image",
|
|
1139
|
-
imagePath: "public/profile_image"
|
|
1140
|
-
});
|
|
1141
|
-
case 15:
|
|
1142
|
-
_context18.next = 17;
|
|
1143
|
-
return this.client.FinalizeContentObject({
|
|
1144
|
-
libraryId: libraryId,
|
|
1145
|
-
objectId: objectId,
|
|
1146
|
-
writeToken: editRequest.write_token,
|
|
1147
|
-
commitMessage: "Set user profile image"
|
|
1148
|
-
});
|
|
1149
|
-
case 17:
|
|
1150
|
-
case "end":
|
|
1151
|
-
return _context18.stop();
|
|
1152
|
-
}
|
|
1153
|
-
}, _callee18, this);
|
|
1154
|
-
}));
|
|
1155
|
-
function SetUserProfileImage(_x9) {
|
|
1156
|
-
return _SetUserProfileImage.apply(this, arguments);
|
|
1157
|
-
}
|
|
1158
|
-
return SetUserProfileImage;
|
|
1159
|
-
}()
|
|
1160
|
-
/**
|
|
1161
|
-
* Get the accumulated tags for the current user
|
|
1162
|
-
*
|
|
1163
|
-
* Note: Subject to user's access level
|
|
1164
|
-
*
|
|
1165
|
-
* @see <a href="#PromptsAndAccessLevels">Prompts and access levels</a>
|
|
1166
|
-
*
|
|
1167
|
-
* @return {Promise<Object>} - User tags
|
|
1168
|
-
*/
|
|
1169
|
-
}, {
|
|
1170
|
-
key: "CollectedTags",
|
|
1171
|
-
value: function () {
|
|
1172
|
-
var _CollectedTags = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19() {
|
|
1173
|
-
return _regeneratorRuntime.wrap(function _callee19$(_context19) {
|
|
1174
|
-
while (1) switch (_context19.prev = _context19.next) {
|
|
1175
|
-
case 0:
|
|
1176
|
-
_context19.next = 2;
|
|
1177
|
-
return this.UserMetadata({
|
|
1178
|
-
metadataSubtree: "collected_data"
|
|
1179
|
-
});
|
|
1180
|
-
case 2:
|
|
1181
|
-
_context19.t0 = _context19.sent;
|
|
1182
|
-
if (_context19.t0) {
|
|
1183
|
-
_context19.next = 5;
|
|
1184
|
-
break;
|
|
1185
|
-
}
|
|
1186
|
-
_context19.t0 = {};
|
|
1187
|
-
case 5:
|
|
1188
|
-
return _context19.abrupt("return", _context19.t0);
|
|
1189
|
-
case 6:
|
|
1190
|
-
case "end":
|
|
1191
|
-
return _context19.stop();
|
|
1192
|
-
}
|
|
1193
|
-
}, _callee19, this);
|
|
1194
|
-
}));
|
|
1195
|
-
function CollectedTags() {
|
|
1196
|
-
return _CollectedTags.apply(this, arguments);
|
|
1197
|
-
}
|
|
1198
|
-
return CollectedTags;
|
|
1199
|
-
}() // Ensure recording tags never causes action to fail
|
|
1200
|
-
}, {
|
|
1201
|
-
key: "RecordTags",
|
|
1202
|
-
value: function () {
|
|
1203
|
-
var _RecordTags = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(_ref14) {
|
|
1204
|
-
var libraryId, objectId, versionHash;
|
|
1205
|
-
return _regeneratorRuntime.wrap(function _callee20$(_context20) {
|
|
1206
|
-
while (1) switch (_context20.prev = _context20.next) {
|
|
1207
|
-
case 0:
|
|
1208
|
-
libraryId = _ref14.libraryId, objectId = _ref14.objectId, versionHash = _ref14.versionHash;
|
|
1209
|
-
_context20.prev = 1;
|
|
1210
|
-
_context20.next = 4;
|
|
1211
|
-
return this.__RecordTags({
|
|
1212
|
-
libraryId: libraryId,
|
|
1213
|
-
objectId: objectId,
|
|
1214
|
-
versionHash: versionHash
|
|
1215
|
-
});
|
|
1216
|
-
case 4:
|
|
1217
|
-
_context20.next = 9;
|
|
1218
|
-
break;
|
|
1219
|
-
case 6:
|
|
1220
|
-
_context20.prev = 6;
|
|
1221
|
-
_context20.t0 = _context20["catch"](1);
|
|
1222
|
-
// eslint-disable-next-line no-console
|
|
1223
|
-
console.error(_context20.t0);
|
|
1224
|
-
case 9:
|
|
1225
|
-
case "end":
|
|
1226
|
-
return _context20.stop();
|
|
1227
|
-
}
|
|
1228
|
-
}, _callee20, this, [[1, 6]]);
|
|
1229
|
-
}));
|
|
1230
|
-
function RecordTags(_x10) {
|
|
1231
|
-
return _RecordTags.apply(this, arguments);
|
|
1232
|
-
}
|
|
1233
|
-
return RecordTags;
|
|
1234
|
-
}()
|
|
1235
|
-
}, {
|
|
1236
|
-
key: "__RecordTags",
|
|
1237
|
-
value: function () {
|
|
1238
|
-
var _RecordTags2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(_ref15) {
|
|
1239
|
-
var libraryId, objectId, versionHash, accessType, seen, walletObjectInfo, userLibraryId, userObjectId, editRequest, contentTags, userTags, formattedTags;
|
|
1240
|
-
return _regeneratorRuntime.wrap(function _callee21$(_context21) {
|
|
1241
|
-
while (1) switch (_context21.prev = _context21.next) {
|
|
1242
|
-
case 0:
|
|
1243
|
-
libraryId = _ref15.libraryId, objectId = _ref15.objectId, versionHash = _ref15.versionHash;
|
|
1244
|
-
_context21.next = 3;
|
|
1245
|
-
return this.client.AccessType({
|
|
1246
|
-
id: objectId
|
|
1247
|
-
});
|
|
1248
|
-
case 3:
|
|
1249
|
-
accessType = _context21.sent;
|
|
1250
|
-
if (!(accessType !== "object")) {
|
|
1251
|
-
_context21.next = 6;
|
|
1252
|
-
break;
|
|
1253
|
-
}
|
|
1254
|
-
return _context21.abrupt("return");
|
|
1255
|
-
case 6:
|
|
1256
|
-
if (!(!versionHash && !libraryId)) {
|
|
1257
|
-
_context21.next = 10;
|
|
1258
|
-
break;
|
|
1259
|
-
}
|
|
1260
|
-
_context21.next = 9;
|
|
1261
|
-
return this.client.ContentObjectLibraryId({
|
|
1262
|
-
objectId: objectId
|
|
1263
|
-
});
|
|
1264
|
-
case 9:
|
|
1265
|
-
libraryId = _context21.sent;
|
|
1266
|
-
case 10:
|
|
1267
|
-
if (versionHash) {
|
|
1268
|
-
_context21.next = 14;
|
|
1269
|
-
break;
|
|
1270
|
-
}
|
|
1271
|
-
_context21.next = 13;
|
|
1272
|
-
return this.client.ContentObject({
|
|
1273
|
-
libraryId: libraryId,
|
|
1274
|
-
objectId: objectId
|
|
1275
|
-
});
|
|
1276
|
-
case 13:
|
|
1277
|
-
versionHash = _context21.sent.hash;
|
|
1278
|
-
case 14:
|
|
1279
|
-
_context21.next = 16;
|
|
1280
|
-
return this.UserMetadata({
|
|
1281
|
-
metadataSubtree: UrlJoin("accessed_content", versionHash)
|
|
1282
|
-
});
|
|
1283
|
-
case 16:
|
|
1284
|
-
seen = _context21.sent;
|
|
1285
|
-
if (!seen) {
|
|
1286
|
-
_context21.next = 19;
|
|
1287
|
-
break;
|
|
1288
|
-
}
|
|
1289
|
-
return _context21.abrupt("return");
|
|
1290
|
-
case 19:
|
|
1291
|
-
_context21.next = 21;
|
|
1292
|
-
return this.UserWalletObjectInfo();
|
|
1293
|
-
case 21:
|
|
1294
|
-
walletObjectInfo = _context21.sent;
|
|
1295
|
-
userLibraryId = walletObjectInfo.libraryId;
|
|
1296
|
-
userObjectId = walletObjectInfo.objectId; // Mark content as seen
|
|
1297
|
-
_context21.next = 26;
|
|
1298
|
-
return this.client.EditContentObject({
|
|
1299
|
-
libraryId: userLibraryId,
|
|
1300
|
-
objectId: userObjectId
|
|
1301
|
-
});
|
|
1302
|
-
case 26:
|
|
1303
|
-
editRequest = _context21.sent;
|
|
1304
|
-
_context21.next = 29;
|
|
1305
|
-
return this.client.ReplaceMetadata({
|
|
1306
|
-
libraryId: userLibraryId,
|
|
1307
|
-
objectId: userObjectId,
|
|
1308
|
-
writeToken: editRequest.write_token,
|
|
1309
|
-
metadataSubtree: UrlJoin("accessed_content", versionHash),
|
|
1310
|
-
metadata: Date.now()
|
|
1311
|
-
});
|
|
1312
|
-
case 29:
|
|
1313
|
-
_context21.next = 31;
|
|
1314
|
-
return this.client.ContentObjectMetadata({
|
|
1315
|
-
libraryId: libraryId,
|
|
1316
|
-
objectId: objectId,
|
|
1317
|
-
versionHash: versionHash,
|
|
1318
|
-
metadataSubtree: "video_tags"
|
|
1319
|
-
});
|
|
1320
|
-
case 31:
|
|
1321
|
-
contentTags = _context21.sent;
|
|
1322
|
-
if (!(contentTags && contentTags.length > 0)) {
|
|
1323
|
-
_context21.next = 40;
|
|
1324
|
-
break;
|
|
1325
|
-
}
|
|
1326
|
-
_context21.next = 35;
|
|
1327
|
-
return this.CollectedTags();
|
|
1328
|
-
case 35:
|
|
1329
|
-
userTags = _context21.sent;
|
|
1330
|
-
formattedTags = this.__FormatVideoTags(contentTags);
|
|
1331
|
-
Object.keys(formattedTags).forEach(function (tag) {
|
|
1332
|
-
if (userTags[tag]) {
|
|
1333
|
-
// User has seen this tag before
|
|
1334
|
-
userTags[tag].occurrences += 1;
|
|
1335
|
-
userTags[tag].aggregate += formattedTags[tag];
|
|
1336
|
-
} else {
|
|
1337
|
-
// New tag
|
|
1338
|
-
userTags[tag] = {
|
|
1339
|
-
occurrences: 1,
|
|
1340
|
-
aggregate: formattedTags[tag]
|
|
1341
|
-
};
|
|
1342
|
-
}
|
|
1343
|
-
});
|
|
1344
|
-
|
|
1345
|
-
// Update user tags
|
|
1346
|
-
_context21.next = 40;
|
|
1347
|
-
return this.client.ReplaceMetadata({
|
|
1348
|
-
libraryId: userLibraryId,
|
|
1349
|
-
objectId: userObjectId,
|
|
1350
|
-
writeToken: editRequest.write_token,
|
|
1351
|
-
metadataSubtree: "collected_data",
|
|
1352
|
-
metadata: userTags
|
|
1353
|
-
});
|
|
1354
|
-
case 40:
|
|
1355
|
-
_context21.next = 42;
|
|
1356
|
-
return this.client.FinalizeContentObject({
|
|
1357
|
-
libraryId: userLibraryId,
|
|
1358
|
-
objectId: userObjectId,
|
|
1359
|
-
writeToken: editRequest.write_token,
|
|
1360
|
-
commitMessage: "Record user tags",
|
|
1361
|
-
awaitCommitConfirmation: false
|
|
1362
|
-
});
|
|
1363
|
-
case 42:
|
|
1364
|
-
case "end":
|
|
1365
|
-
return _context21.stop();
|
|
1366
|
-
}
|
|
1367
|
-
}, _callee21, this);
|
|
1368
|
-
}));
|
|
1369
|
-
function __RecordTags(_x11) {
|
|
1370
|
-
return _RecordTags2.apply(this, arguments);
|
|
1371
|
-
}
|
|
1372
|
-
return __RecordTags;
|
|
1373
|
-
}()
|
|
1374
|
-
/*
|
|
1375
|
-
Format video tags into an easier format and average scores
|
|
1376
|
-
Example content tags:
|
|
1377
|
-
[
|
|
1378
|
-
{
|
|
1379
|
-
"tags": [
|
|
1380
|
-
{
|
|
1381
|
-
"score": 0.3,
|
|
1382
|
-
"tag": "cherry"
|
|
1383
|
-
},
|
|
1384
|
-
{
|
|
1385
|
-
"score": 0.8,
|
|
1386
|
-
"tag": "chocolate"
|
|
1387
|
-
},
|
|
1388
|
-
{
|
|
1389
|
-
"score": 0.6,
|
|
1390
|
-
"tag": "boat"
|
|
1391
|
-
}
|
|
1392
|
-
],
|
|
1393
|
-
"time_in": "00:00:00.000",
|
|
1394
|
-
"time_out": "00:03:00.000"
|
|
1395
|
-
},
|
|
1396
|
-
...
|
|
1397
|
-
]
|
|
1398
|
-
*/
|
|
1399
|
-
}, {
|
|
1400
|
-
key: "__FormatVideoTags",
|
|
1401
|
-
value: function __FormatVideoTags(videoTags) {
|
|
1402
|
-
var collectedTags = {};
|
|
1403
|
-
videoTags.forEach(function (videoTag) {
|
|
1404
|
-
var tags = videoTag["tags"];
|
|
1405
|
-
tags.forEach(function (tag) {
|
|
1406
|
-
if (collectedTags[tag.tag]) {
|
|
1407
|
-
collectedTags[tag.tag].occurrences += 1;
|
|
1408
|
-
collectedTags[tag.tag].aggregate += tag.score;
|
|
1409
|
-
} else {
|
|
1410
|
-
collectedTags[tag.tag] = {
|
|
1411
|
-
occurrences: 1,
|
|
1412
|
-
aggregate: tag.score
|
|
1413
|
-
};
|
|
1414
|
-
}
|
|
1415
|
-
});
|
|
1416
|
-
});
|
|
1417
|
-
var formattedTags = {};
|
|
1418
|
-
Object.keys(collectedTags).forEach(function (tag) {
|
|
1419
|
-
formattedTags[tag] = collectedTags[tag].aggregate / collectedTags[tag].occurrences;
|
|
1420
|
-
});
|
|
1421
|
-
return formattedTags;
|
|
1422
|
-
}
|
|
1423
|
-
|
|
1424
|
-
// List of methods that may require a prompt - these should have an unlimited timeout period
|
|
1425
|
-
}, {
|
|
1426
|
-
key: "PromptedMethods",
|
|
1427
|
-
value: function PromptedMethods() {
|
|
1428
|
-
return FrameClient.PromptedMethods();
|
|
1429
|
-
}
|
|
1430
|
-
|
|
1431
|
-
// List of methods for accessing user metadata - these should be namespaced when used by an app
|
|
1432
|
-
}, {
|
|
1433
|
-
key: "MetadataMethods",
|
|
1434
|
-
value: function MetadataMethods() {
|
|
1435
|
-
return FrameClient.MetadataMethods();
|
|
1436
|
-
}
|
|
1437
|
-
|
|
1438
|
-
// Whitelist of methods allowed to be called using the frame API
|
|
1439
|
-
}, {
|
|
1440
|
-
key: "FrameAllowedMethods",
|
|
1441
|
-
value: function FrameAllowedMethods() {
|
|
1442
|
-
var forbiddenMethods = ["constructor", "FrameAllowedMethods", "Log", "MetadataMethods", "PromptedMethods", "RecordTags", "SetAccessLevel", "SetTenantId", "SetUserProfileImage", "__IsLibraryCreated", "__TouchLibrary", "__FormatVideoTags", "__RecordTags"];
|
|
1443
|
-
return Object.getOwnPropertyNames(Object.getPrototypeOf(this)).filter(function (method) {
|
|
1444
|
-
return !forbiddenMethods.includes(method);
|
|
1445
|
-
});
|
|
1446
|
-
}
|
|
1447
|
-
}]);
|
|
1448
|
-
return UserProfileClient;
|
|
1449
|
-
}();
|
|
1450
|
-
module.exports = UserProfileClient;
|