@barekey/cli 0.5.0 → 0.5.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.
@@ -35,6 +35,10 @@ function resolveVerificationUri(baseUrl, verificationUri) {
35
35
  }
36
36
  return verificationUri;
37
37
  }
38
+ function resolveDisplayName(input) {
39
+ const displayName = input.displayName?.trim();
40
+ return displayName && displayName.length > 0 ? displayName : input.clerkUserId;
41
+ }
38
42
  async function runLogin(options) {
39
43
  const baseUrl = await resolveBaseUrl(options.baseUrl);
40
44
  intro("Barekey CLI login");
@@ -89,6 +93,8 @@ async function runLogin(options) {
89
93
  orgId: poll.orgId,
90
94
  orgSlug: poll.orgSlug,
91
95
  clerkUserId: poll.clerkUserId,
96
+ displayName: poll.displayName,
97
+ email: poll.email,
92
98
  });
93
99
  const sessionId = buildSessionId(baseUrl, refreshed.clerkUserId);
94
100
  await saveCredentials(sessionId, {
@@ -108,7 +114,7 @@ async function runLogin(options) {
108
114
  });
109
115
  pollSpinner.stop("Login approved");
110
116
  pollActive = false;
111
- outro(`Logged in as ${pc.bold(refreshed.clerkUserId)}.`);
117
+ outro(`Signed in as ${pc.bold(resolveDisplayName(refreshed))}.`);
112
118
  return;
113
119
  }
114
120
  pollSpinner.stop("Timed out");
@@ -152,9 +158,10 @@ async function runWhoami(options) {
152
158
  toJsonOutput(true, session);
153
159
  return;
154
160
  }
155
- console.log(`${pc.bold("User")}: ${session.clerkUserId}`);
156
- console.log(`${pc.bold("Current org")}: ${session.orgSlug}`);
157
- console.log(`${pc.bold("Source")}: ${session.source}`);
161
+ console.log(resolveDisplayName(session));
162
+ if (session.email !== null) {
163
+ console.log(session.email);
164
+ }
158
165
  }
