@valbuild/server 0.113.0 → 0.115.0

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.
@@ -372,13 +372,6 @@ export declare abstract class ValOps {
372
372
  } | {
373
373
  errorType: "patch-head-conflict";
374
374
  }>>;
375
- abstract getCommitSummary(preparedCommit: PreparedCommit): Promise<{
376
- commitSummary: string | null;
377
- error?: undefined;
378
- } | {
379
- commitSummary?: undefined;
380
- error: GenericErrorMessage;
381
- }>;
382
375
  abstract onInit(baseSha: BaseSha, schemaSha: SchemaSha): Promise<void>;
383
376
  abstract fetchPatches<ExcludePatchOps extends boolean>(filters: {
384
377
  patchIds?: PatchId[];
@@ -43,13 +43,6 @@ export declare class ValOpsFS extends ValOps {
43
43
  statusCode: 401 | 500;
44
44
  error: GenericErrorMessage;
45
45
  }>;
46
- getCommitSummary(): Promise<{
47
- commitSummary: string | null;
48
- error?: undefined;
49
- } | {
50
- commitSummary?: undefined;
51
- error: GenericErrorMessage;
52
- }>;
53
46
  getStat(params: {
54
47
  baseSha: BaseSha;
55
48
  schemaSha: SchemaSha;
@@ -46,13 +46,6 @@ export declare class ValOpsHttp extends ValOps {
46
46
  statusCode: 401 | 500;
47
47
  error: GenericErrorMessage;
48
48
  }>;
49
- getCommitSummary(preparedCommit: PreparedCommit): Promise<{
50
- commitSummary: string | null;
51
- error?: undefined;
52
- } | {
53
- commitSummary?: undefined;
54
- error: GenericErrorMessage;
55
- }>;
56
49
  getStat(params: {
57
50
  baseSha: BaseSha;
58
51
  schemaSha: SchemaSha;
@@ -127,12 +120,6 @@ export declare class ValOpsHttp extends ValOps {
127
120
  errors?: undefined;
128
121
  deleted?: undefined;
129
122
  }>;
130
- getCommitMessage(preparedCommit: PreparedCommit): Promise<{
131
- commitSummary: string;
132
- error?: undefined;
133
- } | {
134
- error: GenericErrorMessage;
135
- }>;
136
123
  commit(prepared: PreparedCommit, message: string, committer: AuthorId, filesDirectory: string, newBranch?: string): Promise<{
137
124
  isNotFastForward?: boolean;
138
125
  updatedFiles: string[];
@@ -114,6 +114,32 @@ type ValServerOverrides = Partial<{
114
114
  disableCache?: boolean;
115
115
  }>;
116
116
  export declare function createValServer(valModules: ValModules, route: string, opts: ValApiOptions, config: ValConfig, callbacks: ValServerCallbacks, formatter?: (code: string, filePath: string) => string | Promise<string>): Promise<ValServer>;
117
+ /**
118
+ * Hosts we send credentials to, and what each one puts at risk. They differ:
119
+ * only `valBuildUrl` hands back the app token that becomes the session cookie,
120
+ * so a single shared sentence would overstate one and understate the other.
121
+ */
122
+ type CredentialBearingUrl = "valBuildUrl" | "valContentUrl";
123
+ /**
124
+ * Returns a warning if `url` would send credentials somewhere they can be read
125
+ * off the wire, or null if it is fine.
126
+ *
127
+ * Both URLs default to https, but each is overridable - `opts.valBuildUrl` /
128
+ * `VAL_BUILD_URL`, `opts.valContentUrl` / `VAL_CONTENT_URL` - and neither
129
+ * override has ever been scheme-checked. Point one at a plain http host and the
130
+ * api key goes out in clear text, and whatever comes back is whatever the
131
+ * network says: for `valBuildUrl` that includes the app token this server
132
+ * re-signs into the session cookie.
133
+ *
134
+ * Loopback over http is exempt: that is a val.build running on the developer's
135
+ * own machine, and there is no network to be on the wrong side of.
136
+ *
137
+ * This warns rather than throws. Both overrides are set by the operator, not by
138
+ * an attacker, so this is a misconfiguration to surface - not untrusted input to
139
+ * reject - and refusing to boot would break anyone deliberately pointing at an
140
+ * internal http host today.
141
+ */
142
+ export declare function insecureUrlWarning(name: CredentialBearingUrl, url: string): string | null;
117
143
  export declare function safeReadGit(cwd: string): Promise<{
118
144
  commit?: string;
119
145
  branch?: string;
@@ -5,4 +5,4 @@ import { ValidationError } from "@valbuild/core";
5
5
  * There is no schema in hand here — a `ValidationError` carries only the value
6
6
  * it flagged — so the shape is all there is to go on.
7
7
  */
8
- export declare function getValidationErrorFileRef(validationError: ValidationError): string | null;
8
+ export declare function getValidationErrorFileRef(validationError: ValidationError): any;
@@ -25,8 +25,8 @@ export { checkRemoteRef, downloadFileFromRemote, getCachedRemoteFileDir, getCach
25
25
  export { hasRemoteFileSchema } from "@valbuild/core";
26
26
  export { getFileExt } from "./getFileExt.js";
27
27
  export { evalValConfigFile, findAndEvalValConfigFile, } from "./evalValConfigFile.js";
28
- export { startValLogin, awaitValLoginConfirmation, persistPersonalAccessToken, ValLoginError, DEFAULT_LOGIN_HOST, DEFAULT_LOGIN_MAX_DURATION, DEFAULT_LOGIN_POLL_INTERVAL, } from "./login.js";
29
- export type { ValLoginErrorCode, ValLoginResult, ValLoginSession, } from "./login.js";
28
+ export { startValLogin, awaitValLoginConfirmation, persistPersonalAccessToken, ValLoginError, DEFAULT_LOGIN_HOST, DEFAULT_LOGIN_EXPIRES_IN_SECONDS, DEFAULT_LOGIN_POLL_INTERVAL_SECONDS, } from "./login.js";
29
+ export type { ValLoginErrorCode, ValLoginResult, ValDeviceAuthorization, } from "./login.js";
30
30
  export { createModulePathMap, createJsonEntryPathMap, getModulePathRange, } from "./modulePathMap.js";
31
31
  export { findJsonEntryFilePath } from "./jsonEntryLocation.js";
32
32
  export { classifyJsonValuesOp, rebaseContentOp } from "./patch/jsonValuesPatch.js";
@@ -1,5 +1,15 @@
1
1
  /**
2
- * The Val login device flow, as reusable primitives.
2
+ * The Val login flow, as reusable primitives.
3
+ *
4
+ * This is an RFC 8628 device authorization grant. The shape that matters:
5
+ * {@link ValDeviceAuthorization.deviceCode} is a secret this process holds and
6
+ * polls with, while {@link ValDeviceAuthorization.userCode} is the short string
7
+ * the human reads out of the terminal and types into a browser. Only the device
8
+ * code can collect a token.
9
+ *
10
+ * Keep them apart. Show the user code; never print, log or put the device code
11
+ * in a URL. An earlier version of this flow used one value for both jobs, which
12
+ * meant anyone who saw the verification link could collect the token it led to.
3
13
  *
4
14
  * The CLI wraps these with terminal output, and `@valbuild/language-server`
5
15
  * wraps them with LSP `window/showDocument` and progress reporting. Neither the
@@ -16,6 +26,10 @@ export type ValLoginErrorCode =
16
26
  | "unexpected-response"
17
27
  /** The server returned a 5xx. */
18
28
  | "server-error"
29
+ /** The user declined the login in the browser. */
30
+ | "access-denied"
31
+ /** The login was not approved before the code expired. */
32
+ | "expired"
19
33
  /** The user did not complete the login within the allotted time. */
20
34
  | "timeout"
21
35
  /** The caller aborted the flow. */
@@ -25,12 +39,23 @@ export declare class ValLoginError extends Error {
25
39
  readonly details?: string | undefined;
26
40
  constructor(code: ValLoginErrorCode, message: string, details?: string | undefined);
27
41
  }
28
- /** A login attempt that is waiting for the user to confirm in a browser. */
29
- export type ValLoginSession = {
30
- /** Opaque token used to poll for confirmation. */
31
- nonce: string;
32
- /** URL the user must open to confirm the login. */
33
- url: string;
42
+ /** A login attempt that is waiting for the user to approve it in a browser. */
43
+ export type ValDeviceAuthorization = {
44
+ /**
45
+ * Secret. Polls for the token. Do not display, log or transmit anywhere but
46
+ * the token endpoint.
47
+ */
48
+ deviceCode: string;
49
+ /** Short code for the user to compare and type. Safe to display. */
50
+ userCode: string;
51
+ /** Where the user goes to enter {@link userCode}. */
52
+ verificationUri: string;
53
+ /** {@link verificationUri} with the code prefilled, for convenience. */
54
+ verificationUriComplete: string;
55
+ /** Seconds until the code stops being approvable. */
56
+ expiresInSeconds: number;
57
+ /** Minimum seconds between polls, per the server. */
58
+ intervalSeconds: number;
34
59
  };
35
60
  export type ValLoginResult = {
36
61
  profile: {
@@ -39,24 +64,26 @@ export type ValLoginResult = {
39
64
  pat: string;
40
65
  };
41
66
  /**
42
- * Begin a login attempt. The caller is responsible for getting
43
- * {@link ValLoginSession.url} in front of the user.
67
+ * Begin a login attempt. The caller is responsible for getting the user code
68
+ * and verification URL in front of the user.
44
69
  */
45
70
  export declare function startValLogin(options?: {
46
71
  host?: string;
47
- }): Promise<ValLoginSession>;
48
- export declare const DEFAULT_LOGIN_MAX_DURATION: number;
49
- export declare const DEFAULT_LOGIN_POLL_INTERVAL = 1000;
72
+ deviceName?: string;
73
+ }): Promise<ValDeviceAuthorization>;
74
+ /** Fallbacks for a server that omits the optional RFC 8628 timing fields. */
75
+ export declare const DEFAULT_LOGIN_EXPIRES_IN_SECONDS = 600;
76
+ export declare const DEFAULT_LOGIN_POLL_INTERVAL_SECONDS = 5;
50
77
  /**
51
- * Poll until the user confirms the login in their browser.
78
+ * Poll until the user approves the login in their browser.
52
79
  *
53
80
  * Accepts an `AbortSignal` so an editor can cancel the flow when the user
54
- * dismisses the prompt, instead of leaving a poll loop running for 5 minutes.
81
+ * dismisses the prompt, instead of leaving a poll loop running to expiry.
55
82
  */
56
- export declare function awaitValLoginConfirmation(nonce: string, options?: {
83
+ export declare function awaitValLoginConfirmation(authorization: ValDeviceAuthorization, options?: {
57
84
  host?: string;
85
+ /** Defaults to the authorization's own `expiresInSeconds`. */
58
86
  maxDurationMs?: number;
59
- pollIntervalMs?: number;
60
87
  signal?: AbortSignal;
61
88
  /** Wall clock, injectable for tests. */
62
89
  now?: () => number;
@@ -1,4 +1,4 @@
1
- import { ModuleFilePath, PatchId } from "@valbuild/core";
1
+ import { PatchId } from "@valbuild/core";
2
2
  import { z } from "zod";
3
3
  import type { AuthorId, BaseSha } from "./ValOps.js";
4
4
  import { PatchLogEntry, PatchLogProblem } from "./patchLog.js";
@@ -32,14 +32,14 @@ export declare const FSPatch: z.ZodObject<{
32
32
  patch: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
33
33
  op: z.ZodLiteral<"add">;
34
34
  path: z.ZodArray<z.ZodString>;
35
- value: z.ZodType<import("@valbuild/core/patch").JSONValue, unknown, z.core.$ZodTypeInternals<import("@valbuild/core/patch").JSONValue, unknown>>;
35
+ value: z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>;
36
36
  }, z.core.$strict>, z.ZodObject<{
37
37
  op: z.ZodLiteral<"remove">;
38
38
  path: z.ZodTuple<[z.ZodString], z.ZodString>;
39
39
  }, z.core.$strict>, z.ZodObject<{
40
40
  op: z.ZodLiteral<"replace">;
41
41
  path: z.ZodArray<z.ZodString>;
42
- value: z.ZodType<import("@valbuild/core/patch").JSONValue, unknown, z.core.$ZodTypeInternals<import("@valbuild/core/patch").JSONValue, unknown>>;
42
+ value: z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>;
43
43
  }, z.core.$strict>, z.ZodObject<{
44
44
  op: z.ZodLiteral<"move">;
45
45
  from: z.ZodTuple<[z.ZodString], z.ZodString>;
@@ -51,15 +51,15 @@ export declare const FSPatch: z.ZodObject<{
51
51
  }, z.core.$strict>, z.ZodObject<{
52
52
  op: z.ZodLiteral<"test">;
53
53
  path: z.ZodArray<z.ZodString>;
54
- value: z.ZodType<import("@valbuild/core/patch").JSONValue, unknown, z.core.$ZodTypeInternals<import("@valbuild/core/patch").JSONValue, unknown>>;
54
+ value: z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>;
55
55
  }, z.core.$strict>, z.ZodObject<{
56
56
  op: z.ZodLiteral<"file">;
57
57
  path: z.ZodArray<z.ZodString>;
58
58
  filePath: z.ZodString;
59
- value: z.ZodType<import("@valbuild/core/patch").JSONValue, unknown, z.core.$ZodTypeInternals<import("@valbuild/core/patch").JSONValue, unknown>>;
59
+ value: z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>;
60
60
  remote: z.ZodBoolean;
61
61
  nestedFilePath: z.ZodOptional<z.ZodArray<z.ZodString>>;
62
- metadata: z.ZodOptional<z.ZodType<import("@valbuild/core/patch").JSONValue, unknown, z.core.$ZodTypeInternals<import("@valbuild/core/patch").JSONValue, unknown>>>;
62
+ metadata: z.ZodOptional<z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>>;
63
63
  }, z.core.$strict>], "op">>;
64
64
  patchId: z.ZodString;
65
65
  baseSha: z.ZodString & z.ZodType<BaseSha, string, z.core.$ZodTypeInternals<BaseSha, string>>;