@docsxai/engine 0.3.0-rc.3 → 0.3.0-rc.5

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 (181) hide show
  1. package/README.md +44 -34
  2. package/dist/atomic-write.d.ts +19 -0
  3. package/dist/atomic-write.js +127 -0
  4. package/dist/auth/api-login.d.ts +9 -51
  5. package/dist/auth/api-login.js +3 -3
  6. package/dist/auth/browser-session.js +1 -1
  7. package/dist/auth/cookie-jar.d.ts +4 -4
  8. package/dist/auth/cookie-jar.js +4 -4
  9. package/dist/auth/email-otp.d.ts +11 -147
  10. package/dist/auth/email-otp.js +4 -4
  11. package/dist/auth/http-basic.js +1 -1
  12. package/dist/auth/index.js +3 -3
  13. package/dist/auth/jwt-injection.d.ts +7 -131
  14. package/dist/auth/jwt-injection.js +5 -5
  15. package/dist/auth/manual-capture.d.ts +3 -3
  16. package/dist/auth/manual-capture.js +2 -2
  17. package/dist/auth/mtls.d.ts +1 -6
  18. package/dist/auth/mtls.js +1 -1
  19. package/dist/auth/pat-header.d.ts +1 -9
  20. package/dist/auth/pat-header.js +1 -1
  21. package/dist/auth/storage-state-cache.d.ts +16 -6
  22. package/dist/auth/storage-state-cache.js +65 -15
  23. package/dist/auth/test-backdoor.d.ts +2 -13
  24. package/dist/auth/test-backdoor.js +3 -3
  25. package/dist/auth/totp.d.ts +1 -1
  26. package/dist/auth/totp.js +4 -4
  27. package/dist/auth/types.d.ts +3 -3
  28. package/dist/auth/types.js +4 -4
  29. package/dist/auth/ui-form.d.ts +24 -153
  30. package/dist/auth/ui-form.js +3 -3
  31. package/dist/auth/webauthn.d.ts +7 -67
  32. package/dist/auth/webauthn.js +3 -3
  33. package/dist/auth.js +1 -1
  34. package/dist/backend-client-contracts.d.ts +1 -1
  35. package/dist/backend-client-contracts.js +2 -2
  36. package/dist/backend-client-oauth-login.js +1 -1
  37. package/dist/backend-client-state-cache.d.ts +2 -2
  38. package/dist/backend-client-state-cache.js +8 -8
  39. package/dist/backend-client-token.js +4 -4
  40. package/dist/backend-client-transport.d.ts +2 -2
  41. package/dist/backend-client-transport.js +3 -3
  42. package/dist/backend-client.js +6 -6
  43. package/dist/browser-build.d.ts +6 -0
  44. package/dist/browser-build.js +12 -0
  45. package/dist/browser-launch-error.d.ts +18 -0
  46. package/dist/browser-launch-error.js +63 -0
  47. package/dist/browser-wait.d.ts +7 -0
  48. package/dist/browser-wait.js +12 -0
  49. package/dist/calibrate.d.ts +6 -2
  50. package/dist/calibrate.js +20 -13
  51. package/dist/cli-backend-errors.d.ts +5 -0
  52. package/dist/cli-backend-errors.js +24 -3
  53. package/dist/cli-commands-auth.d.ts +1 -0
  54. package/dist/cli-commands-auth.js +114 -0
  55. package/dist/cli-commands-authoring.d.ts +0 -1
  56. package/dist/cli-commands-authoring.js +124 -101
  57. package/dist/cli-commands-backend.d.ts +1 -1
  58. package/dist/cli-commands-backend.js +76 -21
  59. package/dist/cli-commands-docpack.d.ts +3 -1
  60. package/dist/cli-commands-docpack.js +145 -39
  61. package/dist/cli-commands-init.d.ts +1 -0
  62. package/dist/cli-commands-init.js +100 -0
  63. package/dist/cli-commands-pack.d.ts +1 -1
  64. package/dist/cli-commands-pack.js +6 -4
  65. package/dist/cli-commands-session.d.ts +1 -3
  66. package/dist/cli-commands-session.js +109 -180
  67. package/dist/cli-commands-site.d.ts +2 -0
  68. package/dist/cli-commands-site.js +77 -0
  69. package/dist/cli-commands-style.d.ts +1 -0
  70. package/dist/cli-commands-style.js +85 -0
  71. package/dist/cli-flags.d.ts +18 -0
  72. package/dist/cli-flags.js +77 -0
  73. package/dist/cli-help.d.ts +30 -0
  74. package/dist/cli-help.js +174 -0
  75. package/dist/cli-messages.d.ts +30 -0
  76. package/dist/cli-messages.js +97 -0
  77. package/dist/cli-node-guard.d.ts +1 -0
  78. package/dist/cli-node-guard.js +8 -0
  79. package/dist/cli-retired.js +6 -0
  80. package/dist/cli-run-stale.d.ts +2 -0
  81. package/dist/cli-run-stale.js +13 -0
  82. package/dist/cli-run-summary.js +7 -3
  83. package/dist/cli-shared.d.ts +30 -1
  84. package/dist/cli-shared.js +112 -12
  85. package/dist/cli-unexpected.d.ts +12 -2
  86. package/dist/cli-unexpected.js +50 -4
  87. package/dist/cli-usage.d.ts +1 -1
  88. package/dist/cli-usage.js +115 -66
  89. package/dist/cli-value-flags.d.ts +8 -0
  90. package/dist/cli-value-flags.js +34 -0
  91. package/dist/cli-version.d.ts +6 -0
  92. package/dist/cli-version.js +25 -0
  93. package/dist/cli.d.ts +1 -0
  94. package/dist/cli.js +42 -19
  95. package/dist/deprecation.d.ts +2 -0
  96. package/dist/deprecation.js +2 -0
  97. package/dist/device-scale-factor.d.ts +14 -0
  98. package/dist/device-scale-factor.js +38 -0
  99. package/dist/diagnose.js +14 -13
  100. package/dist/diff-compute.js +22 -8
  101. package/dist/diff-report.js +3 -3
  102. package/dist/diff-types.js +1 -1
  103. package/dist/diff.js +3 -3
  104. package/dist/doc-pack-io.js +62 -47
  105. package/dist/doc-pack.d.ts +567 -3487
  106. package/dist/doc-pack.js +47 -33
  107. package/dist/doctor-checks-config.d.ts +12 -0
  108. package/dist/doctor-checks-config.js +229 -0
  109. package/dist/doctor-checks-plugins.js +2 -2
  110. package/dist/doctor-checks-site.d.ts +3 -0
  111. package/dist/doctor-checks-site.js +21 -0
  112. package/dist/doctor-checks.d.ts +13 -2
  113. package/dist/doctor-checks.js +94 -79
  114. package/dist/doctor-next.d.ts +5 -0
  115. package/dist/doctor-next.js +52 -0
  116. package/dist/doctor.d.ts +36 -2
  117. package/dist/doctor.js +88 -29
  118. package/dist/environment-spec.d.ts +36 -44
  119. package/dist/environment-spec.js +31 -3
  120. package/dist/export/adf.d.ts +1 -1
  121. package/dist/export/adf.js +16 -27
  122. package/dist/export/playwright-test.d.ts +1 -1
  123. package/dist/export/playwright-test.js +13 -15
  124. package/dist/flow-file.d.ts +1 -1
  125. package/dist/flow-file.js +22 -4
  126. package/dist/flow-halt.d.ts +1 -1
  127. package/dist/flow-halt.js +15 -3
  128. package/dist/flow-lint.d.ts +3 -1
  129. package/dist/flow-lint.js +39 -26
  130. package/dist/flow-matrix-lint.js +2 -2
  131. package/dist/flow-runtime.d.ts +17 -6
  132. package/dist/flow-runtime.js +48 -17
  133. package/dist/flow-success.js +4 -4
  134. package/dist/flow-tree.js +2 -2
  135. package/dist/index.d.ts +2 -0
  136. package/dist/index.js +2 -0
  137. package/dist/main-module.d.ts +1 -0
  138. package/dist/main-module.js +17 -0
  139. package/dist/matrix-spec.d.ts +33 -106
  140. package/dist/matrix-spec.js +12 -3
  141. package/dist/node-floor.d.ts +4 -0
  142. package/dist/node-floor.js +14 -0
  143. package/dist/obstacles.js +1 -1
  144. package/dist/open-in-browser.d.ts +22 -0
  145. package/dist/open-in-browser.js +37 -0
  146. package/dist/playwright-driver.d.ts +8 -12
  147. package/dist/playwright-driver.js +75 -70
  148. package/dist/playwright-instrumented-browser.d.ts +10 -7
  149. package/dist/playwright-instrumented-browser.js +35 -12
  150. package/dist/plugins/load.d.ts +1 -1
  151. package/dist/plugins/load.js +4 -4
  152. package/dist/plugins/lock.js +11 -8
  153. package/dist/plugins/manifest.d.ts +16 -35
  154. package/dist/plugins/manifest.js +5 -5
  155. package/dist/plugins/plan.d.ts +3 -3
  156. package/dist/plugins/plan.js +14 -14
  157. package/dist/plugins/registry.d.ts +1 -1
  158. package/dist/plugins/registry.js +1 -1
  159. package/dist/plugins/runtime.js +3 -3
  160. package/dist/plugins/types.d.ts +1 -1
  161. package/dist/plugins-cli.js +36 -28
  162. package/dist/posix-path.d.ts +2 -0
  163. package/dist/posix-path.js +7 -0
  164. package/dist/redact.js +2 -2
  165. package/dist/run-flows.d.ts +7 -0
  166. package/dist/run-flows.js +75 -27
  167. package/dist/style.d.ts +2 -2
  168. package/dist/style.js +13 -11
  169. package/dist/verify-determinism.js +2 -1
  170. package/dist/verify-next-step.d.ts +2 -0
  171. package/dist/verify-next-step.js +24 -0
  172. package/dist/verify-report.js +3 -2
  173. package/dist/viewer-bin.d.ts +9 -3
  174. package/dist/viewer-bin.js +35 -12
  175. package/dist/workspace-templates.d.ts +15 -0
  176. package/dist/workspace-templates.js +88 -0
  177. package/dist/workspace.d.ts +78 -5
  178. package/dist/workspace.js +47 -28
  179. package/dist/zip.d.ts +1 -1
  180. package/dist/zip.js +23 -6
  181. package/package.json +6 -6
