@eluvio/elv-client-js 4.0.114 → 4.0.116

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 +68 -0
  2. package/dist/ElvClient-node-min.js +67 -0
  3. package/dist/ElvFrameClient-min.js +60 -0
  4. package/dist/ElvPermissionsClient-min.js +60 -0
  5. package/dist/ElvWalletClient-min.js +68 -0
  6. package/dist/ElvWalletClient-node-min.js +67 -0
  7. package/dist/src/AuthorizationClient.js +2166 -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 +2063 -0
  12. package/dist/src/ElvWallet.js +247 -0
  13. package/dist/src/EthClient.js +1153 -0
  14. package/dist/src/FrameClient.js +484 -0
  15. package/dist/src/HttpClient.js +314 -0
  16. package/dist/src/Id.js +20 -0
  17. package/dist/src/LogMessage.js +25 -0
  18. package/dist/src/PermissionsClient.js +1556 -0
  19. package/dist/src/RemoteSigner.js +383 -0
  20. package/dist/src/UserProfileClient.js +1465 -0
  21. package/dist/src/Utils.js +893 -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 +5202 -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 +567 -0
  32. package/dist/src/client/LiveStream.js +2638 -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 +2109 -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 +20 -2
  128. package/src/client/LiveConf.js +10 -8
  129. package/src/client/LiveStream.js +6 -4
