@duct-sdk/sdk 0.4.5 → 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.
Files changed (58) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +36 -1
  3. package/TOKEN_SPEC.md +237 -0
  4. package/dist/adapters/react/page-context-guard.d.ts +7 -0
  5. package/dist/adapters/react/page-context-guard.js +26 -0
  6. package/dist/adapters/react/page-context-guard.test.d.ts +1 -0
  7. package/dist/adapters/react/page-context-guard.test.js +15 -0
  8. package/dist/adapters/react/shell.js +1 -23
  9. package/dist/adapters/react/use-page-context.d.ts +1 -1
  10. package/dist/adapters/react/use-page-context.js +6 -16
  11. package/dist/cli/agents/reviewer-agent.d.ts +3 -1
  12. package/dist/cli/agents/reviewer-agent.js +29 -21
  13. package/dist/cli/config-loader.d.ts +15 -0
  14. package/dist/cli/config-loader.js +187 -0
  15. package/dist/cli/config-loader.test.d.ts +1 -0
  16. package/dist/cli/config-loader.test.js +63 -0
  17. package/dist/cli/detectors/framework.d.ts +1 -1
  18. package/dist/cli/detectors/framework.js +40 -0
  19. package/dist/cli/generators/receiver.js +206 -76
  20. package/dist/cli/generators/shell.js +50 -4
  21. package/dist/cli/generators/shell.test.d.ts +1 -0
  22. package/dist/cli/generators/shell.test.js +73 -0
  23. package/dist/cli/generators/token-route.d.ts +1 -0
  24. package/dist/cli/generators/token-route.js +108 -5
  25. package/dist/cli/generators/wiring-snippets.js +59 -19
  26. package/dist/cli/generators/wiring-snippets.test.js +15 -1
  27. package/dist/cli/index.js +108 -151
  28. package/dist/cli/init.js +110 -17
  29. package/dist/cli/manifest-diff.d.ts +21 -0
  30. package/dist/cli/manifest-diff.js +158 -0
  31. package/dist/cli/manifest-diff.test.d.ts +1 -0
  32. package/dist/cli/manifest-diff.test.js +104 -0
  33. package/dist/cli/output-paths.d.ts +2 -0
  34. package/dist/cli/output-paths.js +22 -4
  35. package/dist/core/config-policy.test.d.ts +1 -0
  36. package/dist/core/config-policy.test.js +101 -0
  37. package/dist/core/config.d.ts +86 -1
  38. package/dist/core/config.js +120 -2
  39. package/dist/core/invariants.test.d.ts +1 -0
  40. package/dist/core/invariants.test.js +217 -0
  41. package/dist/core/jcs.d.ts +5 -0
  42. package/dist/core/jcs.js +21 -0
  43. package/dist/core/receipt.d.ts +70 -0
  44. package/dist/core/receipt.js +86 -0
  45. package/dist/core/receipt.test.d.ts +1 -0
  46. package/dist/core/receipt.test.js +75 -0
  47. package/dist/core/replay-store.d.ts +51 -0
  48. package/dist/core/replay-store.js +65 -0
  49. package/dist/core/token.d.ts +14 -0
  50. package/dist/core/token.js +50 -18
  51. package/dist/core/token.test.d.ts +1 -0
  52. package/dist/core/token.test.js +66 -0
  53. package/dist/core/types.d.ts +72 -0
  54. package/dist/index.d.ts +6 -4
  55. package/dist/index.js +4 -2
  56. package/dist/server.d.ts +6 -4
  57. package/dist/server.js +4 -2
  58. package/package.json +91 -90
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Pluggable store for deeplink JWT replay protection.
3
+ * Used by `verifyDeeplinkToken` when `replayStore` is provided.
4
+ */
5
+ export interface DeeplinkReplayStore {
6
+ /** Returns true if this jti was already consumed. */
7
+ seen(jti: string): Promise<boolean>;
8
+ /** Record a consumed jti for at least `ttlSec` seconds. */
9
+ record(jti: string, ttlSec: number): Promise<void>;
10
+ }
11
+ /**
12
+ * In-process replay store for **single-instance development only**.
13
+ *
14
+ * Not safe for multi-replica, serverless, or production deployments — use
15
+ * {@link RedisReplayStore} with a shared Redis instance instead.
16
+ */
17
+ export declare class InMemoryReplayStore implements DeeplinkReplayStore {
18
+ private readonly used;
19
+ constructor();
20
+ seen(jti: string): Promise<boolean>;
21
+ record(jti: string, ttlSec: number): Promise<void>;
22
+ }
23
+ /** Minimal Redis client surface for replay keys. */
24
+ export interface RedisSetClient {
25
+ get(key: string): Promise<string | null>;
26
+ set(key: string, value: string, options: {
27
+ NX: true;
28
+ EX: number;
29
+ }): Promise<string | null>;
30
+ }
31
+ /**
32
+ * Redis-backed replay store for production (multi-replica / serverless).
33
+ *
34
+ * Uses `SET key value EX ttl NX` — returns null when the jti was already seen.
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * import Redis from "ioredis";
39
+ * const store = new RedisReplayStore(new Redis(process.env.REDIS_URL), "duct:jti:");
40
+ * await verifyDeeplinkToken(token, { secretKey, replayStore: store });
41
+ * ```
42
+ */
43
+ export declare class RedisReplayStore implements DeeplinkReplayStore {
44
+ private readonly redis;
45
+ private readonly keyPrefix;
46
+ constructor(redis: RedisSetClient, keyPrefix?: string);
47
+ seen(jti: string): Promise<boolean>;
48
+ record(jti: string, ttlSec: number): Promise<void>;
49
+ }
50
+ /** Dev-only helper — documented as not production-safe. */
51
+ export declare function createDevReplayStore(): InMemoryReplayStore;
@@ -0,0 +1,65 @@
1
+ // ============================================================
2
+ // @duct/sdk — Deeplink JTI replay stores
3
+ // ============================================================
4
+ /**
5
+ * In-process replay store for **single-instance development only**.
6
+ *
7
+ * Not safe for multi-replica, serverless, or production deployments — use
8
+ * {@link RedisReplayStore} with a shared Redis instance instead.
9
+ */
10
+ export class InMemoryReplayStore {
11
+ used = new Map();
12
+ constructor() {
13
+ const prune = () => {
14
+ const now = Date.now();
15
+ for (const [jti, at] of this.used) {
16
+ if (now - at > 10 * 60 * 1000)
17
+ this.used.delete(jti);
18
+ }
19
+ };
20
+ const timer = setInterval(prune, 60_000);
21
+ timer.unref?.();
22
+ }
23
+ async seen(jti) {
24
+ return this.used.has(jti);
25
+ }
26
+ async record(jti, ttlSec) {
27
+ this.used.set(jti, Date.now());
28
+ // Best-effort expiry for dev; production should use RedisReplayStore.
29
+ void ttlSec;
30
+ }
31
+ }
32
+ /**
33
+ * Redis-backed replay store for production (multi-replica / serverless).
34
+ *
35
+ * Uses `SET key value EX ttl NX` — returns null when the jti was already seen.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * import Redis from "ioredis";
40
+ * const store = new RedisReplayStore(new Redis(process.env.REDIS_URL), "duct:jti:");
41
+ * await verifyDeeplinkToken(token, { secretKey, replayStore: store });
42
+ * ```
43
+ */
44
+ export class RedisReplayStore {
45
+ redis;
46
+ keyPrefix;
47
+ constructor(redis, keyPrefix = "duct:jti:") {
48
+ this.redis = redis;
49
+ this.keyPrefix = keyPrefix;
50
+ }
51
+ async seen(jti) {
52
+ const existing = await this.redis.get(`${this.keyPrefix}${jti}`);
53
+ return existing !== null;
54
+ }
55
+ async record(jti, ttlSec) {
56
+ await this.redis.set(`${this.keyPrefix}${jti}`, "1", {
57
+ NX: true,
58
+ EX: Math.max(1, Math.ceil(ttlSec)),
59
+ });
60
+ }
61
+ }
62
+ /** Dev-only helper — documented as not production-safe. */
63
+ export function createDevReplayStore() {
64
+ return new InMemoryReplayStore();
65
+ }
@@ -1,4 +1,8 @@
1
+ import type { DeeplinkReplayStore } from "./replay-store.js";
1
2
  import type { DuctTokenPayload, DeeplinkTokenPayload } from "./types.js";