@@ -18,49 +18,26 @@ export interface InboxProvider {
18
18
  }
19
19
  export type InboxProviderFactory = (options: Record<string, unknown>) => InboxProvider;
20
20
  export declare const HttpJsonInboxOptions: z.ZodObject<{
21
- /** Inbox endpoint answering `{ messages: [{ to, received_at, body }] }`. */
22
21
  url: z.ZodString;
23
22
  poll_interval_ms: z.ZodDefault<z.ZodNumber>;
24
- }, "strict", z.ZodTypeAny, {
25
- url: string;
26
- poll_interval_ms: number;
27
- }, {
28
- url: string;
29
- poll_interval_ms?: number | undefined;
30
- }>;
23
+ }, z.core.$strict>;
31
24
  export type HttpJsonInboxOptions = z.infer<typeof HttpJsonInboxOptions>;
32
25
  /** Built-in provider: poll a Mailpit-style JSON inbox until the code mail shows up. */
33
26
  export declare function httpJsonInboxProvider(options: Record<string, unknown>): InboxProvider;
34
- /** Register (or override) an inbox provider under `name` — the email-otp plugin hook. */
27
+ /** Register (or override) an inbox provider under `name`, the email-otp plugin hook. */
35
28
  export declare function registerInboxProvider(name: string, factory: InboxProviderFactory): void;
