para-cli 1.20.0 → 1.20.2

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 (3) hide show
  1. package/index.js +17 -4
  2. package/package.json +7 -7
  3. package/para-cli.js +2 -2
package/index.js CHANGED
@@ -61,7 +61,7 @@ export function setup(config) {
61
61
  var secret = (secretKey || config.get('secretKey')).trim();
62
62
  var endpoint = (endpoint || config.get('endpoint')).trim();
63
63
  newJWT(access, secret, endpoint, config);
64
- var pc = new ParaClient(access, secret, { endpoint: endpoint || defaultConfig.endpoint });
64
+ var pc = new ParaClient(access, secret, parseEndpoint(endpoint || defaultConfig.endpoint));
65
65
  ping(pc, config);
66
66
  if (access === 'app:para') {
67
67
  listApps(config, {}, access, function () {
@@ -462,7 +462,7 @@ export function listApps(config, flags, parentAccessKey, failureCallback) {
462
462
  var accessKey = selectedEndpoint.accessKey;
463
463
  var secretKey = selectedEndpoint.secretKey;
464
464
  var endpoint = selectedEndpoint.endpoint;
465
- var pc = new ParaClient(accessKey, secretKey, {endpoint: endpoint});
465
+ var pc = new ParaClient(accessKey, secretKey, parseEndpoint(endpoint));
466
466
  var p = new Pager();
467
467
  var results = [];
468
468
  p.sortby = '_docid';
@@ -503,7 +503,7 @@ export function selectApp(input, config, flags) {
503
503
  appid: accessKey,
504
504
  getCredentials: selectedApp
505
505
  }), secretKey, { algorithm: 'HS256' });
506
- var paraClient = new ParaClient(accessKey, secretKey, { endpoint: endpoint });
506
+ var paraClient = new ParaClient(accessKey, secretKey, parseEndpoint(endpoint));
507
507
  paraClient.setAccessToken(jwt);
508
508
  paraClient.me(jwt).then(function (data) {
509
509
  if (data && data.credentials) {
@@ -553,7 +553,7 @@ export function addEndpoint(config) {
553
553
  return;
554
554
  }
555
555
  rl.question(cyan.bold('Para Secret Key (for root app app:para): '), function (secretKey) {
556
- var pc = new ParaClient("app:para", secretKey, {endpoint: endpoint});
556
+ var pc = new ParaClient("app:para", secretKey, parseEndpoint(endpoint));
557
557
  var endpoints = config.get('endpoints') || [];
558
558
  var existing = false;
559
559
  for (var i = 0; i < endpoints.length; i++) {
@@ -622,6 +622,19 @@ export function selectEndpoint(config, flags) {
622
622
  });
623
623
  }
624
624
 
625
+ export function parseEndpoint(endpoint) {
626
+ try {
627
+ var url = new URL(endpoint);
628
+ if (url.pathname !== '/') {
629
+ var x = { endpoint: url.protocol + '//' + url.host, apiPath: url.pathname.replace(/\/*$/, '') + '/v1/' };
630
+ return x;
631
+ }
632
+ } catch (e) {
633
+ fail('Invalid Para endpoint:', endpoint);
634
+ }
635
+ return { endpoint: endpoint };
636
+ }
637
+
625
638
  function getSelectedEndpoint(config, flags) {
626
639
  var accessKey = flags.accessKey || process.env.PARA_ACCESS_KEY || config.get('accessKey');
627
640
  var secretKey = flags.secretKey || process.env.PARA_SECRET_KEY || config.get('secretKey');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "para-cli",
3
- "version": "1.20.0",
3
+ "version": "1.20.2",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Command-line tool for Para backend servers",
6
6
  "homepage": "https://paraio.org",
@@ -24,22 +24,22 @@
24
24
  "api"
25
25
  ],
26
26
  "devDependencies": {
27
- "eslint": "^8.29.0"
27
+ "eslint": "^8.32.0"
28
28
  },
29
29
  "repository": "Erudika/para-cli",
30
30
  "dependencies": {
31
31
  "brace-expansion": "^2.0.1",
32
- "chalk": "^5.1.2",
33
- "conf": "^10.2.0",
32
+ "chalk": "^5.2.0",
33
+ "conf": "^11.0.1",
34
34
  "exit": "^0.1.2",
35
35
  "figlet": "^1.5.2",
36
36
  "get-stdin": "^9.0.0",
37
- "globby": "^13.1.2",
37
+ "globby": "^13.1.3",
38
38
  "htmlparser2": "^8.0.1",
39
- "jsonwebtoken": "^8.5.1",
39
+ "jsonwebtoken": "^9.0.0",
40
40
  "meow": "^11.0.0",
41
41
  "mime-types": "^2.1.35",
42
- "para-client-js": "^1.38.0",
42
+ "para-client-js": "^1.38.1",
43
43
  "resolve": "^1.22.1",
44
44
  "striptags": "^3.2.0",
45
45
  "update-notifier": "^6.0.2",
package/para-cli.js CHANGED
@@ -28,7 +28,7 @@ import figlet from 'figlet';
28
28
  import chalk from 'chalk';
29
29
  import meow from 'meow';
30
30
  import {
31
- defaultConfig, setup, listApps, selectEndpoint, addEndpoint, removeEndpoint, selectApp, createAll, readAll,
31
+ defaultConfig, setup, listApps, parseEndpoint, selectEndpoint, addEndpoint, removeEndpoint, selectApp, createAll, readAll,
32
32
  updateAll, deleteAll, search, newKeys, newJWT, newApp, deleteApp, ping, me, appSettings, rebuildIndex, exportData, importData
33
33
  } from './index.js';
34
34
 
@@ -129,7 +129,7 @@ if (!input[0]) {
129
129
  process.exitCode = 1;
130
130
  setup(config);
131
131
  } else {
132
- var pc = new ParaClient(accessKey, secretKey, { endpoint: endpoint });
132
+ var pc = new ParaClient(accessKey, secretKey, parseEndpoint(endpoint));
133
133
 
134
134
  if (input[0] === 'setup') {
135
135
  setup(config);