@superblocksteam/sdk 1.10.0 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.txt ADDED
@@ -0,0 +1,87 @@
1
+ Superblocks Community Software License
2
+
3
+ This Superblocks Community License Agreement (the “Agreement”) sets forth the terms on which DayZero
4
+ Software, Inc. d/b/a Superblocks (“Superblocks”) makes available certain software made available by Superblocks
5
+ under this Agreement (the “Software”). BY INSTALLING, DOWNLOADING, ACCESSING, USING OR
6
+ DISTRIBUTING ANY OF THE SOFTWARE, YOU AGREE TO THE TERMS AND CONDITIONS OF THIS
7
+ AGREEMENT.IF YOU DO NOT AGREE TO SUCH TERMS AND CONDITIONS, YOU MUST NOT USE THE
8
+ SOFTWARE. IF YOU ARE RECEIVING THE SOFTWARE ON BEHALF OF A LEGAL ENTITY, YOU
9
+ REPRESENT AND WARRANT THAT YOU HAVE THE ACTUAL AUTHORITY TO AGREE TO THE
10
+ TERMS AND CONDITIONS OF THIS AGREEMENT ON BEHALF OF SUCH ENTITY. “Licensee” means you,
11
+ an individual, or the entity on whose behalf you are receiving the Software.
12
+
13
+ 1. LICENSE GRANT AND CONDITIONS.
14
+
15
+ 1.1 License. Subject to the terms and conditions of this Agreement, Superblocks hereby grants to Licensee a
16
+ non-exclusive, royalty-free, worldwide, non-transferable, non-sublicenseable license during the term of this
17
+ Agreement to: (a) use the Software; (b) prepare modifications and derivative works of the Software; (c)
18
+ distribute the Software (including without limitation in source code or object code form); and (d) reproduce
19
+ copies of the Software (the “License”). Licensee is not granted the right to, and Licensee shall not, exercise the
20
+ License for an Excluded Purpose. For purposes of this Agreement, “Excluded Purpose” means making
21
+ available any software-as-a-service, platform-as-a-service, infrastructure-as-a-service or other similar online
22
+ service that competes with Superblocks’ products or services.
23
+
24
+ 1.2 Conditions. In consideration of the License, Licensee’s distribution of the Software is subject to the
25
+ following conditions:
26
+
27
+ a. Licensee must cause any Software modified by Licensee to carry prominent notices stating that Licensee
28
+ modified the Software.
29
+ b. On each Software copy, Licensee shall reproduce and not remove or alter all Superblocks or third party
30
+ copyright or other proprietary notices contained in the Software, and Licensee must provide the notice
31
+ below with each copy.
32
+
33
+ “This software is made available by DayZero Software, Inc. d/b/a Superblocks, under the terms of the
34
+ Superblocks Community License Agreement. © 2022 DayZero Software, Inc.”
35
+
36
+ 1.3 Licensee Modifications. Licensee may add its own copyright notices to modifications made by Licensee
37
+ and may provide additional or different license terms and conditions for use, reproduction, or distribution of
38
+ Licensee’s modifications. While redistributing the Software or modifications thereof, Licensee may choose to
39
+ offer, for a fee or free of charge, support, warranty, indemnity, or other obligations. Licensee, and not
40
+ Superblocks, will be responsible for any such obligations.
41
+
42
+ 1.4 No Sublicensing. The License does not include the right to sublicense the Software, however, each recipient
43
+ to which Licensee provides the Software may exercise the Licenses so long as such recipient agrees to the terms
44
+ and conditions of this Agreement.
45
+
46
+ 2. TERM AND TERMINATION. This Agreement will continue unless and until earlier terminated as set forth
47
+ herein. If Licensee breaches any of its conditions or obligations under this Agreement, this Agreement will
48
+ terminate automatically and the License will terminate automatically and permanently.
49
+
50
+ 3. INTELLECTUAL PROPERTY. As between the parties, Superblocks will retain all right, title, and interest in
51
+ the Software, and all intellectual property rights therein. Superblocks hereby reserves all rights not expressly
52
+ granted to Licensee in this Agreement. Superblocks hereby reserves all rights in its trademarks and service
53
+ marks, and no licenses therein are granted in this Agreement.
54
+
55
+ 4. DISCLAIMER. SUPERBLOCKS HEREBY DISCLAIMS ANY AND ALL WARRANTIES AND
56
+ CONDITIONS, EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, AND SPECIFICALLY
57
+ DISCLAIMS ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
58
+ PURPOSE, WITH RESPECT TO THE SOFTWARE.
59
+
60
+ 5. LIMITATION OF LIABILITY. SUPERBLOCKS WILL NOT BE LIABLE FOR ANY DAMAGES OF
61
+ ANY KIND, INCLUDING BUT NOT LIMITED TO, LOST PROFITS OR ANY CONSEQUENTIAL,
62
+ SPECIAL, INCIDENTAL, INDIRECT, OR DIRECT DAMAGES, HOWEVER CAUSED AND ON ANY
63
+ THEORY OF LIABILITY, ARISING OUT OF THIS AGREEMENT. THE FOREGOING SHALL APPLY TO
64
+ THE EXTENT PERMITTED BY APPLICABLE LAW.
65
+
66
+ 6. GENERAL.
67
+
68
+ 6.1  Governing Law. This Agreement will be governed by and interpreted in accordance with the laws of the
69
+ state of California, without reference to its conflict of laws principles. If Licensee is located within the United
70
+ States, all disputes arising out of this Agreement are subject to the exclusive jurisdiction of courts located in San
71
+ Mateo County, California. USA. If Licensee is located outside of the United States, any dispute, controversy or
72
+ claim arising out of or relating to this Agreement will be referred to and finally determined by arbitration in
73
+ accordance with the JAMS International Arbitration Rules. The tribunal will consist of one neutral arbitrator.
74
+ The place of arbitration will be Palo Alto, California. The language to be used in the arbitral proceedings will be
75
+ English. Judgment upon the award rendered by the arbitrator may be entered in any court having jurisdiction
76
+ thereof.
77
+
78
+ 6.2.  Assignment. Licensee may not assign its rights under this Agreement to any third party. Superblocks may
79
+ freely assign its rights under this Agreement to any third party.
80
+
81
+ 6.3.  Other.  This Agreement is the entire agreement between the parties regarding the subject matter hereof.
82
+ No amendment or modification of this Agreement will be valid or binding upon the parties unless made in
83
+ writing and signed by the duly authorized representatives of both parties. In the event that any provision,
84
+ including without limitation any condition, of this Agreement is held to be unenforceable, this Agreement and
85
+ all licenses and rights granted hereunder will immediately terminate. Waiver by Superblocks of a breach of any
86
+ provision of this Agreement or the failure by Superblocks to exercise any right hereunder will not be construed
87
+ as a waiver of any subsequent breach of that right or as a waiver of any other right.
package/dist/client.js CHANGED
@@ -1,11 +1,60 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
2
38
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchApiCommits = exports.fetchApplicationCommits = exports.pushApi = exports.pushApplication = exports.createSocketConnectionIfNeeded = exports.fetchCurrentUser = exports.uploadComponents = exports.registerComponents = exports.validateGitSetup = exports.fetchApis = exports.fetchApi = exports.fetchApplications = exports.fetchApplicationWithComponents = exports.fetchApplicationBranches = exports.fetchApplication = void 0;
4
- const tslib_1 = require("tslib");
5
- const fs = tslib_1.__importStar(require("fs"));
39
+ exports.createSocketConnectionIfNeeded = void 0;
40
+ exports.fetchApplication = fetchApplication;
41
+ exports.fetchApplicationBranches = fetchApplicationBranches;
42
+ exports.fetchApplicationWithComponents = fetchApplicationWithComponents;
43
+ exports.fetchApplications = fetchApplications;
44
+ exports.fetchApi = fetchApi;
45
+ exports.fetchApis = fetchApis;
46
+ exports.validateGitSetup = validateGitSetup;
47
+ exports.registerComponents = registerComponents;
48
+ exports.uploadComponents = uploadComponents;
49
+ exports.fetchCurrentUser = fetchCurrentUser;
50
+ exports.pushApplication = pushApplication;
51
+ exports.pushApi = pushApi;
52
+ exports.fetchApplicationCommits = fetchApplicationCommits;
53
+ exports.fetchApiCommits = fetchApiCommits;
54
+ const fs = __importStar(require("fs"));
6
55
  const util_1 = require("@superblocksteam/util");