36
29
  /** Remove a registered provider (test/plugin teardown). Removing `http-json` restores the built-in. */
37
30
  export declare function unregisterInboxProvider(name: string): void;
38
31
  export declare function makeInboxProvider(name: string, options: Record<string, unknown>): InboxProvider;
39
32
  export declare const EmailOtpInboxOptions: z.ZodObject<{
40
33
  provider: z.ZodDefault<z.ZodString>;
41
- /** Provider-specific options (for `http-json`: `{ url, poll_interval_ms? }`). */
42
34
  options: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
43
- /** Env var *name* holding the inbox address to watch. Default: the role's `username` credential. */
44
35
  to_env: z.ZodOptional<z.ZodString>;
45
- /** Code-extraction regex (first capture group, else the whole match). */
46
36
  code_pattern: z.ZodDefault<z.ZodString>;
47
- /** How long to wait for the code mail. Default 30000. */
48
37
  timeout_ms: z.ZodDefault<z.ZodNumber>;
49
- }, "strict", z.ZodTypeAny, {
50
- options: Record<string, unknown>;
51
- timeout_ms: number;
52
- provider: string;
53
- code_pattern: string;
54
- to_env?: string | undefined;
55
- }, {
56
- options?: Record<string, unknown> | undefined;
57
- timeout_ms?: number | undefined;
58
- provider?: string | undefined;
59
- to_env?: string | undefined;
60
- code_pattern?: string | undefined;
61
- }>;
38
+ }, z.core.$strict>;
62
39
  export type EmailOtpInboxOptions = z.infer<typeof EmailOtpInboxOptions>;
