@odla-ai/chapter 0.39.1 → 0.39.2

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.
@@ -117,16 +117,14 @@ interface ResolvedMemberContent {
117
117
  interface ChapterBuilderLibrary {
118
118
  /** Keep local admin authoring enabled. Defaults to true. */
119
119
  localAuthoring?: boolean;
120
- /** Signed sources this app accepts. Hub sources are Chapters; Chapter sources are Built Not Found. */
120
+ /** Existing Chapter-network peers this app accepts. Hub sources must be
121
+ * configured network targets; a Chapter source must be a configured reader. */
121
122
  sources?: readonly {
122
123
  sourceId: string;
123
- /** Vault key holding the dedicated Builder Library edge secret. */
124
- secretName?: string;
125
124
  }[];
126
125
  }
127
126
  interface ResolvedBuilderLibrarySource {
128
127
  sourceId: string;
129
- secretName: string;
130
128
  }
131
129
  /** Validated Builder Library settings carried on a resolved Chapter. */
132
130
  interface ResolvedBuilderLibrary {
@@ -1123,13 +1121,15 @@ interface BuilderLibraryReceipt {
1123
1121
 
1124
1122
  /** Inputs for one signed Builder Library peer delivery. */
1125
1123
  interface BuilderLibraryDeliveryOptions {
1124
+ /** Existing Chapter-network share secret for this parent/chapter edge. */
1126
1125
  secret: string;
1127
1126
  sender: string;
1128
1127
  targetUrl: string | URL;
1129
1128
  envelope: BuilderLibraryEnvelope;
1130
1129
  fetch?: typeof globalThis.fetch;
1131
1130
  }
1132
- /** Deliver one exact Builder Library revision over its dedicated signed edge. */
1131
+ /** Deliver one exact Builder Library revision over the existing signed Chapter
1132
+ * network edge. No Builder-specific credential is created. */
1133
1133
  declare function deliverBuilderLibrary(options: BuilderLibraryDeliveryOptions): Promise<BuilderLibraryReceipt>;
1134
1134
 
1135
1135
  /** Current wire version for parent-authored admission decisions. */
@@ -117,16 +117,14 @@ interface ResolvedMemberContent {
117
117
  interface ChapterBuilderLibrary {
118
118
  /** Keep local admin authoring enabled. Defaults to true. */
119
119
  localAuthoring?: boolean;
120
- /** Signed sources this app accepts. Hub sources are Chapters; Chapter sources are Built Not Found. */
120
+ /** Existing Chapter-network peers this app accepts. Hub sources must be
121
+ * configured network targets; a Chapter source must be a configured reader. */
121
122
  sources?: readonly {
122
123
  sourceId: string;
123
- /** Vault key holding the dedicated Builder Library edge secret. */
124
- secretName?: string;
125
124
  }[];
126
125
  }
127
126
  interface ResolvedBuilderLibrarySource {
128
127
  sourceId: string;
129
- secretName: string;
130
128
  }
131
129
  /** Validated Builder Library settings carried on a resolved Chapter. */
132
130
  interface ResolvedBuilderLibrary {
@@ -1123,13 +1121,15 @@ interface BuilderLibraryReceipt {
1123
1121
 
1124
1122
  /** Inputs for one signed Builder Library peer delivery. */
1125
1123
  interface BuilderLibraryDeliveryOptions {
1124
+ /** Existing Chapter-network share secret for this parent/chapter edge. */
1126
1125
  secret: string;
1127
1126
  sender: string;
1128
1127
  targetUrl: string | URL;
1129
1128
  envelope: BuilderLibraryEnvelope;
1130
1129
  fetch?: typeof globalThis.fetch;
1131
1130
  }
1132
- /** Deliver one exact Builder Library revision over its dedicated signed edge. */
1131
+ /** Deliver one exact Builder Library revision over the existing signed Chapter
1132
+ * network edge. No Builder-specific credential is created. */
1133
1133
  declare function deliverBuilderLibrary(options: BuilderLibraryDeliveryOptions): Promise<BuilderLibraryReceipt>;
1134
1134
 
1135
1135
  /** Current wire version for parent-authored admission decisions. */
@@ -6074,9 +6074,23 @@ async function saveLocalBuilderLibrary(db, document, environment, expectedRevisi
6074
6074
 
6075
6075
  // src/worker-routes-builder-library.ts
6076
6076
  var BODY_CAP2 = 1e6;
6077
- async function verifySource(req, db, sources) {
6077
+ async function verifySource(req, db, ctx) {
6078
+ const sources = ctx.chapter.builderLibrary?.sources ?? [];
6079
+ if (ctx.chapter.mode === "chapter") {
6080
+ const secret = await getVaultSecret(db, "network_share_secret");
6081
+ if (!secret) return null;
6082
+ const verified = await verifyFederatedRequest8(req, {
6083
+ secret,
6084
+ senders: sources.map((source2) => source2.sourceId)
6085
+ });
6086
+ if (!verified.ok) return null;
6087
+ const source = sources.find((candidate) => candidate.sourceId === verified.sender);
6088
+ return source ? { source, body: verified.body } : null;
6089
+ }
6078
6090
  for (const source of sources) {
6079
- const secret = await getVaultSecret(db, source.secretName);
6091
+ const target = ctx.chapter.network.targets.find((candidate) => candidate.id === source.sourceId);
6092
+ if (!target) continue;
6093
+ const secret = await getVaultSecret(db, target.secretName);
6080
6094
  if (!secret) continue;
6081
6095
  const verified = await verifyFederatedRequest8(req.clone(), { secret, senders: [source.sourceId] });
6082
6096
  if (verified.ok) return { source, body: verified.body };
@@ -6088,7 +6102,7 @@ var handleBuilderLibraryControl = async (req, url, env, ctx) => {
6088
6102
  const settings = ctx.chapter.builderLibrary;
6089
6103
  if (!settings) return json({ error: "not found" }, 404);
6090
6104
  const db = ctx.makeDb(env);
6091
- const verified = await verifySource(req, db, settings.sources);
6105
+ const verified = await verifySource(req, db, ctx);
6092
6106
  if (!verified) return json({ error: "unauthorized" }, 401);
6093
6107
  let input;
6094
6108
  try {