@sixb/cli 0.1.12 → 0.1.14

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/README.md CHANGED
@@ -243,8 +243,10 @@ sixb objects inspect Customer customer-123
243
243
 
244
244
  An auth-disabled local API stores a tokenless profile. Authenticated APIs use a short-lived device
245
245
  code: the browser approves the request through the existing session, and the CLI stores the
246
- one-time personal access token only after validating it against `/api/project`. Use `--token-stdin`
247
- for automation or when you already have a token.
246
+ session's tokens only after validating them against `/api/project`. The access token lasts 15
247
+ minutes; each command renews it with the refresh token when it is about to expire, so one login
248
+ lasts until the session goes unused past its idle timeout (30 days by default). `sixb logout` ends
249
+ the session on the server. Use `--token-stdin` for automation or when you already have a token.
248
250
 
249
251
  Remote target resolution is deterministic:
250
252
 
@@ -8,6 +8,7 @@ export interface ApiOptions {
8
8
  apiPublicOrigin?: string;
9
9
  atlasPublicOrigin?: string;
10
10
  appPublicOrigin?: string;
11
+ trustedProxies?: string;
11
12
  }
12
13
  export declare function runApi(options?: ApiOptions): Promise<void>;
13
14
  //# sourceMappingURL=api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/commands/api.tsx"],"names":[],"mappings":"AAUA,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAED,wBAAsB,MAAM,CAAC,OAAO,GAAE,UAAe,iBA2FpD"}
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/commands/api.tsx"],"names":[],"mappings":"AAUA,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAED,wBAAsB,MAAM,CAAC,OAAO,GAAE,UAAe,iBAgGpD"}
@@ -1 +1 @@
1
- {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/commands/login.tsx"],"names":[],"mappings":"AAKA,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAA;IAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CACxB;AAED,wBAAsB,QAAQ,CAAC,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CA8C/E"}
1
+ {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/commands/login.tsx"],"names":[],"mappings":"AAOA,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAA;IAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CACxB;AAED,wBAAsB,QAAQ,CAAC,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyD/E"}
@@ -1 +1 @@
1
- {"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/commands/logout.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CACxB;AAED,wBAAsB,SAAS,CAAC,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0BjF"}
1
+ {"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/commands/logout.tsx"],"names":[],"mappings":"AAKA,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CACxB;AAED,wBAAsB,SAAS,CAAC,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CA8BjF"}
@@ -54,6 +54,11 @@ export declare const CLI_OPTION_DEFINITIONS: {
54
54
  readonly summary: "Public custom app origin";
55
55
  readonly kind: "string";
56
56
  };
57
+ readonly "trusted-proxies": {
58
+ readonly syntax: "--trusted-proxies <ranges>";
59
+ readonly summary: "Proxies trusted for client addresses (default: private)";
60
+ readonly kind: "string";
61
+ };
57
62
  readonly profile: {
58
63
  readonly syntax: "--profile <name>";
59
64
  readonly summary: "Use a saved API profile";
@@ -1 +1 @@
1
- {"version":3,"file":"command-line.d.ts","sourceRoot":"","sources":["../../src/lib/command-line.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuGuD,CAAA;AAE1F,MAAM,MAAM,aAAa,GA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AAE,UAAU,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAC/D;IACE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;IACxB,QAAQ,CAAC,EAAE,EAAE,cAAc,CAAA;IAC3B,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;IAChC,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAA;IACvC,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAA;CACnC,CAAA;AAEL,qBAAa,aAAc,SAAQ,KAAK;IACtC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,QAAQ,KAAI;gBAET,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;CAK3C;AAED,eAAO,MAAM,SAAS,EAAE,OAavB,CAAA;AAED,eAAO,MAAM,YAAY,yxBAyBf,CAAA;AAEV,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAkB/D;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS,CAG/F;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAErF;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,aAAa,GAAG,SAAS,MAAM,EAAE,CAGhG;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAKpE"}
@@ -1,7 +1,11 @@
1
+ import { type SixbSessionStore, type SixbSessionTokens } from "@sixb/client";
1
2
  export interface SixbProfile {
2
3
  readonly apiUrl: string;
3
4
  readonly projectId: string;
5
+ /** A personal access token, for scripts and CI (`sixb login --token-stdin`). */
4
6
  readonly token?: string;
7
+ /** The session `sixb login` signs in through the browser. */
8
+ readonly session?: SixbSessionTokens;
5
9
  }
6
10
  export interface SixbConfigFile {
7
11
  readonly version: 1;
@@ -31,4 +35,6 @@ export declare function updateConfig(update: (config: SixbConfigFile) => SixbCon
31
35
  export declare function resolveProfile(input?: ResolveProfileInput): Promise<ResolvedProfile>;
32
36
  export declare function requireProfile(config: SixbConfigFile, name: string): SixbProfile;
33
37
  export declare function assertProfileName(name: string): void;
38
+ /** A profile's session, as the store the client SDK refreshes and signs out through. */
39
+ export declare function profileSessionStore(profile: string, options?: ProfileStoreOptions): SixbSessionStore;
34
40
  //# sourceMappingURL=profiles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../../src/lib/profiles.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;IACnB,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAA;IAChC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAA;CACzD;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAA;IAC3D,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAChC;AAED,MAAM,WAAW,mBAAoB,SAAQ,mBAAmB;IAC9D,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,M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B,UAAU,CAAC,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,cAAc,CAAC,CAiB3F;AAED,wBAAsB,YAAY,CAChC,MAAM,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,cAAc,EAClD,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,cAAc,CAAC,CAsBzB;AAED,wBAAsB,cAAc,CAAC,KAAK,GAAE,mBAAwB,GAAG,OAAO,CAAC,eAAe,CAAC,CA2D9F;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,GAAG,WAAW,CAKhF;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAMpD;AA8BD,wFAAwF;AACxF,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,mBAAwB,GAChC,gBAAgB,CAclB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sixb/cli",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "description": "Command-line interface for Sixb projects",
5
5
  "keywords": [
6
6
  "sixb",
@@ -29,20 +29,20 @@
29
29
  "prepack": "bun run build"
30
30
  },
31
31
  "dependencies": {
32
- "@sixb/action-worker": "0.1.12",
33
- "@sixb/agent-worker": "0.1.12",
32
+ "@sixb/action-worker": "0.1.14",
33
+ "@sixb/agent-worker": "0.1.14",
34
34
  "@sixb/app": "^0.1.9",
35
- "@sixb/atlas": "^0.1.10",
36
- "@sixb/client": "^0.1.12",
37
- "@sixb/core": "0.1.12",
38
- "@sixb/cli-core": "^0.1.5",
39
- "@sixb/orchestrator": "0.1.12",
40
- "@sixb/pipeline-worker": "0.1.12",
41
- "@sixb/projection-worker": "0.1.12",
42
- "@sixb/rules-worker": "0.1.12",
43
- "@sixb/server": "0.1.12",
44
- "@sixb/sync-worker": "0.1.12",
45
- "@sixb/workflow-worker": "0.1.12",
35
+ "@sixb/atlas": "^0.1.12",
36
+ "@sixb/client": "^0.1.14",
37
+ "@sixb/core": "0.1.14",
38
+ "@sixb/cli-core": "^0.1.6",
39
+ "@sixb/orchestrator": "0.1.14",
40
+ "@sixb/pipeline-worker": "0.1.14",
41
+ "@sixb/projection-worker": "0.1.14",
42
+ "@sixb/rules-worker": "0.1.14",
43
+ "@sixb/server": "0.1.14",
44
+ "@sixb/sync-worker": "0.1.14",
45
+ "@sixb/workflow-worker": "0.1.14",
46
46
  "create-sixb": "^0.1.3",
47
47
  "ink": "^6.0.0",
48
48
  "react": "^19.0.0",
@@ -18,6 +18,7 @@ export interface ApiOptions {
18
18
  apiPublicOrigin?: string
19
19
  atlasPublicOrigin?: string
20
20
  appPublicOrigin?: string
21
+ trustedProxies?: string
21
22
  }
22
23
 
23
24
  export async function runApi(options: ApiOptions = {}) {
@@ -66,6 +67,10 @@ export async function runApi(options: ApiOptions = {}) {
66
67
  hasCustomApp,
67
68
  })
68
69
 
70
+ const trustedProxies = (options.trustedProxies ?? process.env.SIXB_TRUSTED_PROXIES ?? "")
71
+ .split(",")
72
+ .map((entry) => entry.trim())
73
+ .filter(Boolean)
69
74
  server = createSixbServer({
70
75
  host: sixb,
71
76
  port: topology.apiPort,
@@ -76,6 +81,7 @@ export async function runApi(options: ApiOptions = {}) {
76
81
  allowedOrigins: topology.allowedBrowserOrigins,
77
82
  },
78
83
  ...(hasAuthExperience ? { authExperience: { outdir: authExperienceOutdir } } : {}),
84
+ ...(trustedProxies.length > 0 ? { trustedProxies } : {}),
79
85
  })
80
86
  await server.start()
81
87
 
@@ -1,4 +1,6 @@
1
+ import { hostname } from "node:os"
1
2
  import { CliError, createInstanceApiClient, writeJson } from "@sixb/cli-core"
3
+ import { type SixbSessionTokens, startSixbDeviceLogin } from "@sixb/client"
2
4
  import { normalizeApiUrl } from "../lib/api-client"
3
5
  import { assertProfileName, updateConfig } from "../lib/profiles"
4
6
  import { KeyValueResultView, renderStatic } from "../ui"
@@ -17,16 +19,19 @@ export async function runLogin(options: LoginCommandOptions = {}): Promise<void>
17
19
 
18
20
  const apiUrl = normalizeApiUrl(options.apiUrl)
19
21
  let token: string | undefined
22
+ let session: SixbSessionTokens | undefined
20
23
  let projectId: string
21
24
 
22
25
  try {
23
26
  projectId = await fetchProject(apiUrl)
24
27
  } catch (error) {
25
28
  if (!isAuthorizationError(error)) throw error
26
- token = options.tokenStdin
27
- ? await readTokenFromStdin()
28
- : await authorizeDevice(apiUrl, options.profile?.trim() || "sixb CLI")
29
- projectId = await fetchProject(apiUrl, token)
29
+ if (options.tokenStdin) {
30
+ token = await readTokenFromStdin()
31
+ } else {
32
+ session = await authorizeDevice(apiUrl)
33
+ }
34
+ projectId = await fetchProject(apiUrl, token ?? session?.accessToken)
30
35
  }
31
36
 
32
37
  const profile = options.profile?.trim() || projectId
@@ -36,11 +41,16 @@ export async function runLogin(options: LoginCommandOptions = {}): Promise<void>
36
41
  currentProfile: profile,
37
42
  profiles: {
38
43
  ...config.profiles,
39
- [profile]: { apiUrl, projectId, ...(token ? { token } : {}) },
44
+ [profile]: {
45
+ apiUrl,
46
+ projectId,
47
+ ...(token ? { token } : {}),
48
+ ...(session ? { session } : {}),
49
+ },
40
50
  },
41
51
  }))
42
52
 
43
- const result = { profile, projectId, apiUrl, authenticated: Boolean(token) }
53
+ const result = { profile, projectId, apiUrl, authenticated: Boolean(token ?? session) }
44
54
  if (options.json) {
45
55
  writeJson(result)
46
56
  return
@@ -52,92 +62,25 @@ export async function runLogin(options: LoginCommandOptions = {}): Promise<void>
52
62
  items={[
53
63
  { label: "Project", value: projectId },
54
64
  { label: "API", value: apiUrl },
55
- { label: "Authentication", value: token ? "stored token" : "not required" },
65
+ {
66
+ label: "Authentication",
67
+ value: session ? "signed in" : token ? "stored token" : "not required",
68
+ },
56
69
  ]}
57
70
  />
58
71
  )
59
72
  }
60
73
 
61
- interface DeviceAuthorizationStart {
62
- readonly deviceCode: string
63
- readonly userCode: string
64
- readonly verificationUriComplete: string
65
- readonly expiresAt: string
66
- readonly interval: number
67
- }
68
-
69
- async function authorizeDevice(apiUrl: string, tokenName: string): Promise<string> {
70
- const api = createInstanceApiClient({ kind: "local", baseUrl: apiUrl })
71
- const start = parseDeviceAuthorizationStart(
72
- await api.post("/api/auth/device-authorizations", {
73
- clientName: "sixb CLI",
74
- tokenName,
75
- expiresIn: "90d",
76
- }),
77
- apiUrl
78
- )
79
- process.stderr.write(`Opening ${start.verificationUriComplete}\n`)
80
- process.stderr.write(`Confirm code: ${start.userCode}\n`)
81
- await openBrowser(start.verificationUriComplete)
74
+ async function authorizeDevice(apiUrl: string): Promise<SixbSessionTokens> {
75
+ const login = await startSixbDeviceLogin({
76
+ baseUrl: apiUrl,
77
+ clientName: `sixb CLI on ${hostname()}`,
78
+ })
79
+ process.stderr.write(`Opening ${login.verificationUriComplete}\n`)
80
+ process.stderr.write(`Confirm code: ${login.userCode}\n`)
81
+ await openBrowser(login.verificationUriComplete)
82
82
  process.stderr.write("Waiting for browser authorization...\n")
83
-
84
- const serverDeadline = new Date(start.expiresAt).getTime()
85
- const deadline = Math.min(serverDeadline, Date.now() + 15 * 60 * 1000)
86
- const intervalMs = Math.max(1, Math.min(10, start.interval)) * 1000
87
- while (Date.now() < deadline) {
88
- const result = await api.post("/api/auth/device-authorizations/token", {
89
- deviceCode: start.deviceCode,
90
- })
91
- if (!isRecord(result) || typeof result.status !== "string") {
92
- throw new Error("[SixbCLI] The Sixb API returned an invalid device authorization response.")
93
- }
94
- if (result.status === "approved" && typeof result.accessToken === "string") {
95
- return requireToken(result.accessToken)
96
- }
97
- if (result.status === "denied") {
98
- throw new Error("[SixbCLI] Browser authorization was denied.")
99
- }
100
- if (result.status === "expired") {
101
- throw new Error("[SixbCLI] Browser authorization expired. Run `sixb login` again.")
102
- }
103
- if (result.status !== "pending") {
104
- throw new Error("[SixbCLI] The Sixb API returned an unknown authorization status.")
105
- }
106
- await Bun.sleep(intervalMs)
107
- }
108
- throw new Error("[SixbCLI] Browser authorization expired. Run `sixb login` again.")
109
- }
110
-
111
- function parseDeviceAuthorizationStart(value: unknown, apiUrl: string): DeviceAuthorizationStart {
112
- if (
113
- !isRecord(value) ||
114
- typeof value.deviceCode !== "string" ||
115
- !value.deviceCode ||
116
- value.deviceCode.length > 1_024 ||
117
- typeof value.userCode !== "string" ||
118
- !value.userCode ||
119
- typeof value.verificationUriComplete !== "string" ||
120
- typeof value.expiresAt !== "string" ||
121
- typeof value.interval !== "number" ||
122
- !Number.isFinite(value.interval) ||
123
- !Number.isFinite(new Date(value.expiresAt).getTime())
124
- ) {
125
- throw new Error("[SixbCLI] The Sixb API returned an invalid device authorization.")
126
- }
127
- const verificationUrl = new URL(value.verificationUriComplete)
128
- if (
129
- verificationUrl.origin !== new URL(apiUrl).origin ||
130
- (verificationUrl.protocol !== "http:" && verificationUrl.protocol !== "https:")
131
- ) {
132
- throw new Error("[SixbCLI] The device verification URL does not match the Sixb API origin.")
133
- }
134
- return {
135
- deviceCode: value.deviceCode,
136
- userCode: value.userCode,
137
- verificationUriComplete: value.verificationUriComplete,
138
- expiresAt: value.expiresAt,
139
- interval: value.interval,
140
- }
83
+ return login.complete()
141
84
  }
142
85
 
143
86
  async function openBrowser(url: string): Promise<void> {
@@ -1,5 +1,6 @@
1
1
  import { writeJson } from "@sixb/cli-core"
2
- import { readConfig, requireProfile, updateConfig } from "../lib/profiles"
2
+ import { signOutSixbSession } from "@sixb/client"
3
+ import { profileSessionStore, readConfig, requireProfile, updateConfig } from "../lib/profiles"
3
4
  import { KeyValueResultView, renderStatic } from "../ui"
4
5
 
5
6
  export interface LogoutCommandOptions {
@@ -11,7 +12,11 @@ export async function runLogout(options: LogoutCommandOptions = {}): Promise<voi
11
12
  const current = await readConfig()
12
13
  const name = options.profile?.trim() || current.currentProfile
13
14
  if (!name) throw new Error("[SixbCLI] No current profile to remove.")
14
- requireProfile(current, name)
15
+ const stored = requireProfile(current, name)
16
+ // End the session on the server too, so a copy of its tokens stops working.
17
+ if (stored.session) {
18
+ await signOutSixbSession({ baseUrl: stored.apiUrl, store: profileSessionStore(name) })
19
+ }
15
20
 
16
21
  await updateConfig((config) => {
17
22
  const profiles = { ...config.profiles }
@@ -25,7 +25,7 @@ async function listProfiles(options: ProfileCommandOptions): Promise<void> {
25
25
  current: name === config.currentProfile,
26
26
  projectId: profile.projectId,
27
27
  apiUrl: profile.apiUrl,
28
- authenticated: Boolean(profile.token),
28
+ authenticated: Boolean(profile.token ?? profile.session),
29
29
  }))
30
30
 
31
31
  if (options.json) {
@@ -59,7 +59,7 @@ async function showProfile(options: ProfileCommandOptions): Promise<void> {
59
59
  current: name === config.currentProfile,
60
60
  projectId: profile.projectId,
61
61
  apiUrl: profile.apiUrl,
62
- authenticated: Boolean(profile.token),
62
+ authenticated: Boolean(profile.token ?? profile.session),
63
63
  }
64
64
 
65
65
  if (options.json) {
package/src/index.tsx CHANGED
@@ -148,6 +148,7 @@ async function main(): Promise<void> {
148
148
  apiPublicOrigin: getFlag("api-public-origin"),
149
149
  atlasPublicOrigin: getFlag("atlas-public-origin"),
150
150
  appPublicOrigin: getFlag("app-public-origin"),
151
+ trustedProxies: getFlag("trusted-proxies"),
151
152
  })
152
153
  break
153
154
  }
@@ -54,6 +54,11 @@ export const CLI_OPTION_DEFINITIONS = {
54
54
  summary: "Public custom app origin",
55
55
  kind: "string",
56
56
  },
57
+ "trusted-proxies": {
58
+ syntax: "--trusted-proxies <ranges>",
59
+ summary: "Proxies trusted for client addresses (default: private)",
60
+ kind: "string",
61
+ },
57
62
  profile: { syntax: "--profile <name>", summary: "Use a saved API profile", kind: "string" },
58
63
  "api-url": {
59
64
  syntax: "--api-url <url>",
@@ -227,6 +232,7 @@ const commandTree: readonly CommandNode[] = [
227
232
  "api-public-origin",
228
233
  "atlas-public-origin",
229
234
  "app-public-origin",
235
+ "trusted-proxies",
230
236
  ],
231
237
  }),
232
238
  command("atlas", "Start production Atlas UI server", {
@@ -388,7 +394,7 @@ const commandTree: readonly CommandNode[] = [
388
394
  rootHelpLabel: "worker-group [types...]",
389
395
  }),
390
396
  command("check", "Validate project configuration and health", { options: ["entry"] }),
391
- command("typegen", "Generate ontology types for client query inference", { options: ["entry"] }),
397
+ command("typegen", "Generate ontology types for typed queries", { options: ["entry"] }),
392
398
  command("build", "Build runtime and production UI/app assets", { options: ["entry", "outdir"] }),
393
399
  {
394
400
  name: "db",
@@ -2,6 +2,12 @@ import { randomUUID } from "node:crypto"
2
2
  import { chmod, mkdir, readFile, rename, rm, writeFile } from "node:fs/promises"
3
3
  import { homedir } from "node:os"
4
4
  import { dirname, isAbsolute, join } from "node:path"
5
+ import {
6
+ getSixbSessionAccessToken,
7
+ SixbSessionEndedError,
8
+ type SixbSessionStore,
9
+ type SixbSessionTokens,
10
+ } from "@sixb/client"
5
11
  import { normalizeApiUrl } from "./api-client"
6
12
 
7
13
  const CONFIG_DIRECTORY_MODE = 0o700
@@ -11,7 +17,10 @@ const PROFILE_NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/
11
17
  export interface SixbProfile {
12
18
  readonly apiUrl: string
13
19
  readonly projectId: string
20
+ /** A personal access token, for scripts and CI (`sixb login --token-stdin`). */
14
21
  readonly token?: string
22
+ /** The session `sixb login` signs in through the browser. */
23
+ readonly session?: SixbSessionTokens
15
24
  }
16
25
 
17
26
  export interface SixbConfigFile {
@@ -118,7 +127,7 @@ export async function resolveProfile(input: ResolveProfileInput = {}): Promise<R
118
127
  const explicitProfile = nonblank(input.profile)
119
128
  if (explicitProfile) {
120
129
  const stored = requireProfile(config, explicitProfile)
121
- return resolvedStoredProfile(stored, explicitProfile, "profile-flag", explicitToken)
130
+ return resolvedStoredProfile(stored, explicitProfile, "profile-flag", explicitToken, input)
122
131
  }
123
132
 
124
133
  const environmentApiUrl = nonblank(env.SIXB_API_URL) ?? nonblank(env.SIXB_API_PUBLIC_ORIGIN)
@@ -136,12 +145,24 @@ export async function resolveProfile(input: ResolveProfileInput = {}): Promise<R
136
145
  const environmentProfile = nonblank(env.SIXB_PROFILE)
137
146
  if (environmentProfile) {
138
147
  const stored = requireProfile(config, environmentProfile)
139
- return resolvedStoredProfile(stored, environmentProfile, "profile-environment", explicitToken)
148
+ return resolvedStoredProfile(
149
+ stored,
150
+ environmentProfile,
151
+ "profile-environment",
152
+ explicitToken,
153
+ input
154
+ )
140
155
  }
141
156
 
142
157
  if (config.currentProfile) {
143
158
  const stored = requireProfile(config, config.currentProfile)
144
- return resolvedStoredProfile(stored, config.currentProfile, "current-profile", explicitToken)
159
+ return resolvedStoredProfile(
160
+ stored,
161
+ config.currentProfile,
162
+ "current-profile",
163
+ explicitToken,
164
+ input
165
+ )
145
166
  }
146
167
 
147
168
  return {
@@ -166,21 +187,51 @@ export function assertProfileName(name: string): void {
166
187
  }
167
188
  }
168
189
 
169
- function resolvedStoredProfile(
190
+ async function resolvedStoredProfile(
170
191
  stored: SixbProfile,
171
192
  profile: string,
172
193
  source: "profile-flag" | "profile-environment" | "current-profile",
173
- explicitToken: string | undefined
174
- ): ResolvedProfile {
194
+ explicitToken: string | undefined,
195
+ options: ProfileStoreOptions
196
+ ): Promise<ResolvedProfile> {
197
+ const { session, ...rest } = stored
198
+ const base = { ...rest, profile, source }
199
+ if (explicitToken) return { ...base, token: explicitToken, tokenSource: "--token" }
200
+ if (session) {
201
+ const token = await getSixbSessionAccessToken({
202
+ baseUrl: stored.apiUrl,
203
+ store: profileSessionStore(profile, options),
204
+ }).catch((error: unknown) => {
205
+ if (!(error instanceof SixbSessionEndedError)) throw error
206
+ return null
207
+ })
208
+ if (!token) {
209
+ throw new Error(
210
+ `[SixbCLI] The sign-in for profile '${profile}' has ended. Run \`sixb login ${stored.apiUrl} --profile ${profile}\` again.`
211
+ )
212
+ }
213
+ return { ...base, token, tokenSource: "profile" }
214
+ }
215
+ return stored.token ? { ...base, tokenSource: "profile" } : base
216
+ }
217
+
218
+ /** A profile's session, as the store the client SDK refreshes and signs out through. */
219
+ export function profileSessionStore(
220
+ profile: string,
221
+ options: ProfileStoreOptions = {}
222
+ ): SixbSessionStore {
223
+ const update = (change: (stored: SixbProfile) => SixbProfile) =>
224
+ updateConfig(
225
+ (config) => ({
226
+ ...config,
227
+ profiles: { ...config.profiles, [profile]: change(requireProfile(config, profile)) },
228
+ }),
229
+ options
230
+ )
175
231
  return {
176
- ...stored,
177
- profile,
178
- source,
179
- ...(explicitToken
180
- ? { token: explicitToken, tokenSource: "--token" }
181
- : stored.token
182
- ? { tokenSource: "profile" }
183
- : {}),
232
+ load: async () => requireProfile(await readConfig(options), profile).session ?? null,
233
+ save: async (session) => void (await update((stored) => ({ ...stored, session }))),
234
+ clear: async () => void (await update(({ session: _ended, ...stored }) => stored)),
184
235
  }
185
236
  }
186
237
 
@@ -210,13 +261,21 @@ function parseConfig(value: unknown, path: string): SixbConfigFile {
210
261
  const apiUrl = nonblankString(profile.apiUrl)
211
262
  const projectId = nonblankString(profile.projectId)
212
263
  const token = profile.token === undefined ? undefined : nonblankString(profile.token)
213
- if (!apiUrl || !projectId || (profile.token !== undefined && !token)) {
264
+ const session = profile.session === undefined ? undefined : parseStoredSession(profile.session)
265
+ if (
266
+ !apiUrl ||
267
+ !projectId ||
268
+ (profile.token !== undefined && !token) ||
269
+ (profile.session !== undefined && !session) ||
270
+ (token && session)
271
+ ) {
214
272
  throw invalidConfig(path)
215
273
  }
216
274
  profiles[name] = {
217
275
  apiUrl: normalizeApiUrl(apiUrl),
218
276
  projectId,
219
277
  ...(token ? { token } : {}),
278
+ ...(session ? { session } : {}),
220
279
  }
221
280
  }
222
281
 
@@ -236,6 +295,22 @@ function parseConfig(value: unknown, path: string): SixbConfigFile {
236
295
  }
237
296
  }
238
297
 
298
+ function parseStoredSession(value: unknown): SixbSessionTokens | undefined {
299
+ const record = asRecord(value)
300
+ const accessToken = nonblankString(record.accessToken)
301
+ const refreshToken = nonblankString(record.refreshToken)
302
+ const accessExpiresAt = nonblankString(record.accessExpiresAt)
303
+ if (
304
+ !accessToken ||
305
+ !refreshToken ||
306
+ !accessExpiresAt ||
307
+ Number.isNaN(Date.parse(accessExpiresAt))
308
+ ) {
309
+ return undefined
310
+ }
311
+ return { accessToken, refreshToken, accessExpiresAt }
312
+ }
313
+
239
314
  function invalidConfig(path: string): Error {
240
315
  return new Error(`[SixbCLI] Profile config '${path}' has an invalid shape.`)
241
316
  }