63
- export declare const EmailOtpOptions: z.ZodEffects<z.ZodObject<{
40
+ export declare const EmailOtpOptions: z.ZodObject<{
64
41
  login_url: z.ZodString;
65
42
  username_selector: z.ZodString;
66
43
  password_selector: z.ZodString;
@@ -72,134 +49,21 @@ export declare const EmailOtpOptions: z.ZodEffects<z.ZodObject<{
72
49
  timeout_ms: z.ZodDefault<z.ZodNumber>;
73
50
  ignore_https_errors: z.ZodDefault<z.ZodBoolean>;
74
51
  pre_steps: z.ZodDefault<z.ZodArray<z.ZodObject<{
75
- action: z.ZodEnum<["click", "fill"]>;
52
+ action: z.ZodEnum<{
53
+ fill: "fill";
54
+ click: "click";
55
+ }>;
76
56
  selector: z.ZodString;
77
57
  value_env: z.ZodOptional<z.ZodString>;
78
- }, "strict", z.ZodTypeAny, {
79
- selector: string;
80
- action: "fill" | "click";
81
- value_env?: string | undefined;
82
- }, {
83
- selector: string;
84
- action: "fill" | "click";
85
- value_env?: string | undefined;
86
- }>, "many">>;
58
+ }, z.core.$strict>>>;
87
59
  inbox: z.ZodObject<{
88
60
  provider: z.ZodDefault<z.ZodString>;
89
- /** Provider-specific options (for `http-json`: `{ url, poll_interval_ms? }`). */
90
61
  options: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
91
- /** Env var *name* holding the inbox address to watch. Default: the role's `username` credential. */
92
62
  to_env: z.ZodOptional<z.ZodString>;
93
- /** Code-extraction regex (first capture group, else the whole match). */
94
63
  code_pattern: z.ZodDefault<z.ZodString>;
95
- /** How long to wait for the code mail. Default 30000. */
96
64
  timeout_ms: z.ZodDefault<z.ZodNumber>;
97
- }, "strict", z.ZodTypeAny, {
98
- options: Record<string, unknown>;
99
- timeout_ms: number;
100
- provider: string;
101
- code_pattern: string;
102
- to_env?: string | undefined;
103
- }, {
104
- options?: Record<string, unknown> | undefined;
105
- timeout_ms?: number | undefined;
106
- provider?: string | undefined;
107
- to_env?: string | undefined;
108
- code_pattern?: string | undefined;
109
- }>;
110
- }, "strict", z.ZodTypeAny, {
111
- timeout_ms: number;
112
- login_url: string;
113
- ignore_https_errors: boolean;
114
- otp_selector: string;
115
- submit_selector: string;
116
- username_selector: string;
117
- password_selector: string;
118
- pre_steps: {
119
- selector: string;
120
- action: "fill" | "click";
121
- value_env?: string | undefined;
122
- }[];
123
- inbox: {
124
- options: Record<string, unknown>;
125
- timeout_ms: number;
126
- provider: string;
127
- code_pattern: string;
128
- to_env?: string | undefined;
129
- };
130
- url_matches?: string | undefined;
131
- success_selector?: string | undefined;
132
- otp_submit_selector?: string | undefined;
133
- }, {
134
- login_url: string;
135
- otp_selector: string;
136
- submit_selector: string;
137
- username_selector: string;
138
- password_selector: string;
139
- inbox: {
140
- options?: Record<string, unknown> | undefined;
141
- timeout_ms?: number | undefined;
142
- provider?: string | undefined;
143
- to_env?: string | undefined;
144
- code_pattern?: string | undefined;
145
- };
146
- timeout_ms?: number | undefined;
147
- url_matches?: string | undefined;
148
- ignore_https_errors?: boolean | undefined;
149
- success_selector?: string | undefined;
150
- pre_steps?: {
151
- selector: string;
152
- action: "fill" | "click";
153
- value_env?: string | undefined;
154
- }[] | undefined;
155
- otp_submit_selector?: string | undefined;
156
- }>, {
157
- timeout_ms: number;
158
- login_url: string;
159
- ignore_https_errors: boolean;
160
- otp_selector: string;
161
- submit_selector: string;
162
- username_selector: string;
163
- password_selector: string;
164
- pre_steps: {
165
- selector: string;
166
- action: "fill" | "click";
167
- value_env?: string | undefined;
168
- }[];
169
- inbox: {
170
- options: Record<string, unknown>;
171
- timeout_ms: number;
172
- provider: string;
173
- code_pattern: string;
174
- to_env?: string | undefined;
175
- };
176
- url_matches?: string | undefined;
177
- success_selector?: string | undefined;
178
- otp_submit_selector?: string | undefined;
179
- }, {
180
- login_url: string;
181
- otp_selector: string;
182
- submit_selector: string;
183
- username_selector: string;
184
- password_selector: string;
185
- inbox: {
186
- options?: Record<string, unknown> | undefined;
187
- timeout_ms?: number | undefined;
188
- provider?: string | undefined;
189
- to_env?: string | undefined;
190
- code_pattern?: string | undefined;
191
- };
192
- timeout_ms?: number | undefined;
193
- url_matches?: string | undefined;
194
- ignore_https_errors?: boolean | undefined;
195
- success_selector?: string | undefined;
196
- pre_steps?: {
197
- selector: string;
198
- action: "fill" | "click";
199
- value_env?: string | undefined;
200
- }[] | undefined;
201
- otp_submit_selector?: string | undefined;
202
- }>;
65
+ }, z.core.$strict>;
66
+ }, z.core.$strict>;
203
67
  export type EmailOtpOptions = z.infer<typeof EmailOtpOptions>;
204
68
  export declare class EmailOtpStrategy implements AuthStrategy {
205
69
  private readonly launcher;
@@ -1,4 +1,4 @@
1
- // `email-otp` — a ui-form login whose second factor arrives by email: fill + submit the
1
+ // `email-otp`: a ui-form login whose second factor arrives by email: fill + submit the
2
2
  // credential form, wait for the OTP prompt, poll an inbox for the code mail, extract the code
3
3
  // with `code_pattern`, submit it, capture storageState.
4
4
  //
@@ -46,7 +46,7 @@ export function httpJsonInboxProvider(options) {
46
46
  const inboxProviders = new Map([
47
47
  ["http-json", httpJsonInboxProvider],
48
48
  ]);
49
- /** Register (or override) an inbox provider under `name` — the email-otp plugin hook. */
49
+ /** Register (or override) an inbox provider under `name`, the email-otp plugin hook. */
50
50
  export function registerInboxProvider(name, factory) {
51
51
  inboxProviders.set(name, factory);
52
52
  }
@@ -96,7 +96,7 @@ export const EmailOtpOptions = z
96
96
  })
