@eluvio/elv-client-js 4.2.33 → 4.2.36

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.
@@ -11,6 +11,9 @@ var Utils = require("./Utils");
11
11
  var UrlJoin = require("url-join");
12
12
  var _require = require("./LogMessage"),
13
13
  LogMessage = _require.LogMessage;
14
+ var _require2 = require("./Validation"),
15
+ ValidateObject = _require2.ValidateObject,
16
+ ValidateParameters = _require2.ValidateParameters;
14
17
 
15
18
  /*
16
19
  // -- Contract javascript files built using build/BuildContracts.js
@@ -124,63 +127,69 @@ var AuthorizationClient = /*#__PURE__*/function () {
124
127
  if (versionHash) {
125
128
  objectId = this.client.utils.DecodeVersionHash(versionHash).objectId;
126
129
  }
130
+ if (!(update && !objectId)) {
131
+ _context2.next = 4;
132
+ break;
133
+ }
134
+ throw Error("An objectId or versionHash is required when 'update' is true");
135
+ case 4:
127
136
  _context2.t0 = objectId && this.client.signer && !this.client.signer.anonymous;
128
137
  if (!_context2.t0) {
129
- _context2.next = 10;
138
+ _context2.next = 12;
130
139
  break;
131
140
  }
132
141
  _context2.t1 = this.client.utils;
133
- _context2.next = 7;
142
+ _context2.next = 9;
134
143
  return this.client.userProfileClient.WalletAddress(false);
135
- case 7:
144
+ case 9:
136
145
  _context2.t2 = _context2.sent;
137
146
  _context2.t3 = this.client.utils.HashToAddress(objectId);
138
147
  _context2.t0 = _context2.t1.EqualAddress.call(_context2.t1, _context2.t2, _context2.t3);
139
- case 10:
148
+ case 12:
140
149
  isWalletRequest = _context2.t0;
141
150
  if (!(this.client.staticToken && !isWalletRequest && !update)) {
142
- _context2.next = 15;
151
+ _context2.next = 17;
143
152
  break;
144
153
  }
145
154
  return _context2.abrupt("return", this.client.staticToken);
146
- case 15:
155
+ case 17:
147
156
  if (!(this.client.staticUpdateToken && !isWalletRequest)) {
148
- _context2.next = 17;
157
+ _context2.next = 19;
149
158
  break;
150
159
  }
151
160
  return _context2.abrupt("return", this.client.staticUpdateToken);
152
- case 17:
161
+ case 19:
153
162
  initialNoCache = this.noCache;
154
- _context2.prev = 18;
163
+ _context2.prev = 20;
155
164
  // noCache enabled for this call
156
165
  if (noCache && !this.noCache) {
157
166
  this.noCache = true;
158
167
  }
159
168
  if (!(channelAuth && this.client.signer)) {
160
- _context2.next = 28;
169
+ _context2.next = 30;
161
170
  break;
162
171
  }
163
172
  _context2.t4 = Utils;
164
- _context2.next = 24;
173
+ _context2.next = 26;
165
174
  return this.client.GetBalance({
166
175
  address: this.client.CurrentAccountAddress()
167
176
  });
168
- case 24:
177
+ case 26:
169
178
  _context2.t5 = _context2.sent;
170
179
  balance = _context2.t4.ToBigNumber.call(_context2.t4, _context2.t5).toFixed(3);
171
180
  if (!(balance < 0.02)) {
172
- _context2.next = 28;
181
+ _context2.next = 30;
173
182
  break;
174
183
  }
175
184
  return _context2.abrupt("return", this.client.CreateFabricToken({
176
185
  context: context
177
186
  }));
178
- case 28:
187
+ case 30:
179
188
  if (!channelAuth) {
180
- _context2.next = 34;
189
+ _context2.next = 36;
181
190
  break;
182
191
  }
183
- _context2.next = 31;
192
+ _context2.next = 33;
184
193
  return this.GenerateChannelContentToken({
185
194
  objectId: objectId,
186
195
  versionHash: versionHash,
@@ -188,20 +197,20 @@ var AuthorizationClient = /*#__PURE__*/function () {
188
197
  context: context,
189
198
  oauthToken: oauthToken
190
199
  });
191
- case 31:
200
+ case 33:
192
201
  authorizationToken = _context2.sent;
193
- _context2.next = 39;
202
+ _context2.next = 41;
194
203
  break;
195
- case 34:
204
+ case 36:
196
205
  if (!(noAuth && this.client.signer && this.client.signer.remoteSigner && this.client.signer.unsignedPublicAuth)) {
197
- _context2.next = 36;
206
+ _context2.next = 38;
198
207
  break;
199
208
  }
200
209
  return _context2.abrupt("return", this.client.CreateStaticToken({
201
210
  libraryId: libraryId
202
211
  }));
203
- case 36:
204
- _context2.next = 38;
212
+ case 38:
213
+ _context2.next = 40;
205
214
  return this.GenerateAuthorizationToken({
206
215
  libraryId: libraryId,
207
216
  objectId: objectId,
@@ -211,23 +220,23 @@ var AuthorizationClient = /*#__PURE__*/function () {
211
220
  update: update,
212
221
  makeAccessRequest: makeAccessRequest
213
222
  });
214
- case 38:
223
+ case 40:
215
224
  authorizationToken = _context2.sent;
216
- case 39:
225
+ case 41:
217
226
  return _context2.abrupt("return", authorizationToken);
218
- case 42:
219
- _context2.prev = 42;
220
- _context2.t6 = _context2["catch"](18);
227
+ case 44:
228
+ _context2.prev = 44;
229
+ _context2.t6 = _context2["catch"](20);
221
230
  throw _context2.t6;
222
- case 45:
223
- _context2.prev = 45;
231
+ case 47:
232
+ _context2.prev = 47;
224
233
  this.noCache = initialNoCache;
225
- return _context2.finish(45);
226
- case 48:
234
+ return _context2.finish(47);
235
+ case 50:
227
236
  case "end":
228
237
  return _context2.stop();
229
238
  }
230
- }, _callee2, this, [[18, 42, 45, 48]]);
239
+ }, _callee2, this, [[20, 44, 47, 50]]);
231
240
  }));
232
241
  function AuthorizationToken(_x2) {
233
242
  return _AuthorizationToken.apply(this, arguments);