@trycourier/cli 2.7.0 → 2.7.1

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.
@@ -1,11 +1,10 @@
1
- import { Text } from 'ink';
1
+ import { Box, Text } from 'ink';
2
2
  import _ from 'lodash';
3
3
  import React, { useEffect, useState } from 'react';
4
4
  import { useBoolean } from 'usehooks-ts';
5
5
  import { useCliContext } from '../components/Context.js';
6
6
  import Spinner from '../components/Spinner.js';
7
7
  import UhOh from '../components/UhOh.js';
8
- import { stdout } from 'process';
9
8
  const VALID_SCOPE_PREFIXES = [
10
9
  'read:messages',
11
10
  'read:user-tokens',
@@ -17,19 +16,23 @@ const VALID_SCOPE_PREFIXES = [
17
16
  'read:preferences',
18
17
  'write:preferences',
19
18
  ];
19
+ const ALL = VALID_SCOPE_PREFIXES.filter(s => !s.endsWith('brand'));
20
20
  const UserToken = () => {
21
21
  const { parsedParams, getJWT } = useCliContext();
22
22
  const running = useBoolean(true);
23
23
  const [jwt, setJWT] = useState();
24
+ const [final_scopes, setFinalScopes] = useState([]);
24
25
  const [error, setError] = useState();
25
- const { expiration, scopes, _: [user_id], } = parsedParams;
26
+ const { expiration, scopes, all, _: [user_id], } = parsedParams;
26
27
  useEffect(() => {
27
28
  getUserJWT();
28
29
  }, []);
29
30
  const getUserJWT = async () => {
30
31
  const exp = Number(expiration);
31
- const sc = (scopes?.split(',') || []).map(s => s.trim());
32
+ const scope_input = scopes?.split(',') || [];
33
+ const sc = [...new Set([...scope_input, ...(all ? ALL : [])])];
32
34
  const invalid_scopes = sc.filter(scope => !_.some(VALID_SCOPE_PREFIXES, val => scope.startsWith(val)));
35
+ setFinalScopes([`user_id:${user_id}`, ...sc]);
33
36
  if (!user_id) {
34
37
  setError('No User Specified');
35
38
  }
@@ -64,8 +67,12 @@ const UserToken = () => {
64
67
  return React.createElement(Spinner, { text: `Fetching JWT` });
65
68
  }
66
69
  else {
67
- stdout.write(jwt ?? '');
68
- return React.createElement(Text, null, jwt);
70
+ return (React.createElement(React.Fragment, null,
71
+ React.createElement(Text, null, "Token has the following scopes:"),
72
+ React.createElement(Text, null, final_scopes.join(' ')),
73
+ React.createElement(Box, { flexDirection: "column", marginY: 1, borderColor: "gray", borderStyle: 'single', borderTop: false, borderLeft: false, borderRight: false }),
74
+ React.createElement(Text, null, jwt),
75
+ React.createElement(Box, { flexDirection: "column", marginY: 1, borderColor: "gray", borderStyle: 'single', borderBottom: false, borderLeft: false, borderRight: false })));
69
76
  }
70
77
  };
71
78
  export default UserToken;
@@ -5,7 +5,7 @@ import React, { useEffect } from 'react';
5
5
  import { useCliContext } from './Context.js';
6
6
  import constants from '../constants.js';
7
7
  const Version = () => {
8
- const { version, setVersion, map } = useCliContext();
8
+ const { version, setVersion, map, parsedParams } = useCliContext();
9
9
  useEffect(() => {
10
10
  getVersion();
11
11
  }, []);
@@ -29,7 +29,7 @@ const Version = () => {
29
29
  ? `Upgrade available (${version.current} > ${version.latest}), run courier upgrade`
30
30
  : undefined;
31
31
  if (version_text?.length) {
32
- if (map === 'upgrade') {
32
+ if (map === 'upgrade' || _.get(parsedParams, ['quiet'], false)) {
33
33
  return React.createElement(React.Fragment, null);
34
34
  }
35
35
  else {
package/dist/mappings.js CHANGED
@@ -536,7 +536,11 @@ mappings.set('users:jwt', {
536
536
  options: [
537
537
  {
538
538
  option: '--scopes',
539
- value: 'Required. The scopes to attach to the JWT. We will provide the user_id scope automatically, all others will be comma seperated (https://www.courier.com/docs/reference/auth/issue-token/#available-scopes).',
539
+ value: 'Required if not using all. The scopes to attach to the JWT. We will provide the user_id scope automatically, all others will be comma seperated (https://www.courier.com/docs/reference/auth/issue-token/#available-scopes).',
540
+ },
541
+ {
542
+ option: '--all',
543
+ value: 'Include all scopes besides brand scopes.',
540
544
  },
541
545
  {
542
546
  option: '--expiration',
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
- let VERSION = '2.7.0';
1
+ let VERSION = '2.7.1';
2
2
  export default VERSION;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trycourier/cli",
3
- "version": "2.7.0",
3
+ "version": "2.7.1",
4
4
  "license": "MIT",
5
5
  "bin": {
6
6
  "courier": "dist/cli.js"