para-cli 1.22.2 → 1.22.4

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 +16 -4
  2. package/package.json +2 -2
  3. package/para-cli.js +8 -7
package/index.js CHANGED
@@ -262,7 +262,7 @@ export function newKeys(pc, config) {
262
262
  });
263
263
  }
264
264
 
265
- export function newJWT(accessKey, secretKey, endpoint, config) {
265
+ export function newJWT(accessKey, secretKey, endpoint, config, flags) {
266
266
  if (!accessKey || accessKey.length < 3 || !secretKey || secretKey.length < 6) {
267
267
  fail('Invalid credentials.');
268
268
  return;
@@ -275,11 +275,22 @@ export function newJWT(accessKey, secretKey, endpoint, config) {
275
275
  nbf: now - 5, // allow for 5 seconds time difference in clocks
276
276
  appid: accessKey
277
277
  });
278
- config.set('accessKey', accessKey);
279
- config.set('secretKey', secretKey);
278
+ var selectedApp = config.get('selectedApp');
279
+ if (selectedApp && selectedApp.secretKey) {
280
+ selectedApp.accessKey = accessKey;
281
+ selectedApp.secretKey = secretKey;
282
+ config.set('selectedApp', selectedApp);
283
+ } else {
284
+ config.set('accessKey', accessKey);
285
+ config.set('secretKey', secretKey);
286
+ }
280
287
  config.set('endpoint', endpoint || config.get('endpoint'));
281
288
  config.set('jwt', sign(sClaim, secretKey, { algorithm: 'HS256' }));
282
- console.log(green('✔'), 'New JWT generated and saved in', yellow(config.path));
289
+ if (flags.print) {
290
+ console.log(yellow(config.get('jwt')));
291
+ } else {
292
+ console.log(green('✔'), 'New JWT generated and saved in', yellow(config.path));
293
+ }
283
294
  }
284
295
 
285
296
  export function newApp(pc, input, flags) {
@@ -507,6 +518,7 @@ export function selectApp(input, config, flags) {
507
518
  var jwt = sign(JSON.stringify({
508
519
  iat: now,
509
520
  exp: now + 10,
521
+ nbf: now - 5, // allow for 5 seconds time difference in clocks
510
522
  appid: accessKey,
511
523
  getCredentials: selectedApp
512
524
  }), secretKey, { algorithm: 'HS256' });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "para-cli",
3
- "version": "1.22.2",
3
+ "version": "1.22.4",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Command-line tool for Para backend servers",
6
6
  "homepage": "https://paraio.org",
@@ -44,7 +44,7 @@
44
44
  "jsonwebtoken": "^9.0.3",
45
45
  "meow": "^14.0.0",
46
46
  "mime-types": "^3.0.2",
47
- "para-client-js": "^1.40.2",
47
+ "para-client-js": "^1.40.3",
48
48
  "resolve": "^1.22.11",
49
49
  "striptags": "^3.2.0",
50
50
  "update-notifier": "^7.3.1",
package/para-cli.js CHANGED
@@ -44,8 +44,8 @@ var cli = meow(`
44
44
  setup Initial setup, prompts you to enter your Para API keys and endpoint
45
45
  apps Returns a list of all Para apps
46
46
  types Returns an object containing all currently defined data types in Para
47
- select <appid> Selects a Para app as a target for all subsequent read/write requests.
48
- endpoints [add|remove] List and select Para server endpoints, add new or remove an exiting one.
47
+ select <appid> Selects a Para app as a target for all subsequent read/write requests
48
+ endpoints [add|remove] List and select Para server endpoints, add new or remove an exiting one
49
49
  create <file|glob> [--id] [--type] Persists files as Para objects and makes them searchable
50
50
  read --id 123 [--id 345 ...] Fetches objects with the given ids
51
51
  update <file.json|glob> ... Updates Para objects with the data from a JSON file (must contain id field)
@@ -54,9 +54,9 @@ var cli = meow(`
54
54
  rebuild-index Rebuilds the entire search index
55
55
  app-settings Returns all settings for the authenticated app
56
56
  new-key Generates a new secret key and saves it to config.json
57
- new-jwt Generates a new JWT super token to be used for app authentication
58
- new-app <name> --name --shared Creates a new Para app. Only works if you have the keys for the "root" app
59
- delete-app <id> Deletes an existing Para app. Only works for child apps, not the "root" app
57
+ new-jwt Generates a new JWT super token to be used for app authentication (use --print for console output)
58
+ new-app <name> --name --shared Creates a new Para app (only works if you have the keys for the "root" app)
59
+ delete-app <id> Deletes an existing Para app (only works for child apps, not the "root" app)
60
60
  export Exports all data from the app's table
61
61
  import <file> Imports data from a previously exported ZIP archive
62
62
  ping Tests the connection to the Para server
@@ -75,7 +75,7 @@ var cli = meow(`
75
75
  --limit Limits the number of search results
76
76
  --lastKey Sets the last id for search-after pagination
77
77
  --cwd Sets the current directory - used for resolving file paths
78
- --encodeId By default all ids are Base64 encoded, unless this is 'false'
78
+ --encodeId By default all ids are Base64 encoded, unless this is set to 'false'
79
79
  --help Prints the list of commands
80
80
  --version Prints the version of the program
81
81
 
@@ -89,6 +89,7 @@ var cli = meow(`
89
89
  $ para-cli search "*" --type article --page all
90
90
  $ para-cli new-key
91
91
  $ para-cli new-app "mynewapp" --name "Full app name"
92
+ $ para-cli new-jwt --print
92
93
  $ para-cli apps
93
94
  $ para-cli types
94
95
  $ para-cli select scoold
@@ -181,7 +182,7 @@ if (!input[0]) {
181
182
  }
182
183
 
183
184
  if (input[0] === 'new-jwt') {
184
- newJWT(accessKey, secretKey, endpoint, config);
185
+ newJWT(accessKey, secretKey, endpoint, config, flags);
185
186
  }
186
187
 
187
188
  if (input[0] === 'new-app') {