97
97
  .strict()
98
98
  .refine((o) => o.success_selector !== undefined || o.url_matches !== undefined, {
99
- message: "one of success_selector or url_matches is required",
99
+ error: "one of success_selector or url_matches is required",
100
100
  });
101
101
  export class EmailOtpStrategy {
102
102
  launcher;
@@ -139,7 +139,7 @@ export class EmailOtpStrategy {
139
139
  await page.waitForSelector(opts.otp_selector, { timeoutMs: opts.timeout_ms });
140
140
  }
141
141
  catch {
142
- throw new AuthStrategyConfigError(`email-otp: the OTP prompt ("${opts.otp_selector}") did not appear within ${opts.timeout_ms}ms — check the credential env vars (values not shown) and the selectors`);
142
+ throw new AuthStrategyConfigError(`email-otp: the OTP prompt ("${opts.otp_selector}") did not appear within ${opts.timeout_ms}ms; check the credential env vars (values not shown) and the selectors`);
143
143
  }
144
144
  const message = await provider.waitForMessage({
145
145
  to,
@@ -1,4 +1,4 @@
1
- // `http-basic` — connection-level auth: the browser context answers 401 challenges with the
1
+ // `http-basic`: connection-level auth: the browser context answers 401 challenges with the
2
2
  // role's credentials. Nothing to capture; the strategy emits `contextOptions.httpCredentials`
3
3
  // and an empty storageState.
4
4
  import { AuthStrategyConfigError, emptyStorageState, maskSecret, } from "./types.js";
@@ -1,7 +1,7 @@
1
1
  // Target-site auth layer.
2
2
  //
3
- // Every strategy produces a `storageState` (cookies + localStorage + sessionStorage) — the
4
- // universal artifact every auth scheme reduces to — plus, for connection-level schemes
3
+ // Every strategy produces a `storageState` (cookies + localStorage + sessionStorage), the
4
+ // universal artifact every auth scheme reduces to, plus, for connection-level schemes
5
5
  // (HTTP Basic, PAT headers, mTLS), `contextOptions` the session launcher passes through to
6
6
  // the browser context. One module per strategy; this index holds the descriptor parsing,
7
7
  // the credential resolution, and the strategy registry.
@@ -45,7 +45,7 @@ export function parseAuthStrategyFile(yamlText, source = "<auth/strategy.yaml>")
45
45
  raw = parseYaml(yamlText);
46
46
  }
47
47
  catch (e) {
48
- throw new AuthStrategyConfigError(`${source}: not valid YAML — ${e.message}`, e);
48
+ throw new AuthStrategyConfigError(`${source}: not valid YAML: ${e.message}`, e);
49
49
  }
50
50
  const r = AuthStrategyDescriptor.safeParse(raw);
51
51
  if (!r.success) {
@@ -1,147 +1,23 @@
1
1
  import { z } from "zod";
2
2
  import { type AuthContext, type AuthResult, type AuthStrategy } from "./types.js";
3
- export declare const JwtInjectionOptions: z.ZodEffects<z.ZodObject<{
4
- /** Env var *name* holding a static token. Mutually exclusive with `token_url`. */
3
+ export declare const JwtInjectionOptions: z.ZodObject<{
5
4
  token_env: z.ZodOptional<z.ZodString>;
6
- /** OAuth2 token endpoint for a client-credentials grant (creds: `client_id`, `client_secret`). */
7
5
  token_url: z.ZodOptional<z.ZodString>;
8
- /** Where the token goes. At least one of `localStorage` / `cookies`. */
9
- inject: z.ZodEffects<z.ZodObject<{
6
+ inject: z.ZodObject<{
10
7
  localStorage: z.ZodOptional<z.ZodArray<z.ZodObject<{
11
8
  key: z.ZodString;
12
- /** `{{token}}` template; default `{{token}}`. */
13
9
  value_template: z.ZodDefault<z.ZodString>;
14
- }, "strict", z.ZodTypeAny, {
15
- key: string;
16
- value_template: string;
17
- }, {
18
- key: string;
19
- value_template?: string | undefined;
20
- }>, "many">>;
10
+ }, z.core.$strict>>>;
21
11
  cookies: z.ZodOptional<z.ZodArray<z.ZodObject<{
22
12
  name: z.ZodString;
23
13
  value_template: z.ZodDefault<z.ZodString>;
24
14
  domain: z.ZodOptional<z.ZodString>;
25
15
  path: z.ZodOptional<z.ZodString>;
26
- }, "strict", z.ZodTypeAny, {
27
- name: string;
28
- value_template: string;
29
- path?: string | undefined;
30
- domain?: string | undefined;
31
- }, {
32
- name: string;
33
- path?: string | undefined;
34
- domain?: string | undefined;
35
- value_template?: string | undefined;
36
- }>, "many">>;
37
- }, "strict", z.ZodTypeAny, {
38
- cookies?: {
39
- name: string;
40
- value_template: string;
41
- path?: string | undefined;
42
- domain?: string | undefined;
43
- }[] | undefined;
44
- localStorage?: {
45
- key: string;
46
- value_template: string;
47
- }[] | undefined;
48
- }, {
49
- cookies?: {
50
- name: string;
51
- path?: string | undefined;
52
- domain?: string | undefined;
53
- value_template?: string | undefined;
54
- }[] | undefined;
55
- localStorage?: {
56
- key: string;
57
- value_template?: string | undefined;
58
- }[] | undefined;
59
- }>, {
60
- cookies?: {
61
- name: string;
62
- value_template: string;
63
- path?: string | undefined;
64
- domain?: string | undefined;
65
- }[] | undefined;
66
- localStorage?: {
67
- key: string;
68
- value_template: string;
69
- }[] | undefined;
70
- }, {
71
- cookies?: {
72
- name: string;
73
- path?: string | undefined;
74
- domain?: string | undefined;
75
- value_template?: string | undefined;
76
- }[] | undefined;
77
- localStorage?: {
78
- key: string;
79
- value_template?: string | undefined;
80
- }[] | undefined;
81
- }>;
82
- }, "strict", z.ZodTypeAny, {
83
- inject: {
84
- cookies?: {
85
- name: string;
86
- value_template: string;
87
- path?: string | undefined;
88
- domain?: string | undefined;
89
- }[] | undefined;
90
- localStorage?: {
91
- key: string;
92
- value_template: string;
93
- }[] | undefined;
94
- };
95
- token_env?: string | undefined;
96
- token_url?: string | undefined;
97
- }, {
98
- inject: {
99
- cookies?: {
100
- name: string;
101
- path?: string | undefined;
102
- domain?: string | undefined;
103
- value_template?: string | undefined;
104
- }[] | undefined;
105
- localStorage?: {
106
- key: string;
107
- value_template?: string | undefined;
108
- }[] | undefined;
109
- };
110
- token_env?: string | undefined;
111
- token_url?: string | undefined;
112
- }>, {
113
- inject: {
114
- cookies?: {
115
- name: string;
116
- value_template: string;
117
- path?: string | undefined;
118
- domain?: string | undefined;
119
- }[] | undefined;
120
- localStorage?: {
121
- key: string;
122
- value_template: string;
123
- }[] | undefined;
124
- };
125
- token_env?: string | undefined;
126
- token_url?: string | undefined;
127
- }, {
128
- inject: {
129
- cookies?: {
130
- name: string;
131
- path?: string | undefined;
132
- domain?: string | undefined;
133
- value_template?: string | undefined;
134
- }[] | undefined;
135
- localStorage?: {
136
- key: string;
137
- value_template?: string | undefined;
138
- }[] | undefined;
139
- };
140
- token_env?: string | undefined;
141
- token_url?: string | undefined;
142
- }>;
16
+ }, z.core.$strict>>>;
17
+ }, z.core.$strict>;
18
+ }, z.core.$strict>;
143
19
  export type JwtInjectionOptions = z.infer<typeof JwtInjectionOptions>;
144
- /** Decode a JWT's payload (base64url, **no signature verification**) — claims-reading only. */
20
+ /** Decode a JWT's payload (base64url, **no signature verification**), claims-reading only. */
145
21
  export declare function decodeJwtPayload(token: string): Record<string, unknown> | undefined;
146
22
  export declare class JwtInjectionStrategy implements AuthStrategy {
147
23
  private readonly fetchImpl;
@@ -1,4 +1,4 @@
1
- // `jwt-injection` — obtain a bearer token (static env var, or an OAuth2 client-credentials
1
+ // `jwt-injection`: obtain a bearer token (static env var, or an OAuth2 client-credentials
2
2
  // grant) and inject it into the browser's storage the way the target SPA expects it:
3
3
  // localStorage keys and/or cookies, rendered from `{{token}}` templates. Pure node, no browser.
4
4
  import { z } from "zod";
@@ -34,14 +34,14 @@ export const JwtInjectionOptions = z
34
34
  })