7
- const axios_1 = tslib_1.__importStar(require("axios"));
8
- const form_data_1 = tslib_1.__importDefault(require("form-data"));
56
+ const axios_1 = __importStar(require("axios"));
57
+ const form_data_1 = __importDefault(require("form-data"));
9
58
  const lodash_1 = require("lodash");
10
59
  const errors_1 = require("./errors");
11
60
  const flag_1 = require("./flag");
@@ -69,7 +118,6 @@ async function fetchApplication({ cliVersion, applicationId, branch, token, supe
69
118
  throw new Error(`Could not fetch application: ${typeof e === "object" && e && "message" in e ? e.message : e}`);
70
119
  }
71
120
  }
72
- exports.fetchApplication = fetchApplication;
73
121
  async function fetchApplicationBranches({ cliVersion, applicationId, token, superblocksBaseUrl, injectedHeaders = {}, }) {
74
122
  const serverURL = new URL(`public/applications/${applicationId}/branches`, superblocksBaseUrl);
75
123
  let serverResponse;
@@ -93,7 +141,6 @@ async function fetchApplicationBranches({ cliVersion, applicationId, token, supe
93
141
  }
94
142
  return serverResponse?.data?.data;
95
143
  }
96
- exports.fetchApplicationBranches = fetchApplicationBranches;
97
144
  async function fetchApplicationWithComponents({ cliVersion, applicationId, branch, token, superblocksBaseUrl, viewMode, commitId, skipSigningVerification = false, injectedHeaders = {}, }) {
98
145
  const applicationWrapper = await fetchApplication({
99
146
  cliVersion,
@@ -145,7 +192,6 @@ async function fetchApplicationWithComponents({ cliVersion, applicationId, branc
145
192
  throw new Error("Could not fetch application");
146
193
  }
147
194
  }
148
- exports.fetchApplicationWithComponents = fetchApplicationWithComponents;
149
195
  async function fetchApplications(cliVersion, token, superblocksBaseUrl, injectedHeaders = {}) {
150
196
  try {
151
197
  const config = {
@@ -167,8 +213,7 @@ async function fetchApplications(cliVersion, token, superblocksBaseUrl, injected
167
213
  e.response?.data?.responseMeta?.message ??
168
214
  JSON.stringify(e.response?.data) ??
169
215
  e.response?.statusText ??
170
- e?.message ??
171
- `${e}`;
216
+ e?.message;
172
217
  }
173
218
  else {
174
219
  message = `${e?.message ? e?.message : e}`;
@@ -176,7 +221,6 @@ async function fetchApplications(cliVersion, token, superblocksBaseUrl, injected
176
221
  throw new Error(`Could not fetch applications: ${message}`);
177
222
  }
178
223
  }
179
- exports.fetchApplications = fetchApplications;
180
224
  async function fetchApi(cliVersion, apiId, token, superblocksBaseUrl, viewMode, branch, commitId, skipSigningVerification = false) {
181
225
  try {
182
226
  const serverURL = branch
@@ -222,7 +266,6 @@ async function fetchApi(cliVersion, apiId, token, superblocksBaseUrl, viewMode,
222
266
  throw new Error(`Could not fetch api: ${typeof e === "object" && e && "message" in e ? e.message : e}`);
223
267
  }
224
268
  }
225
- exports.fetchApi = fetchApi;
226
269
  async function fetchApis(cliVersion, token, superblocksBaseUrl) {
227
270
  try {
228
271
  const config = {
@@ -236,11 +279,10 @@ async function fetchApis(cliVersion, token, superblocksBaseUrl) {
236
279
  const response = await (0, axios_1.default)(config);
237
280
  return response.data.data.apis;
238
281
  }
239
- catch (e) {
282
+ catch {
240
283
  throw new Error("Could not fetch apis");
241
284
  }
242
285
  }
243
- exports.fetchApis = fetchApis;
244
286
  async function validateGitSetup(cliVersion, resourceId, resourceType, event, localGitRepoState, token, superblocksBaseUrl, injectedHeaders) {
245
287
  let resourceName;
246
288
  try {
@@ -290,8 +332,7 @@ async function validateGitSetup(cliVersion, resourceId, resourceType, event, loc
290
332
  e.response?.data?.responseMeta?.message ??
291
333
  JSON.stringify(e.response?.data) ??
292
334
  e.response?.statusText ??
293
- e?.message ??
294
- `${e}`;
335
+ e?.message;
295
336
  }
296
337
  else {
297
338
  message = `${e?.message ? e.message : e}`;
@@ -307,7 +348,6 @@ async function validateGitSetup(cliVersion, resourceId, resourceType, event, loc
307
348
  }
308
349
  }
309
350
  }
310
- exports.validateGitSetup = validateGitSetup;
311
351
  async function registerComponents(cliVersion, applicationId, componentConfigs, token, superblocksBaseUrl, branch, injectedHeaders) {
312
352
  try {
313
353
  const branchPath = branch ? `/branches/${encodeURIComponent(branch)}` : "";
@@ -348,7 +388,6 @@ async function registerComponents(cliVersion, applicationId, componentConfigs, t
348
388
  throw new Error(`Could not register application components ${e.message ? "\n" + e.message : ""}`);
349
389
  }
350
390
  }
351
- exports.registerComponents = registerComponents;
352
391
  async function uploadComponents({ cliVersion, applicationId, componentConfigs, files, token, superblocksBaseUrl, branch, }) {
353
392
  superblocksBaseUrl = superblocksBaseUrl.replace(/\/$/, "");
354
393
  const bucketeerBaseUrl = (0, util_1.getBucketeerUrlFromSuperblocksUrl)(superblocksBaseUrl);
@@ -447,7 +486,6 @@ You can reduce your component bundle size by uploading static assets to a separa
447
486
  }
448
487
  }
449
488
  }
450
- exports.uploadComponents = uploadComponents;
451
489
  async function fetchCurrentUser(cliVersion, token, superblocksBaseUrl) {
452
490
  try {
453
491
  const config = {
@@ -469,8 +507,7 @@ async function fetchCurrentUser(cliVersion, token, superblocksBaseUrl) {
469
507
  e.response?.data?.responseMeta?.message ??
470
508
  JSON.stringify(e.response?.data) ??
471
509
  e.response?.statusText ??
472
- e?.message ??
473
- `${e}`;
510
+ e?.message;
474
511
  }
475
512
  else {
476
513
  message = `${e?.message ? e?.message : e}`;
@@ -478,7 +515,6 @@ async function fetchCurrentUser(cliVersion, token, superblocksBaseUrl) {
478
515
  throw new Error(`Could not fetch current user: ${message}`);
479
516
  }
480
517
  }
481
- exports.fetchCurrentUser = fetchCurrentUser;
482
518
  const createSocketConnectionIfNeeded = async (cliVersion, token, superblocksBaseUrl) => {
483
519
  const userMe = await fetchCurrentUser(cliVersion, token, superblocksBaseUrl);
484
520
  const organization = userMe.organizations[0];
@@ -563,7 +599,6 @@ async function pushApplication({ cliVersion, applicationId, token, superblocksBa
563
599
  throw new Error(`Could not push application ${e.message ? "\n" + e.message : ""}`);
564
600
  }
565
601
  }
566
- exports.pushApplication = pushApplication;
567
602
  async function pushApi({ cliVersion, apiId, token, superblocksBaseUrl, apiConfig, branch, injectedHeaders = {}, }) {
568
603
  const handleHttpError = (status) => {
569
604
  if (status === 405) {
@@ -631,7 +666,6 @@ async function pushApi({ cliVersion, apiId, token, superblocksBaseUrl, apiConfig
631
666
  throw new Error(`Could not push api ${e.message ? "\n" + e.message : ""}`);
632
667
  }
633
668
  }
634
- exports.pushApi = pushApi;
635
669
  async function fetchApplicationCommits({ cliVersion, applicationId, branch, token, superblocksBaseUrl, injectedHeaders = {}, limit, offset, }) {
636
670
  try {
637
671
  const serverURL = branch
@@ -661,7 +695,6 @@ async function fetchApplicationCommits({ cliVersion, applicationId, branch, toke
661
695
  throw new Error("Could not fetch application");
662
696
  }
663
697
  }
664
- exports.fetchApplicationCommits = fetchApplicationCommits;
665
698
  async function fetchApiCommits({ cliVersion, applicationId, branch, token, superblocksBaseUrl, injectedHeaders = {}, limit, offset, }) {
666
699
  try {
667
700
  const serverURL = branch
@@ -691,4 +724,3 @@ async function fetchApiCommits({ cliVersion, applicationId, branch, token, super
691
724
  throw new Error("Could not fetch application");
692
725
  }
693
726
  }
694
- exports.fetchApiCommits = fetchApiCommits;
package/dist/flag.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { FlagBootstrap } from "./types";
2
2
  export declare const signingEnabled: (flags: FlagBootstrap) => boolean;
3
- export declare const DEFAULT_LINES_FOR_LARGE_STEPS = 10;
3
+ export declare const DEFAULT_LINES_FOR_LARGE_STEPS = 1;
4
4
  export declare class FeatureFlags {
5
5
  private flags;
6
6
  constructor(flags: FlagBootstrap);
package/dist/flag.js CHANGED
@@ -5,8 +5,9 @@ const signingEnabled = (flags) => {
5
5
  return flags["ui.enable-resource-signing"] ?? false;
6
6
  };
7
7
  exports.signingEnabled = signingEnabled;
8
- exports.DEFAULT_LINES_FOR_LARGE_STEPS = 10;
8
+ exports.DEFAULT_LINES_FOR_LARGE_STEPS = 1;
9
9
  class FeatureFlags {
10
+ flags;
10
11
  constructor(flags) {
11
12
  this.flags = flags;
12
13
  }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from "./client";
2
2
  export * from "./flag";
3
3
  export * from "./sdk";
4
+ export * from "./types";
package/dist/index.js CHANGED
@@ -1,6 +1,20 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./client"), exports);
5
- tslib_1.__exportStar(require("./flag"), exports);
6
- tslib_1.__exportStar(require("./sdk"), exports);
17
+ __exportStar(require("./client"), exports);
18
+ __exportStar(require("./flag"), exports);
19
+ __exportStar(require("./sdk"), exports);
20
+ __exportStar(require("./types"), exports);
package/dist/sdk.js CHANGED
@@ -1,16 +1,29 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
17
  exports.SuperblocksSdk = void 0;
4
- const tslib_1 = require("tslib");
5
18
  const client_1 = require("./client");
6
19
  const flag_1 = require("./flag");
7
20
  // Exporting here instead of index.ts because only sdk.ts is exposed outside in package.json
8
- tslib_1.__exportStar(require("./errors"), exports);
21
+ __exportStar(require("./errors"), exports);
9
22
  class SuperblocksSdk {
23
+ token = "";
24
+ superblocksBaseUrl = "";
25
+ cliVersion = "";
10
26
  constructor(accessToken, superblocksBaseUrl, cliVersion) {
11
- this.token = "";
12
- this.superblocksBaseUrl = "";
13
- this.cliVersion = "";
14
27
  this.token = accessToken;
15
28
  this.superblocksBaseUrl = superblocksBaseUrl;
16
29
  this.cliVersion = cliVersion;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createRequestHandlers = void 0;
3
+ exports.createRequestHandlers = createRequestHandlers;
4
4
  const signing_1 = require("./signing");
5
5
  function createRequestHandlers({ agentUrl, token, }) {
6
6
  const requestHandlers = {
@@ -94,4 +94,3 @@ function createRequestHandlers({ agentUrl, token, }) {
94
94
  };
95
95
  return requestHandlers;
96
96
  }
97
- exports.createRequestHandlers = createRequestHandlers;
@@ -1,8 +1,13 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.connectWebSocket = exports.connectISocket = exports.ISocketWithClientAuth = exports.connectToISocketRPCServer = void 0;
4
- const tslib_1 = require("tslib");
5
- const ws_1 = tslib_1.__importDefault(require("ws"));
6
+ exports.ISocketWithClientAuth = void 0;
7
+ exports.connectToISocketRPCServer = connectToISocketRPCServer;
8
+ exports.connectISocket = connectISocket;
9
+ exports.connectWebSocket = connectWebSocket;
10
+ const ws_1 = __importDefault(require("ws"));
6
11
  const handlers_1 = require("./handlers");
7
12
  const socket_1 = require("./socket");
8
13
  async function connectToISocketRPCServer({ superblocksBaseUrl, agentUrl, token, }) {
@@ -25,18 +30,18 @@ async function connectToISocketRPCServer({ superblocksBaseUrl, agentUrl, token,
25
30
  wsUrl.hostname = "127.0.0.1";
26
31
  }
27
32
  return await connectISocket(wsUrl.href, authorization, requestHandlers, [], {
28
- connectionTimeoutInSeconds: 6 * 60,
33
+ connectionTimeoutInSeconds: 6 * 60, // 6 minutes
29
34
  noResponseTimeoutInSeconds: 5 * 60, // 5 minutes
30
35
  });
31
36
  }
32
- exports.connectToISocketRPCServer = connectToISocketRPCServer;
33
37
  // a subclass of ISocket that sends an auth token on the first request
34
38
  // this is useful for client-side sockets that need to authenticate
35
39
  // TODO(george): if we start using this for long-lived connections, we should add a way to refresh the token
36
40
  class ISocketWithClientAuth extends socket_1.ISocket {
41
+ authorization;
42
+ hasSentAuth = false;
37
43
  constructor(ws, authorization, requestHandlers, globalMiddlewares, timeouts) {
38
44
  super(ws, requestHandlers, globalMiddlewares, timeouts);
39
- this.hasSentAuth = false;
40
45
  this.authorization = authorization;
41
46
  }
42
47
  // override `request` from the base class to send `authorization` when appropriate
@@ -54,7 +59,6 @@ async function connectISocket(wsUrl, authorization, requestHandlers, globalMiddl
54
59
  const isocket = new ISocketWithClientAuth(ws, authorization, requestHandlers, globalMiddlewares, timeouts);
55
60
  return (0, socket_1.createISocketClient)(isocket);
56
61
  }
57
- exports.connectISocket = connectISocket;
58
62
  function connectWebSocket(wsUrl) {
59
63
  return new Promise((resolve, reject) => {
60
64
  const ws = new ws_1.default(wsUrl);
@@ -70,4 +74,3 @@ function connectWebSocket(wsUrl) {
70
74
  });
71
75
  });
72
76
  }
73
- exports.connectWebSocket = connectWebSocket;
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.verifyResources = exports.signResource = void 0;
4
- const tslib_1 = require("tslib");
5
- const axios_1 = tslib_1.__importDefault(require("axios"));
6
+ exports.signResource = signResource;
7
+ exports.verifyResources = verifyResources;
8
+ const axios_1 = __importDefault(require("axios"));
6
9
  const utils_1 = require("../utils");
7
10
  async function signResource({ token, branchName, resource, agentUrl, }) {
8
11
  const requestResource = {
@@ -24,7 +27,6 @@ async function signResource({ token, branchName, resource, agentUrl, }) {
24
27
  });
25
28
  return resp.signature;
26
29
  }
27
- exports.signResource = signResource;
28
30
  async function verifyResources({ agentUrl, token, branchName, resources, }) {
29
31
  await callAgent({
30
32
  baseUrl: agentUrl,
@@ -48,7 +50,6 @@ async function verifyResources({ agentUrl, token, branchName, resources, }) {
48
50
  },
49
51
  });
50
52
  }
51
- exports.verifyResources = verifyResources;
52
53
  async function callAgent({ baseUrl, path, method, token, data, }) {
53
54
  try {
54
55
  const url = new URL(path, baseUrl);
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createISocketClient = exports.ISocket = void 0;
3
+ exports.ISocket = void 0;
4
+ exports.createISocketClient = createISocketClient;
4
5
  const types_1 = require("../types");
5
6
  /**
6
7
  * ISocket is a class that wraps a WebSocket connection and provides a simple interface for sending and receiving messages.
@@ -16,8 +17,17 @@ const types_1 = require("../types");
16
17
  * It is expected that timeouts should be relatively sorted in the order of connection timeout > request timeout > no response timeout.
17
18
  */
18
19
  class ISocket {
20
+ ws;
21
+ requestHandlers;
22
+ globalMiddlewares;
23
+ responseHandler = new Map();
24
+ peerAuthorization;
25
+ nxtRequestId;
26
+ connectionTimeout;
27
+ // pino library not available in shared
28
+ logger;
29
+ timeouts;
19
30
  constructor(ws, requestHandlers, globalMiddlewares, timeouts, logger) {
20
- this.responseHandler = new Map();
21
31
  this.ws = ws;
22
32
  this.requestHandlers = requestHandlers;
23
33
  this.globalMiddlewares = globalMiddlewares;
@@ -29,6 +39,7 @@ class ISocket {
29
39
  this.ws.addEventListener("message",
30
40
  // eslint-disable-next-line @typescript-eslint/no-misused-promises
31
41
  async (event) => {
42
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
32
43
  const eventData = JSON.parse(event.data.toString());
33
44
  return this.handleMessage(eventData);
34
45
  });
@@ -125,6 +136,7 @@ class ISocket {
125
136
  const requestId = ++this.nxtRequestId;
126
137
  this.responseHandler.set(requestId, {
127
138
  resolve: (result) => resolve(result),
139
+ // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
128
140
  reject: (error) => reject(error),
129
141
  });
130
142
  const toSend = {
@@ -247,4 +259,3 @@ function createISocketClient(socket) {
247
259
  call: createIsocketProxy(socket, undefined),
248
260
  };
249
261
  }
250
- exports.createISocketClient = createISocketClient;
@@ -17,6 +17,11 @@ var AgentType;
17
17
  AgentType[AgentType["ONPREMISE"] = 2] = "ONPREMISE";
18
18
  })(AgentType || (exports.AgentType = AgentType = {}));
19
19
  class Profile {
20
+ id;
21
+ key;
22
+ displayName;
23
+ description;
24
+ type;
20
25
  constructor({ id, key, displayName, description, type, }) {
21
26
  this.id = id;
22
27
  this.key = key;
@@ -1,7 +1,20 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./common"), exports);
5
- tslib_1.__exportStar(require("./socket"), exports);
6
- tslib_1.__exportStar(require("./plugin"), exports);
7
- tslib_1.__exportStar(require("./signing"), exports);
17
+ __exportStar(require("./common"), exports);
18
+ __exportStar(require("./socket"), exports);
19
+ __exportStar(require("./plugin"), exports);
20
+ __exportStar(require("./signing"), exports);
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SocketErrorException = void 0;
4
4
  /** The exception type can be thrown to cause the default error handler to write a raw error response to the socket */
5
5
  class SocketErrorException extends Error {
6
+ code;
7
+ message;
6
8
  constructor(code, message) {
7
9
  super(message);
8
10
  this.code = code;
package/dist/utils.js CHANGED
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSanitizedApi = exports.sanitizeV2RequestBody = exports.getAgentUrl = void 0;
4
- const tslib_1 = require("tslib");
5
- const axios_1 = tslib_1.__importDefault(require("axios"));
6
+ exports.getSanitizedApi = exports.sanitizeV2RequestBody = void 0;
7
+ exports.getAgentUrl = getAgentUrl;
8
+ const axios_1 = __importDefault(require("axios"));
6
9
  const types_1 = require("./types");
7
10
  async function getAgentUrl(agents, agentType, profile, healthCheck = true) {
8
11
  let filtered = agents.filter((a) => a.type === agentType && a.status === types_1.AgentStatus.ACTIVE);
@@ -28,7 +31,7 @@ async function getAgentUrl(agents, agentType, profile, healthCheck = true) {
28
31
  try {
29
32
  return await Promise.any(coroutines);
30
33
  }
31
- catch (e) {
34
+ catch {
32
35
  throw new Error("No available agents");
33
36
  }
34
37
  }
@@ -37,7 +40,6 @@ async function getAgentUrl(agents, agentType, profile, healthCheck = true) {
37
40
  return filtered[randomIndex].url;
38
41
  }
39
42
  }
40
- exports.getAgentUrl = getAgentUrl;
41
43
  const sanitizeV2RequestBody = (apiBody) => {
42
44
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
43
45
  const traverseJSON = (obj) => {