3
+ export type { DeeplinkReplayStore } from "./replay-store.js";
4
+ export { InMemoryReplayStore, RedisReplayStore, createDevReplayStore, } from "./replay-store.js";
5
+ export type { RedisSetClient } from "./replay-store.js";
2
6
  export interface GenerateTokenOptions {
3
7
  /** HMAC-SHA256 secret key (at least 32 characters recommended) */
4
8
  secretKey: string;
@@ -13,6 +17,11 @@ export interface GenerateTokenOptions {
13
17
  expirySeconds?: number;
14
18
  /** Action IDs this token is permitted to invoke */
15
19
  allowedActions?: string[];
20
+ /**
21
+ * Allowlisted session field names from `auth.sessionFields`.
22
+ * Only these keys are copied into the delegated JWT payload.
23
+ */
24
+ sessionFields?: string[];
16
25
  }
17
26
  export interface GenerateTokenResult {
18
27
  token: string;
@@ -93,6 +102,11 @@ export interface VerifyDeeplinkTokenOptions {
93
102
  expectedShellId?: string;
94
103
  /** Expected deeplink ID */
95
104
  expectedDeeplinkId?: string;
105
+ /**
106
+ * Optional replay store — when set, each `jti` may only be verified once
107
+ * within the token TTL window. Use {@link RedisReplayStore} in production.
108
+ */
109
+ replayStore?: DeeplinkReplayStore;
96
110
  }
97
111
  export interface VerifyDeeplinkResult {
98
112
  valid: boolean;
@@ -2,6 +2,7 @@
2
2
  // @duct/sdk — Token Generation and Verification
3
3
  // ============================================================
4
4
  import { SignJWT, jwtVerify } from "jose";
5
+ export { InMemoryReplayStore, RedisReplayStore, createDevReplayStore, } from "./replay-store.js";
5
6
  // ----------------------------------------------------------------
6
7
  // Helpers
7
8
  // ----------------------------------------------------------------
@@ -11,32 +12,43 @@ import { SignJWT, jwtVerify } from "jose";
11
12
  function encodeSecret(secret) {
12
13
  return new TextEncoder().encode(secret);
13
14
  }
15
+ const DENYLIST_KEY_FRAGMENTS = [
16
+ "token",
17
+ "secret",
18
+ "password",
19
+ "key",
20
+ "hash",
21
+ "salt",
22
+ "credential",
23
+ "jwt",
24
+ "cookie",
25
+ "bearer",
26
+ "ssn",
27
+ "otp",
28
+ ];
29
+ function isDeniedScalarKey(key) {
30
+ const lowerKey = key.toLowerCase();
31
+ return DENYLIST_KEY_FRAGMENTS.some((frag) => lowerKey.includes(frag));
32
+ }
14
33
  /**
15
- * Filter a session object to only scalar values (no nested objects, arrays,
16
- * or token-like strings). Prevents leaking sensitive data into JWTs.
34
+ * Filter a session object to only declared allowlisted scalar fields, with a
35
+ * secondary denylist guard. Prevents leaking sensitive data into JWTs.
17
36
  */
18
- function filterScalars(session) {
37
+ function filterScalars(session, allowlist) {
19
38
  const result = {};
20
- for (const [key, value] of Object.entries(session)) {
21
- // Skip anything that looks like a token, password, or secret
22
- const lowerKey = key.toLowerCase();
23
- if (lowerKey.includes("token") ||
24
- lowerKey.includes("secret") ||
25
- lowerKey.includes("password") ||
26
- lowerKey.includes("key") ||
27
- lowerKey.includes("hash") ||
28
- lowerKey.includes("salt") ||
29
- lowerKey.includes("credential")) {
39
+ const entries = allowlist && allowlist.length > 0
40
+ ? allowlist.map((key) => [key, session[key]])
41
+ : Object.entries(session);
42
+ for (const [key, value] of entries) {
43
+ if (isDeniedScalarKey(key)) {
30
44
  continue;
31
45
  }
32
- // Only accept scalar values
33
46
  if (typeof value === "string" ||
34
47
  typeof value === "number" ||
35
48
  typeof value === "boolean" ||
36
49
  value === null) {
37
50
  result[key] = value;
38
51
  }
39
- // Skip nested objects, arrays, undefined, functions, symbols
40
52
  }
41
53
  return result;
42
54
  }
@@ -56,12 +68,12 @@ function filterScalars(session) {
56
68
  * ```
57
69
  */
58
70
  export async function generateDuctToken(options) {
59
- const { secretKey, userSession, shellId, expirySeconds = 60, allowedActions, } = options;
71
+ const { secretKey, userSession, shellId, expirySeconds = 60, allowedActions, sessionFields, } = options;
60
72
  if (!secretKey || secretKey.length < 16) {
61
73
  throw new Error("DUCT_SECRET_KEY must be at least 16 characters. Use a strong random secret in production.");
62
74
  }
63
75
  const sub = String(userSession.id ?? userSession.sub ?? "anonymous");
64
- const filteredSession = filterScalars(userSession);
76
+ const filteredSession = filterScalars(userSession, sessionFields);
65
77
  const now = Math.floor(Date.now() / 1000);
66
78
  const exp = now + expirySeconds;
67
79
  const payload = {
@@ -170,7 +182,7 @@ export async function generateDeeplinkToken(options) {
170
182
  * Verify a Duct deeplink token (received at the receiver endpoint).
171
183
  */
172
184
  export async function verifyDeeplinkToken(token, options) {
173
- const { secretKey, expectedShellId, expectedDeeplinkId } = options;
185
+ const { secretKey, expectedShellId, expectedDeeplinkId, replayStore } = options;
174
186
  try {
175
187
  // Only enforce audience if expectedShellId is provided.
176
188
  // Tokens generated before aud was added will still verify without it.
@@ -193,6 +205,25 @@ export async function verifyDeeplinkToken(token, options) {
193
205
  error: `Deeplink ID mismatch: expected "${expectedDeeplinkId}", got "${typedPayload.deeplink_id}"`,
194
206
  };
195
207
  }
208
+ const jti = typedPayload.jti ?? "";
209
+ if (replayStore) {
210
+ if (!jti) {
211
+ return {
212
+ valid: false,
213
+ error: "Token is missing jti claim (required for replay protection)",
214
+ };
215
+ }
216
+ if (await replayStore.seen(jti)) {
217
+ return {
218
+ valid: false,
219
+ error: "Token already used",
220
+ };
221
+ }
222
+ const nowSec = Math.floor(Date.now() / 1000);
223
+ const exp = typedPayload.exp ?? nowSec + 300;
224
+ const ttlSec = Math.max(exp - nowSec + 300, 600);
225
+ await replayStore.record(jti, ttlSec);
226
+ }
196
227
  return {
197
228
  valid: true,
198
229
  payload: {
@@ -201,6 +232,7 @@ export async function verifyDeeplinkToken(token, options) {
201
232
  iss: typedPayload.iss ?? "",
202
233
  iat: typedPayload.iat ?? 0,
203
234
  exp: typedPayload.exp ?? 0,
235
+ jti,
204
236
  state: typedPayload.state ?? {},
205
237
  },
206
238
  };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,66 @@
1
+ import { describe, it } from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import { generateDeeplinkToken, verifyDeeplinkToken, generateDuctToken, verifyDuctToken, createDevReplayStore, } from "./token.js";
4
+ const SECRET = "test-secret-key-at-least-32-chars-long";
5
+ const SHELL_ID = "shell_test_prod";
6
+ describe("verifyDeeplinkToken replay protection", () => {
7
+ it("mint → verify ok → replay rejected when store configured", async () => {
8
+ const replayStore = createDevReplayStore();
9
+ const { token } = await generateDeeplinkToken({
10
+ secretKey: SECRET,
11
+ shellId: SHELL_ID,
12
+ deeplinkId: "view_order",
13
+ state: { orderId: "42" },
14
+ });
15
+ const first = await verifyDeeplinkToken(token, {
16
+ secretKey: SECRET,
17
+ expectedShellId: SHELL_ID,
18
+ replayStore,
19
+ });
20
+ assert.equal(first.valid, true);
21
+ assert.ok(first.payload);
22
+ assert.notEqual(first.payload.jti, "");
23
+ const second = await verifyDeeplinkToken(token, {
24
+ secretKey: SECRET,
25
+ expectedShellId: SHELL_ID,
26
+ replayStore,
27
+ });
28
+ assert.equal(second.valid, false);
29
+ assert.equal(second.error, "Token already used");
30
+ });
31
+ it("populates jti on verified payload", async () => {
32
+ const { token } = await generateDeeplinkToken({
33
+ secretKey: SECRET,
34
+ shellId: SHELL_ID,
35
+ deeplinkId: "view_order",
36
+ });
37
+ const result = await verifyDeeplinkToken(token, {
38
+ secretKey: SECRET,
39
+ expectedShellId: SHELL_ID,
40
+ });
41
+ assert.equal(result.valid, true);
42
+ assert.ok(result.payload);
43
+ assert.notEqual(result.payload.jti, "");
44
+ });
45
+ });
46
+ describe("generateDuctToken session allowlist", () => {
47
+ it("copies only auth.sessionFields scalars into delegated JWT", async () => {
48
+ const { token } = await generateDuctToken({
49
+ secretKey: SECRET,
50
+ shellId: SHELL_ID,
51
+ userSession: {
52
+ userId: "u_123",
53
+ jwt: "eyJhbGciOiJIUzI1NiJ9.secret",
54
+ ssn: "123-45-6789",
55
+ email: "user@example.com",
56
+ },
57
+ sessionFields: ["userId"],
58
+ });
59
+ const verified = await verifyDuctToken(token, {
60
+ secretKey: SECRET,
61
+ expectedShellId: SHELL_ID,
62
+ });
63
+ assert.equal(verified.valid, true);
64
+ assert.deepEqual(verified.payload?.session, { userId: "u_123" });
65
+ });
66
+ });
@@ -47,6 +47,39 @@ export interface RouteManifest {
47
47
  };
48
48
  }
49
49
  export type SensitivityLevel = "none" | "low" | "medium" | "high" | "critical";
50
+ /** Comparison operators for {@link ApprovalPredicate} over invoke params. */
51
+ export type ApprovalCompareOp = "gt" | "gte" | "lt" | "lte" | "eq" | "neq";
52
+ /** Logical combinators for nested {@link ApprovalPredicate} trees. */
53
+ export type ApprovalLogicalOp = "and" | "or";
54
+ /**
55
+ * Conditional approval predicate evaluated against action invoke params.
56
+ * When true, the Duct gateway requires human confirmation before execution.
57
+ * Absent on an action = no conditional approval rule (existing side-effect / sensitivity gates apply).
58
+ */
59
+ export type ApprovalPredicate = {
60
+ op: ApprovalLogicalOp;
61
+ rules: ApprovalPredicate[];
62
+ } | {
63
+ op: "in";
64
+ param: string;
65
+ values: (number | string | boolean)[];
66
+ } | {
67
+ op: ApprovalCompareOp;
68
+ param: string;
69
+ value: number | string | boolean;
70
+ };
71
+ /**
72
+ * Per-action invocation limit — rate (rolling window) or count (total cap).
73
+ * Enforced by the Duct gateway; absent = no manifest-declared limit.
74
+ */
75
+ export type ActionLimitPolicy = {
76
+ type: "rate";
77
+ maxPerWindow: number;
78
+ windowSeconds: number;
79
+ } | {
80
+ type: "count";
81
+ maxCount: number;
82
+ };
50
83
  export interface ActionParam {
51
84
  name: string;
52
85
  type: "string" | "number" | "boolean" | "object" | "array";
@@ -92,6 +125,27 @@ export interface ActionManifest {
92
125
  confidence?: number;
93
126
  /** Files and signals that led to this action being detected (e.g. "routes/orders.ts:42"). */
94
127
  evidence?: string[];
128
+ /**
129
+ * ISO 8601 — action grant is inactive before this instant.
130
+ * Enforced by the Duct gateway. Absent = no time lower bound.
131
+ */
132
+ validFrom?: string;
133
+ /**
134
+ * ISO 8601 — action grant expires after this instant.
135
+ * Enforced by the Duct gateway. Absent = no time upper bound.
136
+ */
137
+ validUntil?: string;
138
+ /**
139
+ * Require human approval when this predicate matches invoke params
140
+ * (e.g. `{ op: "gt", param: "amount", value: 100 }`).
141
+ * Enforced by the Duct gateway. Absent = no conditional approval rule.
142
+ */
143
+ approveIf?: ApprovalPredicate;
144
+ /**
145
+ * Per-action rate or count limit. Enforced by the Duct gateway.
146
+ * Absent = no manifest-declared limit beyond global rateLimit.
147
+ */
148
+ actionLimit?: ActionLimitPolicy;
95
149
  /**
96
150
  * Declares that this action depends on results from other actions.
97
151
  * Forms a DAG; shell runtime traverses it via topological sort.
@@ -223,6 +277,22 @@ export interface AgentPermissions {
223
277
  requireUserConsent: boolean;
224
278
  /** Allowed actions (action IDs) */
225
279
  allowedActions?: string[];
280
+ /**
281
+ * ISO 8601 — shell-wide agent grant inactive before this instant.
282
+ * Enforced by the Duct gateway. Absent = no time lower bound.
283
+ */
284
+ validFrom?: string;
285
+ /**
286
+ * ISO 8601 — shell-wide agent grant expires after this instant.
287
+ * Enforced by the Duct gateway. Absent = no time upper bound.
288
+ */
289
+ validUntil?: string;
290
+ /**
291
+ * Explicit action IDs third-party consent (`uct_`) may authorize per request.
292
+ * When set, wildcard `['*']` consent is rejected — each grant must list actions from this set.
293
+ * Enforced at consent issuance and the Duct gateway. Absent = legacy wildcard allowed.
294
+ */
295
+ consentActionScope?: string[];
226
296
  }
227
297
  /**
228
298
  * Shell panel size/shape presets.
@@ -660,6 +730,8 @@ export interface DeeplinkTokenPayload {
660
730
  iat: number;
661
731
  /** Expiration */
662
732
  exp: number;
733
+ /** JWT ID — single-use replay protection */
734
+ jti: string;
663
735
  /** State fields */
664
736
  state: Record<string, unknown>;
665
737
  }
package/dist/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
- export { defineDuctConfig, DuctConfigSchema } from "./core/config.js";
1
+ export { defineDuctConfig, DuctConfigSchema, crossValidateDuctConfig } from "./core/config.js";
2
2
  export type { ValidatedDuctConfig } from "./core/config.js";
3
- export { generateDuctToken, verifyDuctToken, generateDeeplinkToken, verifyDeeplinkToken, } from "./core/token.js";
4
- export type { GenerateTokenOptions, GenerateTokenResult, VerifyTokenOptions, VerifyTokenResult, GenerateDeeplinkTokenOptions, GenerateDeeplinkTokenResult, VerifyDeeplinkTokenOptions, VerifyDeeplinkResult, } from "./core/token.js";
3
+ export { generateDuctToken, verifyDuctToken, generateDeeplinkToken, verifyDeeplinkToken, createDevReplayStore, InMemoryReplayStore, RedisReplayStore, } from "./core/token.js";
4
+ export type { GenerateTokenOptions, GenerateTokenResult, VerifyTokenOptions, VerifyTokenResult, GenerateDeeplinkTokenOptions, GenerateDeeplinkTokenResult, VerifyDeeplinkTokenOptions, VerifyDeeplinkResult, DeeplinkReplayStore, RedisSetClient, } from "./core/token.js";
5
+ export { verifyReceipt, computeReceiptId } from "./core/receipt.js";
6
+ export type { SignedDuctReceipt, DuctReceiptBody, ReceiptClaimType, ReceiptJwks, VerifyReceiptOptions, VerifyReceiptResult, ReceiptRejectionReason, } from "./core/receipt.js";
5
7
  export { buildAction, checkActionPermission, buildActionSearchIndex, shouldDeferActions, } from "./core/action.js";
6
8
  export type { ActionSearchEntry } from "./core/action.js";
7
9
  export { checkShellStatus } from "./core/status.js";
@@ -13,4 +15,4 @@ export type { ShellPreset, ShellPanelViewportInsets } from "./core/types.js";
13
15
  export type { DuctPageContext } from "./core/types.js";
14
16
  export { useDuctPageContext } from "./adapters/react/use-page-context.js";
15
17
  export type { UseDuctPageContextOptions } from "./adapters/react/use-page-context.js";
16
- export type { RouteManifest, RouteParam, QueryParam, UIStateHint, ActionManifest, ActionParam, SensitivityLevel, ActionRuntimeFields, ActionDef, BuiltActionDef, ActionValidationResult, AuthSchema, AuthStrategy, DeeplinkDefinition, StateField, ReviewResult, ReviewIssue, ReviewIssueSeverity, DuctConfig, ProductConfig, AgentPermissions, AgentPermissionLevel, WidgetConfig, ShellManifest, ModalityDecision, ScoredModalityDecision, ShellSessionPhase, ShellSessionState, ShellSessionType, ShellCallChain, ActionPermissionContext, ActionPermissionResult, PermissionDecision, PermissionRuleSource, SessionContext, Message, DuctTokenPayload, DeeplinkTokenPayload, DuctAdapter, ReceiverOptions, ShellOptions, } from "./core/types.js";
18
+ export type { RouteManifest, RouteParam, QueryParam, UIStateHint, ActionManifest, ActionParam, SensitivityLevel, ApprovalPredicate, ApprovalCompareOp, ApprovalLogicalOp, ActionLimitPolicy, ActionRuntimeFields, ActionDef, BuiltActionDef, ActionValidationResult, AuthSchema, AuthStrategy, DeeplinkDefinition, StateField, ReviewResult, ReviewIssue, ReviewIssueSeverity, DuctConfig, ProductConfig, AgentPermissions, AgentPermissionLevel, WidgetConfig, ShellManifest, ModalityDecision, ScoredModalityDecision, ShellSessionPhase, ShellSessionState, ShellSessionType, ShellCallChain, ActionPermissionContext, ActionPermissionResult, PermissionDecision, PermissionRuleSource, SessionContext, Message, DuctTokenPayload, DeeplinkTokenPayload, DuctAdapter, ReceiverOptions, ShellOptions, } from "./core/types.js";
package/dist/index.js CHANGED
@@ -6,9 +6,11 @@
6
6
  // runtimes where React is not installed (e.g. plain Express).
7
7
  // ============================================================
8
8
  // Core config
9
- export { defineDuctConfig, DuctConfigSchema } from "./core/config.js";
9
+ export { defineDuctConfig, DuctConfigSchema, crossValidateDuctConfig } from "./core/config.js";
10
10
  // Token utilities
11
- export { generateDuctToken, verifyDuctToken, generateDeeplinkToken, verifyDeeplinkToken, } from "./core/token.js";
11
+ export { generateDuctToken, verifyDuctToken, generateDeeplinkToken, verifyDeeplinkToken, createDevReplayStore, InMemoryReplayStore, RedisReplayStore, } from "./core/token.js";
12
+ // Outcome receipt verification (crypto layer)
13
+ export { verifyReceipt, computeReceiptId } from "./core/receipt.js";
12
14
  // Action factory
13
15
  export { buildAction, checkActionPermission, buildActionSearchIndex, shouldDeferActions, } from "./core/action.js";
14
16
  // Shell status (server-side)
package/dist/server.d.ts CHANGED
@@ -1,7 +1,9 @@
1
- export { defineDuctConfig, DuctConfigSchema } from "./core/config.js";
1
+ export { defineDuctConfig, DuctConfigSchema, crossValidateDuctConfig } from "./core/config.js";
2
2
  export type { ValidatedDuctConfig } from "./core/config.js";
3
- export { generateDuctToken, verifyDuctToken, generateDeeplinkToken, verifyDeeplinkToken, } from "./core/token.js";
4
- export type { GenerateTokenOptions, GenerateTokenResult, VerifyTokenOptions, VerifyTokenResult, GenerateDeeplinkTokenOptions, GenerateDeeplinkTokenResult, VerifyDeeplinkTokenOptions, VerifyDeeplinkResult, } from "./core/token.js";
3
+ export { generateDuctToken, verifyDuctToken, generateDeeplinkToken, verifyDeeplinkToken, createDevReplayStore, InMemoryReplayStore, RedisReplayStore, } from "./core/token.js";
4
+ export type { GenerateTokenOptions, GenerateTokenResult, VerifyTokenOptions, VerifyTokenResult, GenerateDeeplinkTokenOptions, GenerateDeeplinkTokenResult, VerifyDeeplinkTokenOptions, VerifyDeeplinkResult, DeeplinkReplayStore, RedisSetClient, } from "./core/token.js";
5
+ export { verifyReceipt, computeReceiptId } from "./core/receipt.js";
6
+ export type { SignedDuctReceipt, DuctReceiptBody, ReceiptClaimType, ReceiptJwks, VerifyReceiptOptions, VerifyReceiptResult, ReceiptRejectionReason, } from "./core/receipt.js";
5
7
  export { createIntrospectHandler, createIntrospectPageHandler, createIntrospectExpressHandler, } from "./core/introspect.js";
6
8
  export type { IntrospectEntity, IntrospectResult, IntrospectContext, IntrospectResolver, IntrospectHandlerOptions, } from "./core/introspect.js";
7
9
  export { createPageResolveHandler, createPageResolvePageHandler, createPageResolveExpressHandler, } from "./core/page-resolve.js";
@@ -16,4 +18,4 @@ export { buildDeeplinkRedirectUrl, buildDeeplinkSession, validateDeeplinkClaims,
16
18
  export type { DeeplinkReceiverResult } from "./core/receiver.js";
17
19
  export { SHELL_PRESET_DIMENSIONS, DEFAULT_SHELL_PRESET, SHELL_PANEL_VIEWPORT_INSETS, resolveShellDimensions, fitShellPanelDimensions, } from "./core/types.js";
18
20
  export type { ShellPreset, ShellPanelViewportInsets } from "./core/types.js";
19
- export type { DuctConfig, DuctTokenPayload, DeeplinkTokenPayload, ActionManifest, ActionParam, RouteManifest, RouteParam, QueryParam, AuthSchema, AuthStrategy, DeeplinkDefinition, StateField, ShellManifest, ProductConfig, AgentPermissions, AgentPermissionLevel, WidgetConfig, SensitivityLevel, SessionContext, DuctAdapter, ReceiverOptions, } from "./core/types.js";
21
+ export type { DuctConfig, DuctTokenPayload, DeeplinkTokenPayload, ActionManifest, ActionParam, RouteManifest, RouteParam, QueryParam, AuthSchema, AuthStrategy, DeeplinkDefinition, StateField, ShellManifest, ProductConfig, AgentPermissions, AgentPermissionLevel, WidgetConfig, SensitivityLevel, ApprovalPredicate, ApprovalCompareOp, ApprovalLogicalOp, ActionLimitPolicy, SessionContext, DuctAdapter, ReceiverOptions, } from "./core/types.js";
package/dist/server.js CHANGED
@@ -10,9 +10,11 @@
10
10
  // is not installed.
11
11
  // ============================================================
12
12
  // Config
13
- export { defineDuctConfig, DuctConfigSchema } from "./core/config.js";
13
+ export { defineDuctConfig, DuctConfigSchema, crossValidateDuctConfig } from "./core/config.js";
14
14
  // Token utilities — mint delegated JWTs, verify them, handle deeplinks
15
- export { generateDuctToken, verifyDuctToken, generateDeeplinkToken, verifyDeeplinkToken, } from "./core/token.js";
15
+ export { generateDuctToken, verifyDuctToken, generateDeeplinkToken, verifyDeeplinkToken, createDevReplayStore, InMemoryReplayStore, RedisReplayStore, } from "./core/token.js";
16
+ // Outcome receipt verification (crypto layer)
17
+ export { verifyReceipt, computeReceiptId } from "./core/receipt.js";
16
18
  // Introspect handler factories
17
19
  export { createIntrospectHandler, createIntrospectPageHandler, createIntrospectExpressHandler, } from "./core/introspect.js";
18
20
  // Page-resolve handler factories (agent deeplink resolution)