35
35
  .strict()
36
36
  .refine((i) => (i.localStorage?.length ?? 0) + (i.cookies?.length ?? 0) > 0, {
37
- message: "inject needs at least one localStorage or cookies entry",
37
+ error: "inject needs at least one localStorage or cookies entry",
38
38
  }),
39
39
  })
40
40
  .strict()
41
41
  .refine((o) => (o.token_env !== undefined) !== (o.token_url !== undefined), {
42
- message: "exactly one of token_env or token_url is required",
42
+ error: "exactly one of token_env or token_url is required",
43
43
  });
44
- /** Decode a JWT's payload (base64url, **no signature verification**) — claims-reading only. */
44
+ /** Decode a JWT's payload (base64url, **no signature verification**), claims-reading only. */
45
45
  export function decodeJwtPayload(token) {
46
46
  const payload = token.split(".")[1];
47
47
  if (!payload)
@@ -87,7 +87,7 @@ export class JwtInjectionStrategy {
87
87
  }).toString(),
88
88
  });
89
89
  if (!response.ok) {
90
- throw new AuthStrategyConfigError(`jwt-injection: token endpoint ${tokenUrl.href} answered ${response.status} (client_secret: ${maskSecret(clientSecret)} — value not shown)`);
90
+ throw new AuthStrategyConfigError(`jwt-injection: token endpoint ${tokenUrl.href} answered ${response.status} (client_secret: ${maskSecret(clientSecret)}, value not shown)`);
91
91
  }