159
166
  export function registerAuthCommands(program) {
160
167
  const auth = program.command("auth").description("Authentication commands");
@@ -5,12 +5,9 @@ import { getJson, postJson } from "../http.js";
5
5
  import { promptForOrganizationSlug } from "./target-prompts.js";
6
6
  async function runBillingCatalog(options) {
7
7
  const local = await requireLocalSession();
8
- const authProvider = createCliAuthProvider();
9
- const accessToken = await authProvider.getAccessToken();
10
8
  const response = await getJson({
11
9
  baseUrl: local.baseUrl,
12
10
  path: "/v1/cli/billing/catalog",
13
- accessToken,
14
11
  schema: BillingCatalogResponseSchema,
15
12
  });
16
13
  if (options.json) {
@@ -51,6 +51,8 @@ export declare const ErrorEnvelopeSchema: Schema.Struct<{
51
51
  }>;
52
52
  export declare const CliSessionResponseSchema: Schema.Struct<{
53
53
  clerkUserId: typeof Schema.String;
54
+ displayName: Schema.NullOr<typeof Schema.String>;
55
+ email: Schema.NullOr<typeof Schema.String>;
54
56
  orgId: typeof Schema.String;
55
57
  orgSlug: typeof Schema.String;
56
58
  source: Schema.Literal<["clerk", "cli"]>;
@@ -79,6 +81,8 @@ export declare const DevicePollApprovedSchema: Schema.Struct<{
79
81
  orgId: typeof Schema.String;
80
82
  orgSlug: typeof Schema.String;
81
83
  clerkUserId: typeof Schema.String;
84
+ displayName: Schema.NullOr<typeof Schema.String>;
85
+ email: Schema.NullOr<typeof Schema.String>;
82
86
  requestId: Schema.optional<typeof Schema.String>;
83
87
  }>;
84
88
  export declare const DevicePollResponseSchema: Schema.Union<[Schema.Struct<{
@@ -95,6 +99,8 @@ export declare const DevicePollResponseSchema: Schema.Union<[Schema.Struct<{
95
99
  orgId: typeof Schema.String;
96
100
  orgSlug: typeof Schema.String;
97
101
  clerkUserId: typeof Schema.String;
102
+ displayName: Schema.NullOr<typeof Schema.String>;
103
+ email: Schema.NullOr<typeof Schema.String>;
98
104
  requestId: Schema.optional<typeof Schema.String>;
99
105
  }>]>;
100
106
  export declare const RefreshResponseSchema: Schema.Struct<{
@@ -105,6 +111,8 @@ export declare const RefreshResponseSchema: Schema.Struct<{
105
111
  orgId: typeof Schema.String;
106
112
  orgSlug: typeof Schema.String;
107
113
  clerkUserId: typeof Schema.String;
114
+ displayName: Schema.NullOr<typeof Schema.String>;
115
+ email: Schema.NullOr<typeof Schema.String>;
108
116
  requestId: Schema.optional<typeof Schema.String>;
109
117
  }>;
110
118
  export declare const EnvDecisionSchema: Schema.Struct<{
@@ -53,6 +53,8 @@ export const ErrorEnvelopeSchema = Schema.Struct({
53
53
  });
54
54
  export const CliSessionResponseSchema = Schema.Struct({
55
55
  clerkUserId: Schema.String,
56
+ displayName: Schema.NullOr(Schema.String),
57
+ email: Schema.NullOr(Schema.String),
56
58
  orgId: Schema.String,
57
59
  orgSlug: Schema.String,
58
60
  source: Schema.Literal("clerk", "cli"),
@@ -81,6 +83,8 @@ export const DevicePollApprovedSchema = Schema.Struct({
81
83
  orgId: Schema.String,
82
84
  orgSlug: Schema.String,
83
85
  clerkUserId: Schema.String,
86
+ displayName: Schema.NullOr(Schema.String),
87
+ email: Schema.NullOr(Schema.String),
84
88
  requestId: Schema.optional(Schema.String),
85
89
  });
86
90
  export const DevicePollResponseSchema = Schema.Union(DevicePollPendingSchema, DevicePollApprovedSchema);
@@ -92,6 +96,8 @@ export const RefreshResponseSchema = Schema.Struct({
92
96
  orgId: Schema.String,
93
97
  orgSlug: Schema.String,
94
98
  clerkUserId: Schema.String,
99
+ displayName: Schema.NullOr(Schema.String),
100
+ email: Schema.NullOr(Schema.String),
95
101
  requestId: Schema.optional(Schema.String),
96
102
  });
97
103
  export const EnvDecisionSchema = Schema.Struct({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barekey/cli",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Barekey command line interface",
5
5
  "type": "module",
6
6
  "bin": {
@@ -57,6 +57,14 @@ function resolveVerificationUri(baseUrl: string, verificationUri: string): strin
57
57
  return verificationUri;
58
58
  }
59
59
 
60
+ function resolveDisplayName(input: {
61
+ displayName: string | null;
62
+ clerkUserId: string;
63
+ }): string {
64
+ const displayName = input.displayName?.trim();
65
+ return displayName && displayName.length > 0 ? displayName : input.clerkUserId;
66
+ }
67
+
60
68
  async function runLogin(options: { baseUrl?: string }): Promise<void> {
61
69
  const baseUrl = await resolveBaseUrl(options.baseUrl);
62
70
  intro("Barekey CLI login");
@@ -117,6 +125,8 @@ async function runLogin(options: { baseUrl?: string }): Promise<void> {
117
125
  orgId: poll.orgId,
118
126
  orgSlug: poll.orgSlug,
119
127
  clerkUserId: poll.clerkUserId,
128
+ displayName: poll.displayName,
129
+ email: poll.email,
120
130
  });
121
131
  const sessionId = buildSessionId(baseUrl, refreshed.clerkUserId);
122
132
 
@@ -138,7 +148,7 @@ async function runLogin(options: { baseUrl?: string }): Promise<void> {
138
148
 
139
149
  pollSpinner.stop("Login approved");
140
150
  pollActive = false;
141
- outro(`Logged in as ${pc.bold(refreshed.clerkUserId)}.`);
151
+ outro(`Signed in as ${pc.bold(resolveDisplayName(refreshed))}.`);
142
152
  return;
143
153
  }
144
154
 
@@ -186,9 +196,10 @@ async function runWhoami(options: { json?: boolean }): Promise<void> {
186
196
  return;
187
197
  }
188
198
 
189
- console.log(`${pc.bold("User")}: ${session.clerkUserId}`);
190
- console.log(`${pc.bold("Current org")}: ${session.orgSlug}`);
191
- console.log(`${pc.bold("Source")}: ${session.source}`);
199
+ console.log(resolveDisplayName(session));
200
+ if (session.email !== null) {
201
+ console.log(session.email);
202
+ }
192
203
  }
193
204
 
194
205
  export function registerAuthCommands(program: Command): void {
@@ -8,12 +8,9 @@ import { promptForOrganizationSlug } from "./target-prompts.js";
8
8
 
9
9
  async function runBillingCatalog(options: { json?: boolean }) {
10
10
  const local = await requireLocalSession();
11
- const authProvider = createCliAuthProvider();
12
- const accessToken = await authProvider.getAccessToken();
13
11
  const response = await getJson({
14
12
  baseUrl: local.baseUrl,
15
13
  path: "/v1/cli/billing/catalog",
16
- accessToken,
17
14
  schema: BillingCatalogResponseSchema,
18
15
  });
19
16
 
@@ -75,6 +75,8 @@ export const ErrorEnvelopeSchema = Schema.Struct({
75
75
 
76
76
  export const CliSessionResponseSchema = Schema.Struct({
77
77
  clerkUserId: Schema.String,
78
+ displayName: Schema.NullOr(Schema.String),
79
+ email: Schema.NullOr(Schema.String),
78
80
  orgId: Schema.String,
79
81
  orgSlug: Schema.String,
80
82
  source: Schema.Literal("clerk", "cli"),
@@ -106,6 +108,8 @@ export const DevicePollApprovedSchema = Schema.Struct({
106
108
  orgId: Schema.String,
107
109
  orgSlug: Schema.String,
108
110
  clerkUserId: Schema.String,
111
+ displayName: Schema.NullOr(Schema.String),
112
+ email: Schema.NullOr(Schema.String),
109
113
  requestId: Schema.optional(Schema.String),
110
114
  });
111
115
 
@@ -122,6 +126,8 @@ export const RefreshResponseSchema = Schema.Struct({
122
126
  orgId: Schema.String,
123
127
  orgSlug: Schema.String,
124
128
  clerkUserId: Schema.String,
129
+ displayName: Schema.NullOr(Schema.String),
130
+ email: Schema.NullOr(Schema.String),
125
131
  requestId: Schema.optional(Schema.String),
126
132
  });
127
133