@@ -0,0 +1,2063 @@
1
+ var _toConsumableArray = require("@babel/runtime/helpers/toConsumableArray");
2
+ var _typeof = require("@babel/runtime/helpers/typeof");
3
+ var _defineProperty = require("@babel/runtime/helpers/defineProperty");
4
+ var _regeneratorRuntime = require("@babel/runtime/regenerator");
5
+ var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
6
+ var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
7
+ var _createClass = require("@babel/runtime/helpers/createClass");
8
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10
+ if (typeof globalThis.Buffer === "undefined") {
11
+ globalThis.Buffer = require("buffer/").Buffer;
12
+ }
13
+ var URI = require("urijs");
14
+ var Ethers = require("ethers");
15
+ var AuthorizationClient = require("./AuthorizationClient");
16
+ var ElvWallet = require("./ElvWallet");
17
+ var EthClient = require("./EthClient");
18
+ var UserProfileClient = require("./UserProfileClient");
19
+ var HttpClient = require("./HttpClient");
20
+ var RemoteSigner = require("./RemoteSigner");
21
+ var Utils = require("./Utils");
22
+ var Crypto = require("./Crypto");
23
+ var _require = require("./LogMessage"),
24
+ LogMessage = _require.LogMessage;
25
+ var Pako = require("pako");
26
+ var _require2 = require("./Validation"),
27
+ ValidatePresence = _require2.ValidatePresence;
28
+ var UrlJoin = require("url-join");
29
+ var networks = {
30
+ "main": "https://main.net955305.contentfabric.io",
31
+ "demo": "https://demov3.net955210.contentfabric.io",
32
+ "demov3": "https://demov3.net955210.contentfabric.io",
33
+ "local": "http://127.0.0.1:8008/config?qspace=dev&self",
34
+ "test": "https://test.net955203.contentfabric.io"
35
+ };
36
+ if (Utils.Platform() === Utils.PLATFORM_NODE) {
37
+ // Define Response in node
38
+ // eslint-disable-next-line no-global-assign
39
+ globalThis.Response = require("node-fetch").Response;
40
+ }
41
+
42
+ /**
43
+ * See the Modules section on the sidebar for details about methods related to interacting with the Fabric.
44
+ *
45
+ * <br/>
46
+ *
47
+ * For information about the Eluvio Wallet Client, go <a href="wallet-client/index.html">here</a>.
48
+ */
49
+ var ElvClient = /*#__PURE__*/function () {
50
+ "use strict";
51
+
52
+ /**
53
+ * Create a new ElvClient
54
+ *
55
+ * NOTE: It is highly recommended to use the <a href="#.FromConfigurationUrl">FromConfigurationUrl</a> or <a href="#.FromNetworkName">FromNetworkName</a> method
56
+ * automatically import the client settings from the fabric
57
+ *
58
+ * @constructor
59
+ *
60
+ * @namedParams
61
+ * @param {string} contentSpaceId - ID of the content space
62
+ * @param {string} networkId - ID of the blockchain network
63
+ * @param {string} networkName - Name of the blockchain network
64
+ * @param {number} fabricVersion - The version of the target content fabric
65
+ * @param {Array<string>} fabricURIs - A list of full URIs to content fabric nodes
66
+ * @param {Array<string>} ethereumURIs - A list of full URIs to ethereum nodes
67
+ * @param {Array<string>} authServiceURIs - A list of full URIs to auth service endpoints
68
+ * @param {Array<string>} fileServiceURIs - A list of full URIs to file service endpoints
69
+ * @param {Array<string>=} searchURIs - A list of full URIs to search service endpoints
70
+ * @param {number=} ethereumContractTimeout=10 - Number of seconds to wait for contract calls
71
+ * @param {string=} trustAuthorityId - (OAuth) The ID of the trust authority to use for OAuth authentication
72
+ * @param {string=} staticToken - Static token that will be used for all authorization in place of normal auth. Also known as an anonymous token containing the space
73
+ * @param {boolean=} noCache=false - If enabled, blockchain transactions will not be cached
74
+ * @param {boolean=} noAuth=false - If enabled, blockchain authorization will not be performed
75
+ * @param {boolean=} assumeV3=false - If enabled, V3 fabric will be assumed
76
+ * @param {string=} service=default - The mode that determines how HttpClient will be initialized.
77
+ * If 'default' is set, HttpClient uris will use fabricUris. If 'search' is used, searchUris will be used
78
+ *
79
+ * @return {ElvClient} - New ElvClient connected to the specified content fabric and blockchain
80
+ */
81
+ function ElvClient(_ref) {
82
+ var contentSpaceId = _ref.contentSpaceId,
83
+ networkId = _ref.networkId,
84
+ networkName = _ref.networkName,
85
+ fabricVersion = _ref.fabricVersion,
86
+ fabricURIs = _ref.fabricURIs,
87
+ ethereumURIs = _ref.ethereumURIs,
88
+ authServiceURIs = _ref.authServiceURIs,
89
+ fileServiceURIs = _ref.fileServiceURIs,
90
+ searchURIs = _ref.searchURIs,
91
+ _ref$ethereumContract = _ref.ethereumContractTimeout,
92
+ ethereumContractTimeout = _ref$ethereumContract === void 0 ? 10 : _ref$ethereumContract,
93
+ trustAuthorityId = _ref.trustAuthorityId,
94
+ staticToken = _ref.staticToken,
95
+ _ref$noCache = _ref.noCache,
96
+ noCache = _ref$noCache === void 0 ? false : _ref$noCache,
97
+ _ref$noAuth = _ref.noAuth,
98
+ noAuth = _ref$noAuth === void 0 ? false : _ref$noAuth,
99
+ _ref$assumeV = _ref.assumeV3,
100
+ assumeV3 = _ref$assumeV === void 0 ? false : _ref$assumeV,
101
+ _ref$service = _ref.service,
102
+ service = _ref$service === void 0 ? "default" : _ref$service;
103
+ _classCallCheck(this, ElvClient);
104
+ this.Configuration = ElvClient.Configuration;
105
+ this.utils = Utils;
106
+ this.contentSpaceId = contentSpaceId;
107
+ this.contentSpaceAddress = this.utils.HashToAddress(contentSpaceId);
108
+ this.contentSpaceLibraryId = this.utils.AddressToLibraryId(this.contentSpaceAddress);
109
+ this.contentSpaceObjectId = this.utils.AddressToObjectId(this.contentSpaceAddress);
110
+ this.networkId = networkId;
111
+ this.networkName = networkName;
112
+ this.fabricVersion = fabricVersion;
113
+ this.fabricURIs = fabricURIs;
114
+ this.authServiceURIs = authServiceURIs;
115
+ this.fileServiceURIs = fileServiceURIs || fabricURIs;
116
+ this.ethereumURIs = ethereumURIs;
117
+ this.searchURIs = searchURIs;
118
+ this.ethereumContractTimeout = ethereumContractTimeout;
119
+ this.trustAuthorityId = trustAuthorityId;
120
+ this.noCache = noCache;
121
+ this.noAuth = noAuth;
122
+ this.assumeV3 = assumeV3;
123
+ if (!["search", "default"].includes(service)) {
124
+ throw Error("Invalid service: ".concat(service));
125
+ }
126
+ this.service = service;
127
+ this.debug = false;
128
+ this.InitializeClients({
129
+ staticToken: staticToken
130
+ });
131
+ }
132
+
133
+ /**
134
+ * Retrieve content space info and preferred fabric and blockchain URLs from the fabric
135
+ *
136
+ * @methodGroup Constructor
137
+ * @namedParams
138
+ * @param {string} configUrl - Full URL to the config endpoint
139
+ * @param {Array<string>} kmsUrls - List of KMS urls to use for OAuth authentication
140
+ * @param {string=} region - Preferred region - the fabric will auto-detect the best region if not specified
141
+ * - Available regions: as-east, au-east, eu-east-north, eu-west-north, na-east-north, na-east-south, na-west-north, na-west-south, eu-east-south, eu-west-south
142
+ * @param {string=} clientIP - IP address to use in determining the region to use
143
+ * @return {Promise<Object>} - Object containing content space ID and fabric and ethereum URLs
144
+ */
145
+ return _createClass(ElvClient, [{
146
+ key: "Log",
147
+ value: function Log(message) {
148
+ var error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
149
+ LogMessage(this, message, error);
150
+ }
151
+
152
+ /**
153
+ * Enable or disable verbose logging
154
+ *
155
+ * @methodGroup Miscellaneous
156
+ *
157
+ * @param {boolean} enable - Set logging
158
+ * @param {Object=} options - Additional options for customizing logging
159
+ * - log: custom log() function
160
+ * - error: custom error() function
161
+ * - (custom functions must accept same arguments as console.log/console.error)
162
+ */
163
+ }, {
164
+ key: "ToggleLogging",
165
+ value: function ToggleLogging(enable) {
166
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
167
+ // define func with closure to pass to forEach
168
+ var setDebug = function setDebug(reporter) {
169
+ if (reporter) {
170
+ reporter.debug = enable;
171
+ reporter.debugOptions = options;
172
+ }
173
+ };
174
+ [this, this.authClient, this.ethClient, this.HttpClient, this.AuthHttpClient, this.FileServiceHttpClient, this.SearchHttpClient, this.userProfileClient].forEach(setDebug);
175
+ if (enable) {
176
+ this.Log("Debug Logging Enabled:\n Content Space: ".concat(this.contentSpaceId, "\n Fabric URLs: [\n\t\t").concat(this.fabricURIs.join(", \n\t\t"), "\n\t]\n Ethereum URLs: [\n\t\t").concat(this.ethereumURIs.join(", \n\t\t"), "\n\t]\n Auth Service URLs: [\\n\\t\\t").concat(this.authServiceURIs.join(", \n\t\t"), "\\n\\t]\n File Service URLs: [\\n\\t\\t").concat(this.fileServiceURIs.join(", \n\t\t"), "\\n\\t]\n "));
177
+ }
178
+ }
179
+ }, {
180
+ key: "EnableMethodLogging",
181
+ value: function EnableMethodLogging() {
182
+ var MethodLogger = function MethodLogger(klass) {
183
+ Object.getOwnPropertyNames(Object.getPrototypeOf(klass)).filter(function (method) {
184
+ return typeof klass[method] === "function";
185
+ }).forEach(function (methodName) {
186
+ var originalMethod = klass[methodName].bind(klass);
187
+ if (originalMethod.constructor.name === "AsyncFunction") {
188
+ klass[methodName] = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
189
+ var start,
190
+ _len,
191
+ args,
192
+ _key,
193
+ result,
194
+ _args = arguments;
195
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
196
+ while (1) switch (_context.prev = _context.next) {
197
+ case 0:
198
+ start = Date.now();
199
+ for (_len = _args.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
200
+ args[_key] = _args[_key];
201
+ }
202
+ _context.next = 4;
203
+ return originalMethod.apply(void 0, args);
204
+ case 4:
205
+ result = _context.sent;
206
+ // eslint-disable-next-line no-console
207
+ console.log(methodName, Date.now() - start, "ms", JSON.stringify(args));
208
+ return _context.abrupt("return", result);
209
+ case 7:
210
+ case "end":
211
+ return _context.stop();
212
+ }
213
+ }, _callee);
214
+ }));
215
+ } else {
216
+ klass[methodName] = function () {
217
+ var start = Date.now();
218
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
219
+ args[_key2] = arguments[_key2];
220
+ }
221
+ var result = originalMethod.apply(void 0, args);
222
+ // eslint-disable-next-line no-console
223
+ console.log(methodName, Date.now() - start, "ms", JSON.stringify(args));
224
+ return result;
225
+ };
226
+ }
227
+ });
228
+ };
229
+ MethodLogger(this);
230
+ }
231
+ }, {
232
+ key: "InitializeClients",
233
+ value: function () {
234
+ var _InitializeClients = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
235
+ var _ref3,
236
+ staticToken,
237
+ uris,
238
+ wallet,
239
+ signer,
240
+ _args2 = arguments;
241
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
242
+ while (1) switch (_context2.prev = _context2.next) {
243
+ case 0:
244
+ _ref3 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, staticToken = _ref3.staticToken;
245
+ // Cached info
246
+ this.contentTypes = {};
247
+ this.encryptionConks = {};
248
+ this.stateChannelAccess = {};
249
+ this.objectTenantIds = {};
250
+ this.objectLibraryIds = {};
251
+ this.objectImageUrls = {};
252
+ this.visibilityInfo = {};
253
+ this.inaccessibleLibraries = {};
254
+ uris = this.service === "search" ? this.searchURIs : this.fabricURIs;
255
+ this.HttpClient = new HttpClient({
256
+ uris: uris,
257
+ debug: this.debug
258
+ });
259
+ this.AuthHttpClient = new HttpClient({
260
+ uris: this.authServiceURIs,
261
+ debug: this.debug
262
+ });
263
+ this.FileServiceHttpClient = new HttpClient({
264
+ uris: this.fileServiceURIs,
265
+ debug: this.debug
266
+ });
267
+ this.SearchHttpClient = new HttpClient({
268
+ uris: this.searchURIs || [],
269
+ debug: this.debug
270
+ });
271
+ this.ethClient = new EthClient({
272
+ client: this,
273
+ uris: this.ethereumURIs,
274
+ networkId: this.networkId,
275
+ debug: this.debug,
276
+ timeout: this.ethereumContractTimeout
277
+ });
278
+ if (!this.signer) {
279
+ wallet = this.GenerateWallet();
280
+ signer = wallet.AddAccountFromMnemonic({
281
+ mnemonic: wallet.GenerateMnemonic()
282
+ });
283
+ this.SetSigner({
284
+ signer: signer,
285
+ reset: false
286
+ });
287
+ this.SetStaticToken({
288
+ token: staticToken
289
+ });
290
+ }
291
+ this.authClient = new AuthorizationClient({
292
+ client: this,
293
+ contentSpaceId: this.contentSpaceId,
294
+ signer: this.signer,
295
+ noCache: this.noCache,
296
+ noAuth: this.noAuth,
297
+ debug: this.debug
298
+ });
299
+ this.userProfileClient = new UserProfileClient({
300
+ client: this,
301
+ debug: this.debug
302
+ });
303
+
304
+ // Initialize crypto wasm
305
+ this.Crypto = Crypto;
306
+ this.Crypto.ElvCrypto();
307
+ case 20:
308
+ case "end":
309
+ return _context2.stop();
310
+ }
311
+ }, _callee2, this);
312
+ }));
313
+ function InitializeClients() {
314
+ return _InitializeClients.apply(this, arguments);
315
+ }
316
+ return InitializeClients;
317
+ }()
318
+ }, {
319
+ key: "ConfigUrl",
320
+ value: function ConfigUrl() {
321
+ return this.configUrl;
322
+ }
323
+ }, {
324
+ key: "SetAuth",
325
+ value: function SetAuth(auth) {
326
+ this.noAuth = !auth;
327
+ this.authClient.noAuth = !auth;
328
+ }
329
+
330
+ /**
331
+ * Update fabric URLs to prefer the specified region.
332
+ *
333
+ * Note: Client must have been initialized with FromConfigurationUrl or FromNetworkName
334
+ *
335
+ * @methodGroup Nodes
336
+ * @namedParams
337
+ * @param {string} region - Preferred region - the fabric will auto-detect the best region if not specified
338
+ * - Available regions: as-east, au-east, eu-east-north, eu-west-north, na-east-north, na-east-south, na-west-north, na-west-south, eu-east-south, eu-west-south
339
+ *
340
+ * @return {Promise<Object>} - An object containing the updated fabric, ethereum, auth service, and search URLs in order of preference
341
+ */
342
+ }, {
343
+ key: "UseRegion",
344
+ value: (function () {
345
+ var _UseRegion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref4) {
346
+ var region, _yield$ElvClient$Conf, fabricURIs, ethereumURIs, authServiceURIs, fileServiceURIs, searchURIs;
347
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
348
+ while (1) switch (_context3.prev = _context3.next) {
349
+ case 0:
350
+ region = _ref4.region;
351
+ if (this.configUrl) {
352
+ _context3.next = 3;
353
+ break;
354
+ }
355
+ throw Error("Unable to change region: Configuration URL not set");
356
+ case 3:
357
+ _context3.next = 5;
358
+ return ElvClient.Configuration({
359
+ configUrl: this.configUrl,
360
+ region: region
361
+ });
362
+ case 5:
363
+ _yield$ElvClient$Conf = _context3.sent;
364
+ fabricURIs = _yield$ElvClient$Conf.fabricURIs;
365
+ ethereumURIs = _yield$ElvClient$Conf.ethereumURIs;
366
+ authServiceURIs = _yield$ElvClient$Conf.authServiceURIs;
367
+ fileServiceURIs = _yield$ElvClient$Conf.fileServiceURIs;
368
+ searchURIs = _yield$ElvClient$Conf.searchURIs;
369
+ this.region = region;
370
+ this.SetNodes({
371
+ fabricURIs: fabricURIs,
372
+ ethereumURIs: ethereumURIs,
373
+ authServiceURIs: authServiceURIs,
374
+ fileServiceURIs: fileServiceURIs,
375
+ searchURIs: searchURIs
376
+ });
377
+ return _context3.abrupt("return", {
378
+ fabricURIs: fabricURIs,
379
+ ethereumURIs: ethereumURIs,
380
+ fileServiceURIs: fileServiceURIs,
381
+ authServiceURIs: authServiceURIs,
382
+ searchURIs: searchURIs
383
+ });
384
+ case 14:
385
+ case "end":
386
+ return _context3.stop();
387
+ }
388
+ }, _callee3, this);
389
+ }));
390
+ function UseRegion(_x) {
391
+ return _UseRegion.apply(this, arguments);
392
+ }
393
+ return UseRegion;
394
+ }()
395
+ /**
396
+ * Reset fabric URLs to prefer the best region auto-detected by the fabric.
397
+ *
398
+ * Note: Client must have been initialized with FromConfigurationUrl or FromNetworkName
399
+ *
400
+ * @methodGroup Nodes
401
+ *
402
+ * @return {Promise<Object>} - An object containing the updated fabric and ethereum URLs in order of preference
403
+ */
404
+ )
405
+ }, {
406
+ key: "ResetRegion",
407
+ value: (function () {
408
+ var _ResetRegion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
409
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
410
+ while (1) switch (_context4.prev = _context4.next) {
411
+ case 0:
412
+ if (this.configUrl) {
413
+ _context4.next = 2;
414
+ break;
415
+ }
416
+ throw Error("Unable to change region: Configuration URL not set");
417
+ case 2:
418
+ _context4.next = 4;
419
+ return this.UseRegion({
420
+ region: ""
421
+ });
422
+ case 4:
423
+ return _context4.abrupt("return", _context4.sent);
424
+ case 5:
425
+ case "end":
426
+ return _context4.stop();
427
+ }
428
+ }, _callee4, this);
429
+ }));
430
+ function ResetRegion() {
431
+ return _ResetRegion.apply(this, arguments);
432
+ }
433
+ return ResetRegion;
434
+ }()
435
+ /**
436
+ * Retrieve the node ID reported by the fabric for the specified region
437
+ *
438
+ * Note: Client must have been initialized with FromConfigurationUrl or FromNetworkName
439
+ *
440
+ * @methodGroup Nodes
441
+ *
442
+ * @namedParams
443
+ * @param {string} region - Region from which to retrieve the node ID
444
+ *
445
+ * @return {Promise<string>} - The node ID reported by the fabric
446
+ */
447
+ )
448
+ }, {
449
+ key: "NodeId",
450
+ value: (function () {
451
+ var _NodeId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref5) {
452
+ var region, _yield$ElvClient$Conf2, nodeId;
453
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
454
+ while (1) switch (_context5.prev = _context5.next) {
455
+ case 0:
456
+ region = _ref5.region;
457
+ _context5.next = 3;
458
+ return ElvClient.Configuration({
459
+ configUrl: this.configUrl,
460
+ region: region
461
+ });
462
+ case 3:
463
+ _yield$ElvClient$Conf2 = _context5.sent;
464
+ nodeId = _yield$ElvClient$Conf2.nodeId;
465
+ return _context5.abrupt("return", nodeId);
466
+ case 6:
467
+ case "end":
468
+ return _context5.stop();
469
+ }
470
+ }, _callee5, this);
471
+ }));
472
+ function NodeId(_x2) {
473
+ return _NodeId.apply(this, arguments);
474
+ }
475
+ return NodeId;
476
+ }()
477
+ /**
478
+ * Retrieve the fabric, ethereum, auth service, and search nodes currently used by the client, in preference order
479
+ *
480
+ * @methodGroup Nodes
481
+ *
482
+ * @return {Promise<Object>} - An object containing the lists of fabric, ethereum, auth service, and search urls in use by the client
483
+ */
484
+ )
485
+ }, {
486
+ key: "Nodes",
487
+ value: function Nodes() {
488
+ return {
489
+ fabricURIs: this.fabricURIs,
490
+ ethereumURIs: this.ethereumURIs,
491
+ authServiceURIs: this.authServiceURIs,
492
+ fileServiceURIs: this.fileServiceURIs,
493
+ searchURIs: this.searchURIs
494
+ };
495
+ }
496
+
497
+ /**
498
+ * Set the client to use the specified fabric, ethereum, auth service, and search nodes, in preference order
499
+ *
500
+ * @namedParams
501
+ * @param {Array<string>=} fabricURIs - A list of URLs for the fabric, in preference order
502
+ * @param {Array<string>=} ethereumURIs - A list of URLs for the blockchain, in preference order
503
+ * @param {Array<string>=} authServiceURIs - A list of URLs for the auth service, in preference order
504
+ * @param {Array<string>=} fileServiceURIs - A list of URLs for file service jobs, in preference order
505
+ * @param {Array<string>=} searchURIs - A list of URLs for the search nodes, in preference order
506
+ *
507
+ * @methodGroup Nodes
508
+ */
509
+ }, {
510
+ key: "SetNodes",
511
+ value: function SetNodes(_ref6) {
512
+ var fabricURIs = _ref6.fabricURIs,
513
+ ethereumURIs = _ref6.ethereumURIs,
514
+ authServiceURIs = _ref6.authServiceURIs,
515
+ fileServiceURIs = _ref6.fileServiceURIs,
516
+ searchURIs = _ref6.searchURIs;
517
+ if (fabricURIs) {
518
+ this.fabricURIs = fabricURIs;
519
+ this.HttpClient.uris = fabricURIs;
520
+ this.HttpClient.uriIndex = 0;
521
+ }
522
+ if (ethereumURIs) {
523
+ this.ethereumURIs = ethereumURIs;
524
+ this.ethClient.ethereumURIs = ethereumURIs;
525
+ this.ethClient.ethereumURIIndex = 0;
526
+ }
527
+ if (authServiceURIs) {
528
+ this.authServiceURIs = authServiceURIs;
529
+ this.AuthHttpClient.uris = authServiceURIs;
530
+ this.AuthHttpClient.uriIndex = 0;
531
+ }
532
+ if (fileServiceURIs) {
533
+ this.fileServiceURIs = fileServiceURIs;
534
+ this.FileServiceHttpClient.uris = fileServiceURIs;
535
+ this.FileServiceHttpClient.uriIndex = 0;
536
+ }
537
+ if (searchURIs) {
538
+ this.searchURIs = searchURIs;
539
+ this.SearchHttpClient.uris = searchURIs;
540
+ this.SearchHttpClient.uriIndex = 0;
541
+ }
542
+ }
543
+
544
+ /**
545
+ * Return a list of nodes in the content space, optionally filtered by node ID or endpoint.
546
+ *
547
+ * @methodGroup Nodes
548
+ * @namedParams
549
+ * @param {string=} matchEndpoint - Return node(s) matching the specified endpoint
550
+ * @param {string=} matchNodeId - Return node(s) matching the specified node ID
551
+ *
552
+ * @return {Promise<Array<Object>>} - A list of nodes in the space matching the parameters
553
+ */
554
+ }, {
555
+ key: "SpaceNodes",
556
+ value: (function () {
557
+ var _SpaceNodes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
558
+ var _this = this;
559
+ var _ref7,
560
+ matchEndpoint,
561
+ matchNodeId,
562
+ nodes,
563
+ _yield$this$utils$Res,
564
+ node,
565
+ _args6 = arguments;
566
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
567
+ while (1) switch (_context6.prev = _context6.next) {
568
+ case 0:
569
+ _ref7 = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {}, matchEndpoint = _ref7.matchEndpoint, matchNodeId = _ref7.matchNodeId;
570
+ this.SetStaticToken();
571
+ if (!matchEndpoint) {
572
+ _context6.next = 12;
573
+ break;
574
+ }
575
+ _context6.next = 5;
576
+ return this.utils.ResponseToJson(this.HttpClient.Request({
577
+ path: UrlJoin("nodes"),
578
+ method: "GET",
579
+ headers: {
580
+ Authorization: "Bearer ".concat(this.staticToken)
581
+ }
582
+ }));
583
+ case 5:
584
+ _yield$this$utils$Res = _context6.sent;
585
+ nodes = _yield$this$utils$Res.nodes;
586
+ if (!(!nodes || !Array.isArray(nodes) || nodes.length === 0)) {
587
+ _context6.next = 9;
588
+ break;
589
+ }
590
+ return _context6.abrupt("return", []);
591
+ case 9:
592
+ return _context6.abrupt("return", nodes.filter(function (node) {
593
+ var match = false;
594
+ if (node.services && node.services.fabric_api && node.services.fabric_api.urls) {
595
+ var results = (node.services.fabric_api.urls || []).find(function (url) {
596
+ return url.includes(matchEndpoint);
597
+ });
598
+ if (results) {
599
+ match = true;
600
+ }
601
+ }
602
+ if (matchNodeId && node.id === matchNodeId) {
603
+ match = true;
604
+ }
605
+ _this.ClearStaticToken();
606
+ return match;
607
+ }));
608
+ case 12:
609
+ if (!matchNodeId) {
610
+ _context6.next = 19;
611
+ break;
612
+ }
613
+ this.SetStaticToken();
614
+ _context6.next = 16;
615
+ return this.utils.ResponseToJson(this.HttpClient.Request({
616
+ path: UrlJoin("nodes", matchNodeId),
617
+ method: "GET",
618
+ headers: {
619
+ Authorization: "Bearer ".concat(this.staticToken)
620
+ }
621
+ }));
622
+ case 16:
623
+ node = _context6.sent;
624
+ this.ClearStaticToken();
625
+ return _context6.abrupt("return", [node]);
626
+ case 19:
627
+ case "end":
628
+ return _context6.stop();
629
+ }
630
+ }, _callee6, this);
631
+ }));
632
+ function SpaceNodes() {
633
+ return _SpaceNodes.apply(this, arguments);
634
+ }
635
+ return SpaceNodes;
636
+ }()
637
+ /**
638
+ * Return information about how the client was connected to the network
639
+ *
640
+ * @methodGroup Nodes
641
+ * @returns {Object} - The name, ID and configuration URL of the network
642
+ */
643
+ )
644
+ }, {
645
+ key: "NetworkInfo",
646
+ value: function NetworkInfo() {
647
+ return {
648
+ name: this.networkName,
649
+ id: this.networkId,
650
+ configUrl: this.configUrl
651
+ };
652
+ }
653
+ }, {
654
+ key: "WriteTokenNodeUrl",
655
+ value: function WriteTokenNodeUrl(_ref8) {
656
+ var writeToken = _ref8.writeToken;
657
+ var nodeUrl = this.HttpClient.draftURIs[writeToken];
658
+ return nodeUrl ? nodeUrl.toString() : undefined;
659
+ }
660
+ }, {
661
+ key: "RecordWriteToken",
662
+ value: function RecordWriteToken(_ref9) {
663
+ var writeToken = _ref9.writeToken,
664
+ fabricNodeUrl = _ref9.fabricNodeUrl;
665
+ this.HttpClient.RecordWriteToken(writeToken, fabricNodeUrl);
666
+ }
667
+
668
+ /* Wallet and signers */
669
+
670
+ /**
671
+ * Generate a new ElvWallet that is connected to the client's provider
672
+ *
673
+ * @methodGroup Signers
674
+ * @returns {ElvWallet} - ElvWallet instance with this client's provider
675
+ */
676
+ }, {
677
+ key: "GenerateWallet",
678
+ value: function GenerateWallet() {
679
+ return new ElvWallet(this.ethClient.Provider());
680
+ }
681
+
682
+ /**
683
+ * Remove the signer from this client
684
+ *
685
+ * @methodGroup Signers
686
+ */
687
+ }, {
688
+ key: "ClearSigner",
689
+ value: function ClearSigner() {
690
+ this.signer = undefined;
691
+ this.InitializeClients();
692
+ }
693
+
694
+ /**
695
+ * Clear saved access and state channel tokens
696
+ *
697
+ * @methodGroup Access Requests
698
+ */
699
+ }, {
700
+ key: "ClearCache",
701
+ value: function ClearCache() {
702
+ this.authClient.ClearCache();
703
+ }
704
+
705
+ /**
706
+ * Set the signer for this client to use for blockchain transactions
707
+ *
708
+ * @methodGroup Signers
709
+ * @namedParams
710
+ * @param {object} signer - The ethers.js signer object
711
+ */
712
+ }, {
713
+ key: "SetSigner",
714
+ value: function SetSigner(_ref10) {
715
+ var signer = _ref10.signer,
716
+ _ref10$reset = _ref10.reset,
717
+ reset = _ref10$reset === void 0 ? true : _ref10$reset;
718
+ this.staticToken = undefined;
719
+ signer.connect(this.ethClient.Provider());
720
+ signer.provider.pollingInterval = 500;
721
+ this.signer = signer;
722
+ if (reset) {
723
+ this.InitializeClients();
724
+ }
725
+ }
726
+
727
+ /**
728
+ * Set signer using OAuth ID token
729
+ *
730
+ * @methodGroup Signers
731
+ * @namedParams
732
+ * @param {string=} idToken - OAuth ID token
733
+ * @param {string=} authToken - Eluvio authorization token previously issued from OAuth ID token
734
+ * @param {string=} tenantId - If specified, user will be associated with the tenant
735
+ * @param {Object=} extraData - Additional data to pass to the login API
736
+ * @param {Array<string>=} signerURIs - (Only if using custom OAuth) - URIs corresponding to the key server(s) to use
737
+ * @param {boolean=} unsignedPublicAuth=false - If specified, the client will use an unsigned static token for calls that don't require authorization (reduces remote signature calls)
738
+ */
739
+ }, {
740
+ key: "SetRemoteSigner",
741
+ value: (function () {
742
+ var _SetRemoteSigner = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref11) {
743
+ var idToken, authToken, tenantId, extraData, signerURIs, unsignedPublicAuth, signer;
744
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
745
+ while (1) switch (_context7.prev = _context7.next) {
746
+ case 0:
747
+ idToken = _ref11.idToken, authToken = _ref11.authToken, tenantId = _ref11.tenantId, extraData = _ref11.extraData, signerURIs = _ref11.signerURIs, unsignedPublicAuth = _ref11.unsignedPublicAuth;
748
+ _context7.t0 = RemoteSigner;
749
+ _context7.t1 = signerURIs || this.authServiceURIs;
750
+ _context7.t2 = idToken;
751
+ _context7.t3 = authToken;
752
+ _context7.t4 = tenantId;
753
+ _context7.next = 8;
754
+ return this.ethClient.Provider();
755
+ case 8:
756
+ _context7.t5 = _context7.sent;
757
+ _context7.t6 = extraData;
758
+ _context7.t7 = unsignedPublicAuth;
759
+ _context7.t8 = {
760
+ signerURIs: _context7.t1,
761
+ idToken: _context7.t2,
762
+ authToken: _context7.t3,
763
+ tenantId: _context7.t4,
764
+ provider: _context7.t5,
765
+ extraData: _context7.t6,
766
+ unsignedPublicAuth: _context7.t7
767
+ };
768
+ signer = new _context7.t0(_context7.t8);
769
+ _context7.next = 15;
770
+ return signer.Initialize();
771
+ case 15:
772
+ this.SetSigner({
773
+ signer: signer
774
+ });
775
+ case 16:
776
+ case "end":
777
+ return _context7.stop();
778
+ }
779
+ }, _callee7, this);
780
+ }));
781
+ function SetRemoteSigner(_x3) {
782
+ return _SetRemoteSigner.apply(this, arguments);
783
+ }
784
+ return SetRemoteSigner;
785
+ }()
786
+ /**
787
+ * Set the signer for this client to use for blockchain transactions from an existing web3 provider.
788
+ * Useful for integrating with MetaMask
789
+ *
790
+ * @see https://github.com/ethers-io/ethers.js/issues/59#issuecomment-358224800
791
+ *
792
+ * @methodGroup Signers
793
+ * @namedParams
794
+ * @param {object} provider - The web3 provider object
795
+ */
796
+ )
797
+ }, {
798
+ key: "SetSignerFromWeb3Provider",
799
+ value: (function () {
800
+ var _SetSignerFromWeb3Provider = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref12) {
801
+ var provider, ethProvider;
802
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
803
+ while (1) switch (_context8.prev = _context8.next) {
804
+ case 0:
805
+ provider = _ref12.provider;
806
+ this.staticToken = undefined;
807
+ ethProvider = new Ethers.providers.Web3Provider(provider);
808
+ ethProvider.pollingInterval = 250;
809
+ this.signer = ethProvider.getSigner();
810
+ _context8.next = 7;
811
+ return this.signer.getAddress();
812
+ case 7:
813
+ this.signer.address = _context8.sent;
814
+ _context8.next = 10;
815
+ return this.InitializeClients();
816
+ case 10:
817
+ case "end":
818
+ return _context8.stop();
819
+ }
820
+ }, _callee8, this);
821
+ }));
822
+ function SetSignerFromWeb3Provider(_x4) {
823
+ return _SetSignerFromWeb3Provider.apply(this, arguments);
824
+ }
825
+ return SetSignerFromWeb3Provider;
826
+ }()
827
+ /**
828
+ * Initialize a new account using the provided funding and group tokens.
829
+ *
830
+ * This method will redeem the tokens for the current account (or create a new one if not set) in order to
831
+ * retrieve funds and optionally have the user added to appropriate access groups.
832
+ *
833
+ * @methodGroup Signers
834
+ * @namedParams
835
+ * @param {string} tenantId - The ID of the tenant
836
+ * @param {string} fundingToken - A token permitting the user to retrieve funds
837
+ * @param {number=} funds=0.5 - The amount to fund this user. The maximum amount is limited by the token issuer.
838
+ * @param {string=} groupToken - A token permitting the user to be added to access groups
839
+ *
840
+ * @return {string} - The address of the user
841
+ */
842
+ )
843
+ }, {
844
+ key: "CreateAccount",
845
+ value: (function () {
846
+ var _CreateAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref13) {
847
+ var tenantId, fundingToken, _ref13$funds, funds, groupToken, wallet, signer;
848
+ return _regeneratorRuntime.wrap(function _callee9$(_context9) {
849
+ while (1) switch (_context9.prev = _context9.next) {
850
+ case 0:
851
+ tenantId = _ref13.tenantId, fundingToken = _ref13.fundingToken, _ref13$funds = _ref13.funds, funds = _ref13$funds === void 0 ? 0.5 : _ref13$funds, groupToken = _ref13.groupToken;
852
+ if (!this.signer) {
853
+ wallet = this.GenerateWallet();
854
+ signer = wallet.AddAccountFromMnemonic({
855
+ mnemonic: wallet.GenerateMnemonic()
856
+ });
857
+ this.SetSigner({
858
+ signer: signer
859
+ });
860
+ }
861
+ _context9.next = 4;
862
+ return this.authClient.MakeKMSRequest({
863
+ method: "POST",
864
+ path: "/ks/otp/fnd/".concat(tenantId),
865
+ body: {
866
+ toAddr: this.signer.address,
867
+ amtStr: this.utils.EtherToWei(funds)
868
+ },
869
+ headers: {
870
+ Authorization: "Bearer ".concat(fundingToken)
871
+ }
872
+ });
873
+ case 4:
874
+ _context9.next = 6;
875
+ return this.userProfileClient.CreateWallet();
876
+ case 6:
877
+ _context9.next = 8;
878
+ return this.userProfileClient.ReplaceUserMetadata({
879
+ metadataSubtree: "tenantContractId",
880
+ metadata: tenantId
881
+ });
882
+ case 8:
883
+ if (!groupToken) {
884
+ _context9.next = 11;
885
+ break;
886
+ }
887
+ _context9.next = 11;
888
+ return this.authClient.MakeKMSRequest({
889
+ method: "POST",
890
+ path: "/ks/otp/grp/".concat(tenantId),
891
+ body: {
892
+ addAddr: this.signer.address
893
+ },
894
+ headers: {
895
+ Authorization: "Bearer ".concat(groupToken)
896
+ }
897
+ });
898
+ case 11:
899
+ return _context9.abrupt("return", this.utils.FormatAddress(this.signer.address));
900
+ case 12:
901
+ case "end":
902
+ return _context9.stop();
903
+ }
904
+ }, _callee9, this);
905
+ }));
906
+ function CreateAccount(_x5) {
907
+ return _CreateAccount.apply(this, arguments);
908
+ }
909
+ return CreateAccount;
910
+ }()
911
+ /*
912
+ TOKEN 211b PREFIX + BODY | aplsjcJf1HYcDDUuCdXcSZtU86nYK162YmYJeuqwMczEBJVkD5D5EvsBvVwYDRsf4hzDvBWMoe9piBpqx...
913
+ PREFIX 6b aplsjc | apl=plain s=ES256K jc=json-compressed
914
+ BODY 205b base58(SIGNATURE + PAYLOAD)
915
+ SIGNATURE + PAYLOAD 151b 151b * 138 / 100 + 1 = 209b (>= 205b)
916
+ SIGNATURE 66b ES256K_Di9Lu83mz4wMoehCEeQhKpJJ7ApmDZLumAa2Cge48F6EHYnbn8msATGGpjucScwimei1TWGd7aeyQY45AdXd5tT1Z
917
+ PAYLOAD 85b json-compressed
918
+ json 79b {"adr":"VVf4DQU357tDnZGYQeDrntRJ5rs=","spc":"ispc3ANoVSzNA3P6t7abLR69ho5YPPZU"}
919
+ */
920
+ )
921
+ }, {
922
+ key: "PersonalSign",
923
+ value: (function () {
924
+ var _PersonalSign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref14) {
925
+ var _this2 = this;
926
+ var message, addEthereumPrefix, Sign;
927
+ return _regeneratorRuntime.wrap(function _callee11$(_context11) {
928
+ while (1) switch (_context11.prev = _context11.next) {
929
+ case 0:
930
+ message = _ref14.message, addEthereumPrefix = _ref14.addEthereumPrefix, Sign = _ref14.Sign;
931
+ if (!Sign) {
932
+ // Same as authClient.Sign, but authClient may not yet be initialized
933
+ Sign = /*#__PURE__*/function () {
934
+ var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(message) {
935
+ return _regeneratorRuntime.wrap(function _callee10$(_context10) {
936
+ while (1) switch (_context10.prev = _context10.next) {
937
+ case 0:
938
+ _context10.t0 = Ethers.utils;
939
+ if (!_this2.signer.signDigest) {
940
+ _context10.next = 7;
941
+ break;
942
+ }
943
+ _context10.next = 4;
944
+ return _this2.signer.signDigest(message);
945
+ case 4:
946
+ _context10.t1 = _context10.sent;
947
+ _context10.next = 10;
948
+ break;
949
+ case 7:
950
+ _context10.next = 9;
951
+ return _this2.signer._signingKey().signDigest(message);
952
+ case 9:
953
+ _context10.t1 = _context10.sent;
954
+ case 10:
955
+ _context10.t2 = _context10.t1;
956
+ return _context10.abrupt("return", _context10.t0.joinSignature.call(_context10.t0, _context10.t2));
957
+ case 12:
958
+ case "end":
959
+ return _context10.stop();
960
+ }
961
+ }, _callee10);
962
+ }));
963
+ return function Sign(_x7) {
964
+ return _ref15.apply(this, arguments);
965
+ };
966
+ }();
967
+ }
968
+ if (addEthereumPrefix) {
969
+ message = Ethers.utils.keccak256(Buffer.from("\x19Ethereum Signed Message:\n".concat(message.length).concat(message), "utf-8"));
970
+ }
971
+ _context11.next = 5;
972
+ return Sign(message);
973
+ case 5:
974
+ return _context11.abrupt("return", _context11.sent);
975
+ case 6:
976
+ case "end":
977
+ return _context11.stop();
978
+ }
979
+ }, _callee11);
980
+ }));
981
+ function PersonalSign(_x6) {
982
+ return _PersonalSign.apply(this, arguments);
983
+ }
984
+ return PersonalSign;
985
+ }()
986
+ /**
987
+ * Create a signed authorization token that can be used to authorize against the fabric
988
+ *
989
+ * @methodGroup Authorization
990
+ * @namedParams
991
+ * @param {number} duration=86400000 - Time until the token expires, in milliseconds (1 hour = 60 * 60 * 1000 = 3600000). Default is 24 hours.
992
+ * @param {Object=} spec - Additional attributes for this token
993
+ * @param {string=} address - Address of the signing account - if not specified, the current signer address will be used.
994
+ * @param {function=} Sign - If specified, this function will be used to produce the signature instead of the client's current signer
995
+ * @param {boolean=} addEthereumPrefix=true - If specified, the 'Ethereum Signed Message' prefixed hash format will be performed. Disable this if the provided Sign method already does this (e.g. Metamask)
996
+ */
997
+ )
998
+ }, {
999
+ key: "CreateFabricToken",
1000
+ value: (function () {
1001
+ var _CreateFabricToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
1002
+ var _ref16,
1003
+ _ref16$duration,
1004
+ duration,
1005
+ _ref16$spec,
1006
+ spec,
1007
+ address,
1008
+ Sign,
1009
+ _ref16$addEthereumPre,
1010
+ addEthereumPrefix,
1011
+ _ref16$context,
1012
+ context,
1013
+ token,
1014
+ message,
1015
+ signature,
1016
+ compressedToken,
1017
+ _args12 = arguments;
1018
+ return _regeneratorRuntime.wrap(function _callee12$(_context12) {
1019
+ while (1) switch (_context12.prev = _context12.next) {
1020
+ case 0:
1021
+ _ref16 = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : {}, _ref16$duration = _ref16.duration, duration = _ref16$duration === void 0 ? 24 * 60 * 60 * 1000 : _ref16$duration, _ref16$spec = _ref16.spec, spec = _ref16$spec === void 0 ? {} : _ref16$spec, address = _ref16.address, Sign = _ref16.Sign, _ref16$addEthereumPre = _ref16.addEthereumPrefix, addEthereumPrefix = _ref16$addEthereumPre === void 0 ? true : _ref16$addEthereumPre, _ref16$context = _ref16.context, context = _ref16$context === void 0 ? {} : _ref16$context;
1022
+ address = address || this.CurrentAccountAddress();
1023
+ _context12.t0 = _objectSpread;
1024
+ _context12.t1 = _objectSpread({}, spec);
1025
+ _context12.t2 = {};
1026
+ _context12.t3 = "iusr".concat(Utils.AddressToHash(address));
1027
+ _context12.t4 = Buffer.from(address.replace(/^0x/, ""), "hex").toString("base64");
1028
+ _context12.next = 9;
1029
+ return this.ContentSpaceId();
1030
+ case 9:
1031
+ _context12.t5 = _context12.sent;
1032
+ _context12.t6 = Date.now();
1033
+ _context12.t7 = Date.now() + duration;
1034
+ _context12.t8 = context;
1035
+ _context12.t9 = {
1036
+ sub: _context12.t3,
1037
+ adr: _context12.t4,
1038
+ spc: _context12.t5,
1039
+ iat: _context12.t6,
1040
+ exp: _context12.t7,
1041
+ ctx: _context12.t8
1042
+ };
1043
+ token = (0, _context12.t0)(_context12.t1, _context12.t2, _context12.t9);
1044
+ message = "Eluvio Content Fabric Access Token 1.0\n".concat(JSON.stringify(token));
1045
+ _context12.next = 18;
1046
+ return this.PersonalSign({
1047
+ message: message,
1048
+ addEthereumPrefix: addEthereumPrefix,
1049
+ Sign: Sign
1050
+ });
1051
+ case 18:
1052
+ signature = _context12.sent;
1053
+ compressedToken = Pako.deflateRaw(Buffer.from(JSON.stringify(token), "utf-8"));
1054
+ return _context12.abrupt("return", "acspjc".concat(this.utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(compressedToken)]))));
1055
+ case 21:
1056
+ case "end":
1057
+ return _context12.stop();
1058
+ }
1059
+ }, _callee12, this);
1060
+ }));
1061
+ function CreateFabricToken() {
1062
+ return _CreateFabricToken.apply(this, arguments);
1063
+ }
1064
+ return CreateFabricToken;
1065
+ }()
1066
+ /**
1067
+ * Issue a self-signed authorization token
1068
+ *
1069
+ * @methodGroup Authorization
1070
+ * @namedParams
1071
+ * @param {string=} libraryId - Library ID to authorize
1072
+ * @param {string=} objectId - Object ID to authorize
1073
+ * @param {string=} versionHash - Version hash to authorize
1074
+ * @param {string=} policyId - The object ID of the policy for this token
1075
+ * @param {string=} subject - The subject of the token
1076
+ * @param {string} grantType=read - Permissions to grant for this token. Options: "access", "read", "create", "update", "read-crypt"
1077
+ * @param {number} duration - Time until the token expires, in milliseconds (1 hour = 60 * 60 * 1000 = 3600000)
1078
+ * @param {boolean} allowDecryption=false - If specified, the re-encryption key will be included in the token,
1079
+ * enabling the user of this token to download encrypted content from the specified object
1080
+ * @param {Object=} context - Additional JSON context
1081
+ */
1082
+ )
1083
+ }, {
1084
+ key: "CreateSignedToken",
1085
+ value: (function () {
1086
+ var _CreateSignedToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref17) {
1087
+ var libraryId, objectId, versionHash, policyId, subject, _ref17$grantType, grantType, _ref17$allowDecryptio, allowDecryption, duration, _ref17$context, context, token, cap, compressedToken, signature;
1088
+ return _regeneratorRuntime.wrap(function _callee13$(_context13) {
1089
+ while (1) switch (_context13.prev = _context13.next) {
1090
+ case 0:
1091
+ libraryId = _ref17.libraryId, objectId = _ref17.objectId, versionHash = _ref17.versionHash, policyId = _ref17.policyId, subject = _ref17.subject, _ref17$grantType = _ref17.grantType, grantType = _ref17$grantType === void 0 ? "read" : _ref17$grantType, _ref17$allowDecryptio = _ref17.allowDecryption, allowDecryption = _ref17$allowDecryptio === void 0 ? false : _ref17$allowDecryptio, duration = _ref17.duration, _ref17$context = _ref17.context, context = _ref17$context === void 0 ? {} : _ref17$context;
1092
+ if (subject) {
1093
+ _context13.next = 9;
1094
+ break;
1095
+ }
1096
+ _context13.t0 = "iusr";
1097
+ _context13.t1 = this.utils;
1098
+ _context13.next = 6;
1099
+ return this.CurrentAccountAddress();
1100
+ case 6:
1101
+ _context13.t2 = _context13.sent;
1102
+ _context13.t3 = _context13.t1.AddressToHash.call(_context13.t1, _context13.t2);
1103
+ subject = _context13.t0.concat.call(_context13.t0, _context13.t3);
1104
+ case 9:
1105
+ if (policyId) {
1106
+ context["elv:delegation-id"] = policyId;
1107
+ }
1108
+ _context13.t4 = Buffer;
1109
+ _context13.next = 13;
1110
+ return this.CurrentAccountAddress().replace(/^0x/, "");
1111
+ case 13:
1112
+ _context13.t5 = _context13.sent;
1113
+ _context13.t6 = _context13.t4.from.call(_context13.t4, _context13.t5, "hex").toString("base64");
1114
+ _context13.t7 = subject;
1115
+ _context13.next = 18;
1116
+ return this.ContentSpaceId();
1117
+ case 18:
1118
+ _context13.t8 = _context13.sent;
1119
+ _context13.t9 = Date.now();
1120
+ _context13.t10 = Date.now() + duration;
1121
+ _context13.t11 = grantType;
1122
+ _context13.t12 = context;
1123
+ token = {
1124
+ adr: _context13.t6,
1125
+ sub: _context13.t7,
1126
+ spc: _context13.t8,
1127
+ iat: _context13.t9,
1128
+ exp: _context13.t10,
1129
+ gra: _context13.t11,
1130
+ ctx: _context13.t12
1131
+ };
1132
+ if (versionHash) {
1133
+ objectId = this.utils.DecodeVersionHash(versionHash).objectId;
1134
+ }
1135
+ if (!objectId) {
1136
+ _context13.next = 31;
1137
+ break;
1138
+ }
1139
+ token.qid = objectId;
1140
+ if (libraryId) {
1141
+ _context13.next = 31;
1142
+ break;
1143
+ }
1144
+ _context13.next = 30;
1145
+ return this.ContentObjectLibraryId({
1146
+ objectId: objectId
1147
+ });
1148
+ case 30:
1149
+ libraryId = _context13.sent;
1150
+ case 31:
1151
+ if (libraryId) {
1152
+ token.lib = libraryId;
1153
+ }
1154
+ if (!allowDecryption) {
1155
+ _context13.next = 37;
1156
+ break;
1157
+ }
1158
+ _context13.next = 35;
1159
+ return this.authClient.ReEncryptionConk({
1160
+ libraryId: libraryId,
1161
+ objectId: objectId
1162
+ });
1163
+ case 35:
1164
+ cap = _context13.sent;
1165
+ token.apk = cap.public_key;
1166
+ case 37:
1167
+ compressedToken = Pako.deflateRaw(Buffer.from(JSON.stringify(token), "utf-8"));
1168
+ _context13.next = 40;
1169
+ return this.authClient.Sign(Ethers.utils.keccak256(compressedToken));
1170
+ case 40:
1171
+ signature = _context13.sent;
1172
+ return _context13.abrupt("return", "aessjc".concat(this.utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(compressedToken)]))));
1173
+ case 42:
1174
+ case "end":
1175
+ return _context13.stop();
1176
+ }
1177
+ }, _callee13, this);
1178
+ }));
1179
+ function CreateSignedToken(_x8) {
1180
+ return _CreateSignedToken.apply(this, arguments);
1181
+ }
1182
+ return CreateSignedToken;
1183
+ }()
1184
+ /**
1185
+ * Build a signed message (JSON) using the current signer.
1186
+ * Signed messages have a similar format to signed access tokens and they include the message itself
1187
+ * such that they can be both verified and decoded by the receiving entity.
1188
+ *
1189
+ * Messages can be encoded and signed using different methods, and the encoding and signature types
1190
+ * are described in the header of the resulting signed message blob.
1191
+ *
1192
+ * Note this type of message can not be verified and decoded on chain.
1193
+ *
1194
+ * @methodGroup Authorization
1195
+ * @namedParams
1196
+ * @param {string} messasge - A JSON object representing the message to sign
1197
+ */
1198
+ )
1199
+ }, {
1200
+ key: "CreateSignedMessageJSON",
1201
+ value: (function () {
1202
+ var _CreateSignedMessageJSON = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref18) {
1203
+ var message, type, msg, signature;
1204
+ return _regeneratorRuntime.wrap(function _callee14$(_context14) {
1205
+ while (1) switch (_context14.prev = _context14.next) {
1206
+ case 0:
1207
+ message = _ref18.message;
1208
+ // Only one kind of signature supported currently
1209
+ type = "mje_"; // JSON message, EIP192 signature
1210
+ msg = JSON.stringify(message);
1211
+ _context14.next = 5;
1212
+ return this.PersonalSign({
1213
+ message: msg,
1214
+ addEthereumPrefix: true
1215
+ });
1216
+ case 5:
1217
+ signature = _context14.sent;
1218
+ return _context14.abrupt("return", "".concat(type).concat(Utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(msg)]))));
1219
+ case 7:
1220
+ case "end":
1221
+ return _context14.stop();
1222
+ }
1223
+ }, _callee14, this);
1224
+ }));
1225
+ function CreateSignedMessageJSON(_x9) {
1226
+ return _CreateSignedMessageJSON.apply(this, arguments);
1227
+ }
1228
+ return CreateSignedMessageJSON;
1229
+ }()
1230
+ /**
1231
+ * Verify and decode a signed message (JSON).
1232
+ *
1233
+ * @methodGroup Authorization
1234
+ * @namedParams
1235
+ * @param {string} signedMessage - a signed message as created by CreateSignedMessageJSON
1236
+ * @returns {Promise<Object>} - The decoded message, signer address, signature and signature type
1237
+ */
1238
+ )
1239
+ }, {
1240
+ key: "DecodeSignedMessageJSON",
1241
+ value: (function () {
1242
+ var _DecodeSignedMessageJSON = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref19) {
1243
+ var signedMessage, type, msgBytes, signature, msg, obj, prefixedMsgHash, signerAddr;
1244
+ return _regeneratorRuntime.wrap(function _callee15$(_context15) {
1245
+ while (1) switch (_context15.prev = _context15.next) {
1246
+ case 0:
1247
+ signedMessage = _ref19.signedMessage;
1248
+ type = signedMessage.slice(0, 4);
1249
+ _context15.t0 = type;
1250
+ _context15.next = _context15.t0 === "mje_" ? 5 : 12;
1251
+ break;
1252
+ case 5:
1253
+ msgBytes = Utils.FromB58(signedMessage.slice(4));
1254
+ signature = msgBytes.slice(0, 65);
1255
+ msg = msgBytes.slice(65);
1256
+ obj = JSON.parse(msg);
1257
+ prefixedMsgHash = Ethers.utils.keccak256(Buffer.from("\x19Ethereum Signed Message:\n".concat(msg.length).concat(msg), "utf-8"));
1258
+ signerAddr = Ethers.utils.recoverAddress(prefixedMsgHash, signature);
1259
+ return _context15.abrupt("return", {
1260
+ type: type,
1261
+ message: obj,
1262
+ signerAddress: signerAddr,
1263
+ signature: "0x" + signature.toString("hex")
1264
+ });
1265
+ case 12:
1266
+ throw new Error("Bad message type: ".concat(type));
1267
+ case 13:
1268
+ case "end":
1269
+ return _context15.stop();
1270
+ }
1271
+ }, _callee15);
1272
+ }));
1273
+ function DecodeSignedMessageJSON(_x10) {
1274
+ return _DecodeSignedMessageJSON.apply(this, arguments);
1275
+ }
1276
+ return DecodeSignedMessageJSON;
1277
+ }()
1278
+ /**
1279
+ * Get the account address of the current signer
1280
+ *
1281
+ * @methodGroup Signers
1282
+ * @returns {string} - The address of the current signer
1283
+ */
1284
+ )
1285
+ }, {
1286
+ key: "CurrentAccountAddress",
1287
+ value: function CurrentAccountAddress() {
1288
+ return this.signer ? this.utils.FormatAddress(this.signer.address) : "";
1289
+ }
1290
+
1291
+ /**
1292
+ * Set the OAuth token for use in state channel calls
1293
+ *
1294
+ * @methodGroup Authorization
1295
+ * @namedParams
1296
+ * @param {string} token - The OAuth ID token
1297
+ */
1298
+ }, {
1299
+ key: "SetOauthToken",
1300
+ value: (function () {
1301
+ var _SetOauthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(_ref20) {
1302
+ var token, wallet, signer;
1303
+ return _regeneratorRuntime.wrap(function _callee16$(_context16) {
1304
+ while (1) switch (_context16.prev = _context16.next) {
1305
+ case 0:
1306
+ token = _ref20.token;
1307
+ this.oauthToken = token;
1308
+ wallet = this.GenerateWallet();
1309
+ signer = wallet.AddAccountFromMnemonic({
1310
+ mnemonic: wallet.GenerateMnemonic()
1311
+ });
1312
+ this.SetSigner({
1313
+ signer: signer
1314
+ });
1315
+ case 5:
1316
+ case "end":
1317
+ return _context16.stop();
1318
+ }
1319
+ }, _callee16, this);
1320
+ }));
1321
+ function SetOauthToken(_x11) {
1322
+ return _SetOauthToken.apply(this, arguments);
1323
+ }
1324
+ return SetOauthToken;
1325
+ }()
1326
+ /**
1327
+ * Set the signer for this client via OAuth token. The client will exchange the given token
1328
+ * for the user's private key using the KMS specified in the configuration.
1329
+ *
1330
+ * NOTE: The KMS URL(s) must be set in the initial configuration of the client (FromConfigurationUrl or FromNetworkName)
1331
+ *
1332
+ * @methodGroup Authorization
1333
+ * @namedParams
1334
+ * @param {string} token - The OAuth ID
1335
+ */
1336
+ )
1337
+ }, {
1338
+ key: "SetSignerFromOauthToken",
1339
+ value: (function () {
1340
+ var _SetSignerFromOauthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(_ref21) {
1341
+ var token, wallet, client, _yield$client$authCli, urls, path, httpClient, response, privateKey;
1342
+ return _regeneratorRuntime.wrap(function _callee17$(_context17) {
1343
+ while (1) switch (_context17.prev = _context17.next) {
1344
+ case 0:
1345
+ token = _ref21.token;
1346
+ if (this.trustAuthorityId) {
1347
+ _context17.next = 3;
1348
+ break;
1349
+ }
1350
+ throw Error("Unable to authorize with OAuth token: No trust authority ID set");
1351
+ case 3:
1352
+ wallet = this.GenerateWallet();
1353
+ _context17.prev = 4;
1354
+ if (this.kmsURIs) {
1355
+ _context17.next = 17;
1356
+ break;
1357
+ }
1358
+ _context17.next = 8;
1359
+ return ElvClient.FromConfigurationUrl({
1360
+ configUrl: this.configUrl
1361
+ });
1362
+ case 8:
1363
+ client = _context17.sent;
1364
+ client.SetSigner({
1365
+ signer: wallet.AddAccountFromMnemonic({
1366
+ mnemonic: wallet.GenerateMnemonic()
1367
+ })
1368
+ });
1369
+ _context17.next = 12;
1370
+ return client.authClient.KMSInfo({
1371
+ kmsId: this.trustAuthorityId
1372
+ });
1373
+ case 12:
1374
+ _yield$client$authCli = _context17.sent;
1375
+ urls = _yield$client$authCli.urls;
1376
+ if (!(!urls || urls.length === 0)) {
1377
+ _context17.next = 16;
1378
+ break;
1379
+ }
1380
+ throw Error("Unable to authorize with OAuth token: No KMS URLs set");
1381
+ case 16:
1382
+ this.kmsURIs = urls;
1383
+ case 17:
1384
+ this.oauthToken = token;
1385
+ path = "/ks/jwt/wlt";
1386
+ httpClient = new HttpClient({
1387
+ uris: this.kmsURIs,
1388
+ debug: this.debug
1389
+ });
1390
+ _context17.next = 22;
1391
+ return this.utils.ResponseToJson(httpClient.Request({
1392
+ headers: {
1393
+ Authorization: "Bearer ".concat(token)
1394
+ },
1395
+ method: "PUT",
1396
+ path: path,
1397
+ forceFailover: true
1398
+ }));
1399
+ case 22:
1400
+ response = _context17.sent;
1401
+ privateKey = response["UserSKHex"];
1402
+ this.SetSigner({
1403
+ signer: wallet.AddAccount({
1404
+ privateKey: privateKey
1405
+ })
1406
+ });
1407
+
1408
+ // Ensure wallet is initialized
1409
+ _context17.next = 27;
1410
+ return this.userProfileClient.WalletAddress();
1411
+ case 27:
1412
+ _context17.next = 36;
1413
+ break;
1414
+ case 29:
1415
+ _context17.prev = 29;
1416
+ _context17.t0 = _context17["catch"](4);
1417
+ this.Log("Failed to set signer from OAuth token:", true);
1418
+ this.Log(_context17.t0, true);
1419
+ _context17.next = 35;
1420
+ return this.ClearSigner();
1421
+ case 35:
1422
+ throw _context17.t0;
1423
+ case 36:
1424
+ case "end":
1425
+ return _context17.stop();
1426
+ }
1427
+ }, _callee17, this, [[4, 29]]);
1428
+ }));
1429
+ function SetSignerFromOauthToken(_x12) {
1430
+ return _SetSignerFromOauthToken.apply(this, arguments);
1431
+ }
1432
+ return SetSignerFromOauthToken;
1433
+ }()
1434
+ /**
1435
+ * Create a static authorization token
1436
+ *
1437
+ * @methodGroup Authorization
1438
+ * @namedParams
1439
+ * @param {string=} libraryId - The library ID to associate with the static token
1440
+ *
1441
+ * @return {string} - The created static token
1442
+ */
1443
+ )
1444
+ }, {
1445
+ key: "CreateStaticToken",
1446
+ value: function CreateStaticToken(_ref22) {
1447
+ var libraryId = _ref22.libraryId;
1448
+ var token = {
1449
+ qspace_id: this.client.contentSpaceId
1450
+ };
1451
+ if (libraryId) {
1452
+ token.qlib_id = libraryId;
1453
+ }
1454
+ return Utils.B64(JSON.stringify(token));
1455
+ }
1456
+
1457
+ /**
1458
+ * Set a static token for the client to use for all authorization
1459
+ *
1460
+ * @methodGroup Authorization
1461
+ * @namedParams
1462
+ * @param {string=} token - The static token to use. If not provided, the default static token will be set.
1463
+ */
1464
+ }, {
1465
+ key: "SetStaticToken",
1466
+ value: function SetStaticToken() {
1467
+ var _ref23 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1468
+ token = _ref23.token;
1469
+ if (token) {
1470
+ this.staticToken = token;
1471
+ } else {
1472
+ this.staticToken = this.utils.B64(JSON.stringify({
1473
+ qspace_id: this.contentSpaceId
1474
+ }));
1475
+ }
1476
+ }
1477
+
1478
+ /**
1479
+ * Clear the set static token for the client
1480
+ */
1481
+ }, {
1482
+ key: "ClearStaticToken",
1483
+ value: function ClearStaticToken() {
1484
+ this.staticToken = undefined;
1485
+ }
1486
+
1487
+ /**
1488
+ * Authorize the client against the specified policy.
1489
+ *
1490
+ * NOTE: After authorizing, the client will only be able to access content allowed by the policy
1491
+ *
1492
+ * @methodGroup Authorization
1493
+ * @namedParams
1494
+ * @param {string} objectId - The ID of the policy object
1495
+ */
1496
+ }, {
1497
+ key: "SetPolicyAuthorization",
1498
+ value: (function () {
1499
+ var _SetPolicyAuthorization = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref24) {
1500
+ var objectId;
1501
+ return _regeneratorRuntime.wrap(function _callee18$(_context18) {
1502
+ while (1) switch (_context18.prev = _context18.next) {
1503
+ case 0:
1504
+ objectId = _ref24.objectId;
1505
+ _context18.t0 = this;
1506
+ _context18.next = 4;
1507
+ return this.GenerateStateChannelToken({
1508
+ objectId: objectId
1509
+ });
1510
+ case 4:
1511
+ _context18.t1 = _context18.sent;
1512
+ _context18.t2 = {
1513
+ token: _context18.t1
1514
+ };
1515
+ _context18.t0.SetStaticToken.call(_context18.t0, _context18.t2);
1516
+ case 7:
1517
+ case "end":
1518
+ return _context18.stop();
1519
+ }
1520
+ }, _callee18, this);
1521
+ }));
1522
+ function SetPolicyAuthorization(_x13) {
1523
+ return _SetPolicyAuthorization.apply(this, arguments);
1524
+ }
1525
+ return SetPolicyAuthorization;
1526
+ }()
1527
+ /**
1528
+ * Create a signature for the specified string
1529
+ *
1530
+ * @param {string} string - The string to sign
1531
+ * @return {Promise<string>} - The signed string
1532
+ */
1533
+ )
1534
+ }, {
1535
+ key: "Sign",
1536
+ value: (function () {
1537
+ var _Sign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(string) {
1538
+ var signature;
1539
+ return _regeneratorRuntime.wrap(function _callee19$(_context19) {
1540
+ while (1) switch (_context19.prev = _context19.next) {
1541
+ case 0:
1542
+ _context19.next = 2;
1543
+ return this.authClient.Sign(Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(string)));
1544
+ case 2:
1545
+ signature = _context19.sent;
1546
+ return _context19.abrupt("return", this.utils.FormatSignature(signature));
1547
+ case 4:
1548
+ case "end":
1549
+ return _context19.stop();
1550
+ }
1551
+ }, _callee19, this);
1552
+ }));
1553
+ function Sign(_x14) {
1554
+ return _Sign.apply(this, arguments);
1555
+ }
1556
+ return Sign;
1557
+ }()
1558
+ /**
1559
+ * Encrypt the given string or object with the current signer's public key
1560
+ *
1561
+ * @namedParams
1562
+ * @param {string | Object} message - The string or object to encrypt
1563
+ * @param {string=} publicKey - If specified, message will be encrypted with this public key instead of the current user's
1564
+ *
1565
+ * @return {Promise<string>} - The encrypted message
1566
+ */
1567
+ )
1568
+ }, {
1569
+ key: "EncryptECIES",
1570
+ value: (function () {
1571
+ var _EncryptECIES = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(_ref25) {
1572
+ var message, publicKey;
1573
+ return _regeneratorRuntime.wrap(function _callee20$(_context20) {
1574
+ while (1) switch (_context20.prev = _context20.next) {
1575
+ case 0:
1576
+ message = _ref25.message, publicKey = _ref25.publicKey;
1577
+ if (this.signer) {
1578
+ _context20.next = 3;
1579
+ break;
1580
+ }
1581
+ throw "Signer not set";
1582
+ case 3:
1583
+ ValidatePresence("message", message);
1584
+ _context20.next = 6;
1585
+ return this.Crypto.EncryptConk(message, publicKey || this.signer._signingKey().publicKey);
1586
+ case 6:
1587
+ return _context20.abrupt("return", _context20.sent);
1588
+ case 7:
1589
+ case "end":
1590
+ return _context20.stop();
1591
+ }
1592
+ }, _callee20, this);
1593
+ }));
1594
+ function EncryptECIES(_x15) {
1595
+ return _EncryptECIES.apply(this, arguments);
1596
+ }
1597
+ return EncryptECIES;
1598
+ }()
1599
+ /**
1600
+ * Decrypt the given encrypted message with the current signer's private key
1601
+ *
1602
+ * @namedParams
1603
+ * @param {string} message - The message to decrypt
1604
+ *
1605
+ * @return {Promise<string | Object>} - The decrypted string or object
1606
+ */
1607
+ )
1608
+ }, {
1609
+ key: "DecryptECIES",
1610
+ value: (function () {
1611
+ var _DecryptECIES = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(_ref26) {
1612
+ var message;
1613
+ return _regeneratorRuntime.wrap(function _callee21$(_context21) {
1614
+ while (1) switch (_context21.prev = _context21.next) {
1615
+ case 0:
1616
+ message = _ref26.message;
1617
+ if (this.signer) {
1618
+ _context21.next = 3;
1619
+ break;
1620
+ }
1621
+ throw "Signer not set";
1622
+ case 3:
1623
+ ValidatePresence("message", message);
1624
+ _context21.next = 6;
1625
+ return this.Crypto.DecryptCap(message, this.signer._signingKey().privateKey);
1626
+ case 6:
1627
+ return _context21.abrupt("return", _context21.sent);
1628
+ case 7:
1629
+ case "end":
1630
+ return _context21.stop();
1631
+ }
1632
+ }, _callee21, this);
1633
+ }));
1634
+ function DecryptECIES(_x16) {
1635
+ return _DecryptECIES.apply(this, arguments);
1636
+ }
1637
+ return DecryptECIES;
1638
+ }()
1639
+ /**
1640
+ * Request the specified URL with the given method and body, and return the result in the specified format
1641
+ *
1642
+ * @param {string} url - URL to request
1643
+ * @param {string=} format="json" - Format of response
1644
+ * @param {string=} method="GET" - Request method
1645
+ * @param {object=} body - Request body
1646
+ * @param {object=} headers - Request headers
1647
+ *
1648
+ * @return {Promise<*>} - Response in the specified format
1649
+ */
1650
+ )
1651
+ }, {
1652
+ key: "Request",
1653
+ value: (function () {
1654
+ var _Request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(_ref27) {
1655
+ var url, _ref27$format, format, _ref27$method, method, _ref27$headers, headers, body;
1656
+ return _regeneratorRuntime.wrap(function _callee22$(_context22) {
1657
+ while (1) switch (_context22.prev = _context22.next) {
1658
+ case 0:
1659
+ url = _ref27.url, _ref27$format = _ref27.format, format = _ref27$format === void 0 ? "json" : _ref27$format, _ref27$method = _ref27.method, method = _ref27$method === void 0 ? "GET" : _ref27$method, _ref27$headers = _ref27.headers, headers = _ref27$headers === void 0 ? {} : _ref27$headers, body = _ref27.body;
1660
+ return _context22.abrupt("return", this.utils.ResponseToFormat(format, HttpClient.Fetch(url, {
1661
+ method: method,
1662
+ headers: headers,
1663
+ body: body
1664
+ })));
1665
+ case 2:
1666
+ case "end":
1667
+ return _context22.stop();
1668
+ }
1669
+ }, _callee22, this);
1670
+ }));
1671
+ function Request(_x17) {
1672
+ return _Request.apply(this, arguments);
1673
+ }
1674
+ return Request;
1675
+ }())
1676
+ }, {
1677
+ key: "MakeAuthServiceRequest",
1678
+ value: function () {
1679
+ var _MakeAuthServiceRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23(_ref28) {
1680
+ var kmsId, objectId, versionHash, _ref28$method, method, path, bodyType, _ref28$body, body, _ref28$queryParams, queryParams, headers;
1681
+ return _regeneratorRuntime.wrap(function _callee23$(_context23) {
1682
+ while (1) switch (_context23.prev = _context23.next) {
1683
+ case 0:
1684
+ kmsId = _ref28.kmsId, objectId = _ref28.objectId, versionHash = _ref28.versionHash, _ref28$method = _ref28.method, method = _ref28$method === void 0 ? "GET" : _ref28$method, path = _ref28.path, bodyType = _ref28.bodyType, _ref28$body = _ref28.body, body = _ref28$body === void 0 ? {} : _ref28$body, _ref28$queryParams = _ref28.queryParams, queryParams = _ref28$queryParams === void 0 ? {} : _ref28$queryParams, headers = _ref28.headers;
1685
+ return _context23.abrupt("return", this.authClient.MakeAuthServiceRequest({
1686
+ kmsId: kmsId,
1687
+ objectId: objectId,
1688
+ versionHash: versionHash,
1689
+ method: method,
1690
+ path: path,
1691
+ bodyType: bodyType,
1692
+ body: body,
1693
+ queryParams: queryParams,
1694
+ headers: headers
1695
+ }));
1696
+ case 2:
1697
+ case "end":
1698
+ return _context23.stop();
1699
+ }
1700
+ }, _callee23, this);
1701
+ }));
1702
+ function MakeAuthServiceRequest(_x18) {
1703
+ return _MakeAuthServiceRequest.apply(this, arguments);
1704
+ }
1705
+ return MakeAuthServiceRequest;
1706
+ }()
1707
+ /* FrameClient related */
1708
+ // Whitelist of methods allowed to be called using the frame API
1709
+ }, {
1710
+ key: "FrameAllowedMethods",
1711
+ value: function FrameAllowedMethods() {
1712
+ var _this3 = this;
1713
+ var forbiddenMethods = ["constructor", "AccessGroupMembershipMethod", "CallFromFrameMessage", "ClearSigner", "CreateAccount", "EnableMethodLogging", "FormatBlockNumbers", "FrameAllowedMethods", "FromConfigurationUrl", "GenerateWallet", "InitializeClients", "Log", "PersonalSign", "SetRemoteSigner", "SetSigner", "SetSignerFromWeb3Provider", "Sign", "ToggleLogging"];
1714
+ return Object.getOwnPropertyNames(Object.getPrototypeOf(this)).filter(function (method) {
1715
+ return typeof _this3[method] === "function" && !forbiddenMethods.includes(method);
1716
+ });
1717
+ }
1718
+
1719
+ // Call a method specified in a message from a frame
1720
+ }, {
1721
+ key: "CallFromFrameMessage",
1722
+ value: function () {
1723
+ var _CallFromFrameMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24(message, Respond) {
1724
+ var _this4 = this;
1725
+ var callback, method, methodResults, responseError;
1726
+ return _regeneratorRuntime.wrap(function _callee24$(_context24) {
1727
+ while (1) switch (_context24.prev = _context24.next) {
1728
+ case 0:
1729
+ if (!(message.type !== "ElvFrameRequest")) {
1730
+ _context24.next = 2;
1731
+ break;
1732
+ }
1733
+ return _context24.abrupt("return");
1734
+ case 2:
1735
+ if (message.callbackId) {
1736
+ callback = function callback(result) {
1737
+ Respond(_this4.utils.MakeClonable({
1738
+ type: "ElvFrameResponse",
1739
+ requestId: message.callbackId,
1740
+ response: result
1741
+ }));
1742
+ };
1743
+ message.args.callback = callback;
1744
+ }
1745
+ _context24.prev = 3;
1746
+ method = message.calledMethod;
1747
+ if (!(message.module === "walletClient")) {
1748
+ _context24.next = 15;
1749
+ break;
1750
+ }
1751
+ if (this.walletClient) {
1752
+ _context24.next = 8;
1753
+ break;
1754
+ }
1755
+ throw Error("Wallet client not set");
1756
+ case 8:
1757
+ if (!this.walletClient.ForbiddenMethods().includes(method)) {
1758
+ _context24.next = 10;
1759
+ break;
1760
+ }
1761
+ throw Error("Invalid user profile method: " + method);
1762
+ case 10:
1763
+ _context24.next = 12;
1764
+ return this.walletClient[method](message.args);
1765
+ case 12:
1766
+ methodResults = _context24.sent;
1767
+ _context24.next = 28;
1768
+ break;
1769
+ case 15:
1770
+ if (!(message.module === "userProfileClient")) {
1771
+ _context24.next = 23;
1772
+ break;
1773
+ }
1774
+ if (this.userProfileClient.FrameAllowedMethods().includes(method)) {
1775
+ _context24.next = 18;
1776
+ break;
1777
+ }
1778
+ throw Error("Invalid user profile method: " + method);
1779
+ case 18:
1780
+ _context24.next = 20;
1781
+ return this.userProfileClient[method](message.args);
1782
+ case 20:
1783
+ methodResults = _context24.sent;
1784
+ _context24.next = 28;
1785
+ break;
1786
+ case 23:
1787
+ if (this.FrameAllowedMethods().includes(method)) {
1788
+ _context24.next = 25;
1789
+ break;
1790
+ }
1791
+ throw Error("Invalid method: " + method);
1792
+ case 25:
1793
+ _context24.next = 27;
1794
+ return this[method](message.args);
1795
+ case 27:
1796
+ methodResults = _context24.sent;
1797
+ case 28:
1798
+ Respond(this.utils.MakeClonable({
1799
+ type: "ElvFrameResponse",
1800
+ requestId: message.requestId,
1801
+ response: methodResults
1802
+ }));
1803
+ _context24.next = 37;
1804
+ break;
1805
+ case 31:
1806
+ _context24.prev = 31;
1807
+ _context24.t0 = _context24["catch"](3);
1808
+ // eslint-disable-next-line no-console
1809
+ this.Log("Frame Message Error:\n Method: ".concat(message.calledMethod, "\n Arguments: ").concat(JSON.stringify(message.args, null, 2), "\n Error: ").concat(_typeof(_context24.t0) === "object" ? JSON.stringify(_context24.t0, null, 2) : _context24.t0), true);
1810
+
1811
+ // eslint-disable-next-line no-console
1812
+ console.error(_context24.t0);
1813
+ responseError = _context24.t0 instanceof Error ? _context24.t0.message : _context24.t0;
1814
+ Respond(this.utils.MakeClonable({
1815
+ type: "ElvFrameResponse",
1816
+ requestId: message.requestId,
1817
+ error: responseError
1818
+ }));
1819
+ case 37:
1820
+ case "end":
1821
+ return _context24.stop();
1822
+ }
1823
+ }, _callee24, this, [[3, 31]]);
1824
+ }));
1825
+ function CallFromFrameMessage(_x19, _x20) {
1826
+ return _CallFromFrameMessage.apply(this, arguments);
1827
+ }
1828
+ return CallFromFrameMessage;
1829
+ }()
1830
+ }], [{
1831
+ key: "Configuration",
1832
+ value: (function () {
1833
+ var _Configuration = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25(_ref29) {
1834
+ var configUrl, _ref29$kmsUrls, kmsUrls, region, clientIP, uri, fabricInfo, filterHTTPS, fabricURIs, ethereumURIs, authServiceURIs, fileServiceURIs, searchURIs, fabricVersion;
1835
+ return _regeneratorRuntime.wrap(function _callee25$(_context25) {
1836
+ while (1) switch (_context25.prev = _context25.next) {
1837
+ case 0:
1838
+ configUrl = _ref29.configUrl, _ref29$kmsUrls = _ref29.kmsUrls, kmsUrls = _ref29$kmsUrls === void 0 ? [] : _ref29$kmsUrls, region = _ref29.region, clientIP = _ref29.clientIP;
1839
+ _context25.prev = 1;
1840
+ uri = new URI(configUrl);
1841
+ uri.pathname("/config");
1842
+ if (region) {
1843
+ uri.addSearch("elvgeo", region);
1844
+ }
1845
+ if (clientIP) {
1846
+ uri.addSearch("client_ip", clientIP);
1847
+ }
1848
+ _context25.next = 8;
1849
+ return Utils.ResponseToJson(HttpClient.Fetch(uri.toString()));
1850
+ case 8:
1851
+ fabricInfo = _context25.sent;
1852
+ // If any HTTPS urls present, throw away HTTP urls so only HTTPS will be used
1853
+ filterHTTPS = function filterHTTPS(uri) {
1854
+ return uri.toLowerCase().startsWith("https");
1855
+ };
1856
+ fabricURIs = fabricInfo.network.services.fabric_api;
1857
+ if (fabricURIs.find(filterHTTPS)) {
1858
+ fabricURIs = fabricURIs.filter(filterHTTPS);
1859
+ }
1860
+ ethereumURIs = fabricInfo.network.services.ethereum_api;
1861
+ if (ethereumURIs.find(filterHTTPS)) {
1862
+ ethereumURIs = ethereumURIs.filter(filterHTTPS);
1863
+ }
1864
+ authServiceURIs = fabricInfo.network.services.authority_service || [];
1865
+ if (authServiceURIs.find(filterHTTPS)) {
1866
+ authServiceURIs = authServiceURIs.filter(filterHTTPS);
1867
+ }
1868
+ fileServiceURIs = fabricInfo.network.services.file_service || fabricURIs;
1869
+ if (fileServiceURIs.find(filterHTTPS)) {
1870
+ fileServiceURIs = fileServiceURIs.filter(filterHTTPS);
1871
+ }
1872
+ searchURIs = fabricInfo.network.services.search || [];
1873
+ fabricVersion = Math.max.apply(Math, _toConsumableArray(fabricInfo.network.api_versions || [2]));
1874
+ return _context25.abrupt("return", {
1875
+ nodeId: fabricInfo.node_id,
1876
+ contentSpaceId: fabricInfo.qspace.id,
1877
+ networkId: (fabricInfo.qspace.ethereum || {}).network_id,
1878
+ networkName: ((fabricInfo.qspace || {}).names || [])[0],
1879
+ fabricURIs: fabricURIs,
1880
+ ethereumURIs: ethereumURIs,
1881
+ authServiceURIs: authServiceURIs,
1882
+ fileServiceURIs: fileServiceURIs,
1883
+ kmsURIs: kmsUrls,
1884
+ searchURIs: searchURIs,
1885
+ fabricVersion: fabricVersion
1886
+ });
1887
+ case 23:
1888
+ _context25.prev = 23;
1889
+ _context25.t0 = _context25["catch"](1);
1890
+ // eslint-disable-next-line no-console
1891
+ console.error("Error retrieving fabric configuration:");
1892
+ // eslint-disable-next-line no-console
1893
+ console.error(_context25.t0);
1894
+ throw _context25.t0;
1895
+ case 28:
1896
+ case "end":
1897
+ return _context25.stop();
1898
+ }
1899
+ }, _callee25, null, [[1, 23]]);
1900
+ }));
1901
+ function Configuration(_x21) {
1902
+ return _Configuration.apply(this, arguments);
1903
+ }
1904
+ return Configuration;
1905
+ }()
1906
+ /**
1907
+ * Return a list of valid Eluvio Content Fabric network names and their associated configuration URLs
1908
+ *
1909
+ * @methodGroup Miscellaneous
1910
+ *
1911
+ * @return {Object} - An object using network names as keys and configuration URLs as values.
1912
+ */
1913
+ )
1914
+ }, {
1915
+ key: "Networks",
1916
+ value: function Networks() {
1917
+ return Object.assign({}, networks);
1918
+ }
1919
+
1920
+ /**
1921
+ * Create a new ElvClient for the specified network
1922
+ *
1923
+ * @methodGroup Constructor
1924
+ * @namedParams
1925
+ * @param {string} networkName - Name of the network to connect to ("main", "demo", "test)
1926
+ * @param {string=} region - Preferred region - the fabric will auto-detect the best region if not specified
1927
+ * - Available regions: as-east, au-east, eu-east-north, eu-west-north, na-east-north, na-east-south, na-west-north, na-west-south, eu-east-south, eu-west-south
1928
+ * @param {string=} clientIP - IP address to use in determining the region to use
1929
+ * @param {string=} trustAuthorityId - (OAuth) The ID of the trust authority to use for OAuth authentication * @param {boolean=} noCache=false - If enabled, blockchain transactions will not be cached
1930
+ * @param {string=} staticToken - Static token that will be used for all authorization in place of normal auth
1931
+ * @param {number=} ethereumContractTimeout=10 - Number of seconds to wait for contract calls
1932
+ * @param {boolean=} noAuth=false - If enabled, blockchain authorization will not be performed
1933
+ *
1934
+ * @return {Promise<ElvClient>} - New ElvClient connected to the specified content fabric and blockchain
1935
+ */
1936
+ }, {
1937
+ key: "FromNetworkName",
1938
+ value: (function () {
1939
+ var _FromNetworkName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26(_ref30) {
1940
+ var networkName, region, clientIP, trustAuthorityId, staticToken, _ref30$ethereumContra, ethereumContractTimeout, _ref30$noCache, noCache, _ref30$noAuth, noAuth, assumeV3, configUrl;
1941
+ return _regeneratorRuntime.wrap(function _callee26$(_context26) {
1942
+ while (1) switch (_context26.prev = _context26.next) {
1943
+ case 0:
1944
+ networkName = _ref30.networkName, region = _ref30.region, clientIP = _ref30.clientIP, trustAuthorityId = _ref30.trustAuthorityId, staticToken = _ref30.staticToken, _ref30$ethereumContra = _ref30.ethereumContractTimeout, ethereumContractTimeout = _ref30$ethereumContra === void 0 ? 10 : _ref30$ethereumContra, _ref30$noCache = _ref30.noCache, noCache = _ref30$noCache === void 0 ? false : _ref30$noCache, _ref30$noAuth = _ref30.noAuth, noAuth = _ref30$noAuth === void 0 ? false : _ref30$noAuth, assumeV3 = _ref30.assumeV3;
1945
+ configUrl = networks[networkName];
1946
+ if (configUrl) {
1947
+ _context26.next = 4;
1948
+ break;
1949
+ }
1950
+ throw Error("Invalid network name: " + networkName);
1951
+ case 4:
1952
+ _context26.next = 6;
1953
+ return this.FromConfigurationUrl({
1954
+ configUrl: configUrl,
1955
+ region: region,
1956
+ clientIP: clientIP,
1957
+ trustAuthorityId: trustAuthorityId,
1958
+ staticToken: staticToken,
1959
+ ethereumContractTimeout: ethereumContractTimeout,
1960
+ noCache: noCache,
1961
+ noAuth: noAuth,
1962
+ assumeV3: assumeV3
1963
+ });
1964
+ case 6:
1965
+ return _context26.abrupt("return", _context26.sent);
1966
+ case 7:
1967
+ case "end":
1968
+ return _context26.stop();
1969
+ }
1970
+ }, _callee26, this);
1971
+ }));
1972
+ function FromNetworkName(_x22) {
1973
+ return _FromNetworkName.apply(this, arguments);
1974
+ }
1975
+ return FromNetworkName;
1976
+ }()
1977
+ /**
1978
+ * Create a new ElvClient from the specified configuration URL
1979
+ *
1980
+ * @methodGroup Constructor
1981
+ * @namedParams
1982
+ * @param {string} configUrl - Full URL to the config endpoint
1983
+ * @param {string=} region - Preferred region - the fabric will auto-detect the best region if not specified
1984
+ * - Available regions: as-east, au-east, eu-east-north, eu-west-north, na-east-north, na-east-south, na-west-north, na-west-south, eu-east-south, eu-west-south
1985
+ * @param {string=} clientIP - IP address to use in determining the region to use
1986
+ * @param {string=} trustAuthorityId - (OAuth) The ID of the trust authority to use for OAuth authentication * @param {boolean=} noCache=false - If enabled, blockchain transactions will not be cached
1987
+ * @param {string=} staticToken - Static token that will be used for all authorization in place of normal auth
1988
+ * @param {number=} ethereumContractTimeout=10 - Number of seconds to wait for contract calls
1989
+ * @param {boolean=} noAuth=false - If enabled, blockchain authorization will not be performed
1990
+ *
1991
+ * @return {Promise<ElvClient>} - New ElvClient connected to the specified content fabric and blockchain
1992
+ */
1993
+ )
1994
+ }, {
1995
+ key: "FromConfigurationUrl",
1996
+ value: (function () {
1997
+ var _FromConfigurationUrl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee27(_ref31) {
1998
+ var configUrl, region, clientIP, trustAuthorityId, staticToken, _ref31$ethereumContra, ethereumContractTimeout, _ref31$noCache, noCache, _ref31$noAuth, noAuth, _ref31$assumeV, assumeV3, _yield$ElvClient$Conf3, contentSpaceId, networkId, networkName, fabricURIs, ethereumURIs, authServiceURIs, fileServiceURIs, searchURIs, fabricVersion, client;
1999
+ return _regeneratorRuntime.wrap(function _callee27$(_context27) {
2000
+ while (1) switch (_context27.prev = _context27.next) {
2001
+ case 0:
2002
+ configUrl = _ref31.configUrl, region = _ref31.region, clientIP = _ref31.clientIP, trustAuthorityId = _ref31.trustAuthorityId, staticToken = _ref31.staticToken, _ref31$ethereumContra = _ref31.ethereumContractTimeout, ethereumContractTimeout = _ref31$ethereumContra === void 0 ? 10 : _ref31$ethereumContra, _ref31$noCache = _ref31.noCache, noCache = _ref31$noCache === void 0 ? false : _ref31$noCache, _ref31$noAuth = _ref31.noAuth, noAuth = _ref31$noAuth === void 0 ? false : _ref31$noAuth, _ref31$assumeV = _ref31.assumeV3, assumeV3 = _ref31$assumeV === void 0 ? false : _ref31$assumeV;
2003
+ _context27.next = 3;
2004
+ return ElvClient.Configuration({
2005
+ configUrl: configUrl,
2006
+ clientIP: clientIP,
2007
+ region: region
2008
+ });
2009
+ case 3:
2010
+ _yield$ElvClient$Conf3 = _context27.sent;
2011
+ contentSpaceId = _yield$ElvClient$Conf3.contentSpaceId;
2012
+ networkId = _yield$ElvClient$Conf3.networkId;
2013
+ networkName = _yield$ElvClient$Conf3.networkName;
2014
+ fabricURIs = _yield$ElvClient$Conf3.fabricURIs;
2015
+ ethereumURIs = _yield$ElvClient$Conf3.ethereumURIs;
2016
+ authServiceURIs = _yield$ElvClient$Conf3.authServiceURIs;
2017
+ fileServiceURIs = _yield$ElvClient$Conf3.fileServiceURIs;
2018
+ searchURIs = _yield$ElvClient$Conf3.searchURIs;
2019
+ fabricVersion = _yield$ElvClient$Conf3.fabricVersion;
2020
+ client = new ElvClient({
2021
+ contentSpaceId: contentSpaceId,
2022
+ networkId: networkId,
2023
+ networkName: networkName,
2024
+ fabricVersion: fabricVersion,
2025
+ fabricURIs: fabricURIs,
2026
+ ethereumURIs: ethereumURIs,
2027
+ authServiceURIs: authServiceURIs,
2028
+ fileServiceURIs: fileServiceURIs,
2029
+ searchURIs: searchURIs,
2030
+ ethereumContractTimeout: ethereumContractTimeout,
2031
+ trustAuthorityId: trustAuthorityId,
2032
+ staticToken: staticToken,
2033
+ noCache: noCache,
2034
+ noAuth: noAuth,
2035
+ assumeV3: assumeV3
2036
+ });
2037
+ client.configUrl = configUrl;
2038
+ client.region = region;
2039
+ client.clientIP = clientIP;
2040
+ return _context27.abrupt("return", client);
2041
+ case 18:
2042
+ case "end":
2043
+ return _context27.stop();
2044
+ }
2045
+ }, _callee27);
2046
+ }));
2047
+ function FromConfigurationUrl(_x23) {
2048
+ return _FromConfigurationUrl.apply(this, arguments);
2049
+ }
2050
+ return FromConfigurationUrl;
2051
+ }())
2052
+ }]);
2053
+ }();
2054
+ Object.assign(ElvClient.prototype, require("./client/AccessGroups"));
2055
+ Object.assign(ElvClient.prototype, require("./client/ContentAccess"));
2056
+ Object.assign(ElvClient.prototype, require("./client/Contracts"));
2057
+ Object.assign(ElvClient.prototype, require("./client/Files"));
2058
+ Object.assign(ElvClient.prototype, require("./client/ABRPublishing"));
2059
+ Object.assign(ElvClient.prototype, require("./client/LiveStream"));
2060
+ Object.assign(ElvClient.prototype, require("./client/ContentManagement"));
2061
+ Object.assign(ElvClient.prototype, require("./client/NTP"));
2062
+ Object.assign(ElvClient.prototype, require("./client/NFT"));
2063
+ exports.ElvClient = ElvClient;