92
92
  let body;
93
93
  try {
@@ -1,7 +1,7 @@
1
1
  import { type AuthContext, type AuthResult, type AuthStrategy, type StorageState } from "./types.js";
2
2
  export type CaptureTrigger = "console" | "button";
3
3
  /**
4
- * The browser the engine drives for `manual-capture` — a security-lowered, *instrumented* Chrome.
4
+ * The browser the engine drives for `manual-capture`, a security-lowered, *instrumented* Chrome.
5
5
  * The Playwright-backed implementation lives in a separate module (so this strategy stays testable);
6
6
  * `--disable-web-security` etc. let the injected capture helper work across SSO-redirect origins.
7
7
  */
@@ -11,7 +11,7 @@ export interface InstrumentedBrowser {
11
11
  /**
12
12
  * Inject the capture helper (a console function `window.__docsxai.capture()` and/or an on-page button)
13
13
  * and resolve once the human triggers it. The human does the interactive login (SSO / MFA / conditional
14
- * access — anything they can click through) before triggering.
14
+ * access: anything they can click through) before triggering.
15
15
  */
16
16
  waitForCapture(trigger: CaptureTrigger): Promise<void>;
17
17
  /** Snapshot the current `storageState`. */
@@ -23,7 +23,7 @@ export interface ManualCaptureOptions {
23
23
  capture_trigger?: CaptureTrigger;
24
24
  }
25
25
  /**
26
- * `manual-capture` — the plugin spawns a security-lowered, instrumented Chrome; the engineer logs in
26
+ * `manual-capture`: the plugin spawns a security-lowered, instrumented Chrome; the engineer logs in
27
27
  * interactively; a console command or an injected button snapshots `storageState`. The zero-integration
28
28
  * universal fallback for SSO / MFA / conditional access, at the cost of periodic human re-capture.
29
29
  */
@@ -1,6 +1,6 @@
1
- // `manual-capture` — the zero-integration universal fallback for SSO / MFA / conditional access.
1
+ // `manual-capture`: the zero-integration universal fallback for SSO / MFA / conditional access.
2
2
  /**
3
- * `manual-capture` — the plugin spawns a security-lowered, instrumented Chrome; the engineer logs in
3
+ * `manual-capture`: the plugin spawns a security-lowered, instrumented Chrome; the engineer logs in
4
4
  * interactively; a console command or an injected button snapshots `storageState`. The zero-integration
5
5
  * universal fallback for SSO / MFA / conditional access, at the cost of periodic human re-capture.
6
6
  */
@@ -1,13 +1,8 @@
1
1
  import { z } from "zod";
2
2
  import { type AuthContext, type AuthResult, type AuthStrategy } from "./types.js";
3
3
  export declare const MtlsOptions: z.ZodObject<{
4
- /** Origin the certificate applies to. Default: the target's baseURL origin. */
5
4
  origin: z.ZodOptional<z.ZodString>;
6
- }, "strict", z.ZodTypeAny, {
7
- origin?: string | undefined;
8
- }, {
9
- origin?: string | undefined;
10
- }>;
5
+ }, z.core.$strict>;
11
6
  export type MtlsOptions = z.infer<typeof MtlsOptions>;
12
7
  export declare class MtlsStrategy implements AuthStrategy {
13
8
  readonly name: "mtls";
package/dist/auth/mtls.js CHANGED
@@ -1,4 +1,4 @@
1
- // `mtls` — connection-level auth: the browser context presents a client certificate during the
1
+ // `mtls`: connection-level auth: the browser context presents a client certificate during the
2
2
  // TLS handshake. The creds env vars hold *paths* to the PEM files (cert/key stay on disk; the
3
3
  // strategy validates they exist and look like PEM but never reads them into logs or errors).
4
4
  // An optional `passphrase` cred decrypts an encrypted key. Empty storageState;
@@ -1,17 +1,9 @@
1
1
  import { z } from "zod";
2
2
  import { type AuthContext, type AuthResult, type AuthStrategy } from "./types.js";
3
3
  export declare const PatHeaderOptions: z.ZodObject<{
4
- /** Header name. Default `Authorization`. */
5
4
  header: z.ZodDefault<z.ZodString>;
6
- /** `{{token}}` template for the header value. Default `Bearer {{token}}`. */
7
5
  value_template: z.ZodDefault<z.ZodString>;
8
- }, "strict", z.ZodTypeAny, {
9
- value_template: string;
10
- header: string;
11
- }, {
12
- value_template?: string | undefined;
13
- header?: string | undefined;
14
- }>;
6
+ }, z.core.$strict>;
15
7
  export type PatHeaderOptions = z.infer<typeof PatHeaderOptions>;
16
8
  export declare class PatHeaderStrategy implements AuthStrategy {
17
9
  readonly name: "pat-header";
@@ -1,4 +1,4 @@
1
- // `pat-header` — connection-level auth: every request the browser context makes carries a
1
+ // `pat-header`: connection-level auth: every request the browser context makes carries a
2
2
  // personal-access-token header (`Authorization: Bearer <token>` by default). Empty storageState;
3
3
  // the strategy emits `contextOptions.extraHTTPHeaders`.
4
4
  import { z } from "zod";
@@ -1,22 +1,32 @@
1
1
  import { type RoleAuth } from "../doc-pack.js";
2
2
  import { type AuthResult, type StorageState } from "./types.js";
3
+ /**
4
+ * The file name (under `.auth/`) that holds a role's session. A role made of safe characters keeps
5
+ * its own name. Any other role gets its unsafe characters replaced and a short hash of the exact
6
+ * role appended, so `a/b` and `a_b` never share a file, and no role lands on the OAuth token file.
7
+ */
8
+ export declare function storageStateFileName(role: string): string;
9
+ /** True when the role's file in `<dir>` exists but is not a cached session (not JSON, or the wrong shape). */
10
+ export declare function cachedSessionIsCorrupt(dir: string, role: string): Promise<boolean>;
3
11
  export declare class LocalStorageStateCache {
4
12
  private readonly dir;
5
13
  /** @param dir the `.auth/` directory (relative paths resolved against cwd). */
6
14
  constructor(dir?: string);
7
15
  private fileName;
8
16
  private file;
17
+ /** The path of the cache file for `role`. */
18
+ filePath(role: string): string;
9
19
  /** Return the cached state for a role if present and not past its expiry; otherwise `null`. */
10
20
  load(role: string, now?: number): Promise<StorageState | null>;
11
21
  /**
12
22
  * Persist a captured session and compute its expiry, in priority order:
13
- * 1. **The app's auth cookie** — if `auth_cookie` (descriptor or override) names a cookie that's in the
23
+ * 1. **The app's auth cookie**, if `auth_cookie` (descriptor or override) names a cookie that's in the
14
24
  * captured jar with a real (non-session) expiry, that expiry *is* the bound. This is the right answer;
15
- * the host agent identifies which cookie it is (it's on the app's domain, long-lived — not an ephemeral
25
+ * the host agent identifies which cookie it is (it's on the app's domain, long-lived, not an ephemeral
16
26
  * IdP scratch cookie). Why not just `min(cookie.expires)`? An interactive SSO login drops scratch cookies
17
27
  * that expire seconds out, so the min ≈ now and the session would be born expired.
18
- * 2. **`ttl`** — a duration (`1h`, `30m`, ms) → `now + ttl`. The fallback when no `auth_cookie` is set/found.
19
- * 3. **`session` / default** — the strategy's reported `expiresAt` if plausibly in the future, else +1h.
28
+ * 2. **`ttl`**, a duration (`1h`, `30m`, ms) → `now + ttl`. The fallback when no `auth_cookie` is set/found.
29
+ * 3. **`session` / default**, the strategy's reported `expiresAt` if plausibly in the future, else +1h.
20
30
  * Returns the computed `expiresAt` and a human-readable `source`.
21
31
  */
22
32
  save(role: string, result: AuthResult, roleAuth: RoleAuth, now?: number, opts?: {
@@ -27,12 +37,12 @@ export declare class LocalStorageStateCache {
27
37
  }>;
28
38
  clear(role: string): Promise<void>;
29
39
  }
30
- /** The cache surface both stores satisfy — `load` / `save` / `clear` per role. */
40
+ /** The cache surface both stores satisfy, `load` / `save` / `clear` per role. */
31
41
  export type StorageStateCache = Pick<LocalStorageStateCache, "load" | "save" | "clear">;
32
42
  /**
33
43
  * Pick the state cache for a role. `store: local` (the default) caches under `<workspace>/.auth/`.
34
44
  * `store: backend` relays AES-256-GCM envelopes through the backend (encrypted client-side; the
35
- * backend never sees plaintext) — it needs a workspace that has been pushed (`backend_url` +
45
+ * backend never sees plaintext), it needs a workspace that has been pushed (`backend_url` +
36
46
  * `backend_workspace_id` in `.docsxai.json`) and `DOCSX_CACHE_KEY`.
37
47
  */
38
48
  export declare function resolveStateCache(roleAuth: RoleAuth, workspaceDir: string): Promise<StorageStateCache>;