@seed-hypermedia/client 0.0.109 → 0.0.111

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 (48) hide show
  1. package/dist/auto-link.mjs +4 -3
  2. package/dist/blocks-to-markdown.mjs +3 -2
  3. package/dist/capability.d.ts +9 -3
  4. package/dist/capability.mjs +3 -2
  5. package/dist/{chunk-BHESE4LH.mjs → chunk-3IDYHD26.mjs} +3 -3
  6. package/dist/{chunk-VN7F33SS.mjs → chunk-65UV5O57.mjs} +38 -0
  7. package/dist/{chunk-7IISPGNN.mjs → chunk-75QI2URL.mjs} +32 -13
  8. package/dist/chunk-AHQWDCHV.mjs +56 -0
  9. package/dist/{chunk-52RP7HHW.mjs → chunk-AUKAVTTK.mjs} +1 -1
  10. package/dist/{chunk-HLTKEZ7W.mjs → chunk-D2NNAW4D.mjs} +1 -1
  11. package/dist/{chunk-GWV7ETLU.mjs → chunk-G4B7P2DG.mjs} +2 -2
  12. package/dist/{chunk-IAS2V6ON.mjs → chunk-H4OOJ6F7.mjs} +1 -1
  13. package/dist/{chunk-KOQHARP5.mjs → chunk-HH7AOMKN.mjs} +1 -1
  14. package/dist/{chunk-SQFGEPOQ.mjs → chunk-IQ5HNMUK.mjs} +10 -5
  15. package/dist/{chunk-Y5XKORRF.mjs → chunk-MLR4UDOJ.mjs} +3 -3
  16. package/dist/{chunk-KNA3PBET.mjs → chunk-MN2JRQM5.mjs} +1 -1
  17. package/dist/{chunk-2NM2JP5H.mjs → chunk-O62L5AUF.mjs} +3 -3
  18. package/dist/{chunk-Z3J6R5DN.mjs → chunk-QSSNEIPO.mjs} +1 -1
  19. package/dist/{chunk-ICFYYWGD.mjs → chunk-QU42JTHS.mjs} +1 -1
  20. package/dist/{chunk-5MVCUZBD.mjs → chunk-SFDJ4SQ4.mjs} +6 -1
  21. package/dist/{chunk-34OBOF5O.mjs → chunk-U5MHHDOD.mjs} +1 -1
  22. package/dist/{chunk-G7CFO5W3.mjs → chunk-YMOCTVFW.mjs} +1 -1
  23. package/dist/client.d.ts +1 -1
  24. package/dist/client.mjs +3 -2
  25. package/dist/comment.mjs +3 -2
  26. package/dist/document-state.mjs +3 -2
  27. package/dist/editorblock-to-hmblock.mjs +3 -2
  28. package/dist/file-to-ipfs.d.ts +19 -0
  29. package/dist/file-to-ipfs.mjs +5 -1
  30. package/dist/hm-resolver.mjs +3 -2
  31. package/dist/hm-types.d.ts +8326 -77112
  32. package/dist/hm-types.mjs +2 -1
  33. package/dist/hmblock-to-editorblock.mjs +3 -2
  34. package/dist/index.d.ts +2 -2
  35. package/dist/index.mjs +19 -14
  36. package/dist/page-input.d.ts +13 -0
  37. package/dist/page-input.mjs +15 -0
  38. package/dist/pdf-to-blocks.mjs +4 -3
  39. package/dist/resource-read.mjs +5 -4
  40. package/dist/schema-engine.mjs +2 -2
  41. package/dist/schema-registry.generated.mjs +1 -1
  42. package/dist/schema-resolve.mjs +5 -4
  43. package/dist/schema-subtypes.mjs +5 -4
  44. package/dist/schema-types.generated.d.ts +24 -0
  45. package/dist/signed-blob.mjs +2 -2
  46. package/dist/tei-to-blocks.mjs +3 -2
  47. package/dist/unicode.mjs +2 -1
  48. package/package.json +1 -1
@@ -4,13 +4,14 @@ import {
4
4
  documentContainsLinkToChild,
5
5
  documentHasSelfQuery,
6
6
  shouldAutoLinkParent
7
- } from "./chunk-GWV7ETLU.mjs";
7
+ } from "./chunk-G4B7P2DG.mjs";
8
8
  import "./chunk-O5MHN2EO.mjs";
9
9
  import "./chunk-PJ2RFT5A.mjs";
10
- import "./chunk-ICFYYWGD.mjs";
10
+ import "./chunk-QU42JTHS.mjs";
11
11
  import "./chunk-LVAHHQIK.mjs";
12
12
  import "./chunk-DR3HJ6BV.mjs";
13
- import "./chunk-7IISPGNN.mjs";
13
+ import "./chunk-75QI2URL.mjs";
14
+ import "./chunk-AHQWDCHV.mjs";
14
15
  import "./chunk-7P6ASYW6.mjs";
15
16
  export {
16
17
  autoLinkChildToParent,
@@ -7,8 +7,9 @@ import {
7
7
  emitFrontmatter,
8
8
  parseDraftFilename,
9
9
  slugify
10
- } from "./chunk-HLTKEZ7W.mjs";
11
- import "./chunk-7IISPGNN.mjs";
10
+ } from "./chunk-D2NNAW4D.mjs";
11
+ import "./chunk-75QI2URL.mjs";
12
+ import "./chunk-AHQWDCHV.mjs";
12
13
  import "./chunk-7P6ASYW6.mjs";
13
14
  export {
14
15
  blocksToMarkdown,
@@ -1,9 +1,8 @@
1
1
  /**
2
2
  * Capability SDK — create and resolve capabilities (delegate access to other accounts).
3
3
  */
4
- import type { HMPublishBlobsInput } from './hm-types';
4
+ import type { HMPublishBlobsInput, HMRequest } from './hm-types';
5
5
  import type { AnySigner } from './signer';
6
- import type { SeedClient } from './client';
7
6
  /** Role values for capability blobs. */
8
7
  export type CapabilityRole = 'WRITER' | 'AGENT';
9
8
  export type CreateCapabilityInput = {
@@ -32,5 +31,12 @@ export declare function createCapability(input: CreateCapabilityInput, signer: A
32
31
  * @param path - The document path being written to (e.g. "/podcasts"). When provided,
33
32
  * ListCapabilities is queried with this path so the backend returns capabilities
34
33
  * scoped to that path (or any ancestor path that covers it).
34
+ * @param capability - When supplied, resolve only this existing capability.
35
35
  */
36
- export declare function resolveCapability(client: SeedClient, targetAccount: string, signerAccount: string, path?: string): Promise<string | undefined>;
36
+ export declare function resolveCapability(client: {
37
+ request: (key: 'ListCapabilities', input: Extract<HMRequest, {
38
+ key: 'ListCapabilities';
39
+ }>['input']) => Promise<Extract<HMRequest, {
40
+ key: 'ListCapabilities';
41
+ }>['output']>;
42
+ }, targetAccount: string, signerAccount: string, path?: string, capability?: string): Promise<string | undefined>;
@@ -1,11 +1,12 @@
1
1
  import {
2
2
  createCapability,
3
3
  resolveCapability
4
- } from "./chunk-SQFGEPOQ.mjs";
4
+ } from "./chunk-IQ5HNMUK.mjs";
5
5
  import "./chunk-LVAHHQIK.mjs";
6
6
  import "./chunk-NBCHK76Q.mjs";
7
7
  import "./chunk-DR3HJ6BV.mjs";
8
- import "./chunk-7IISPGNN.mjs";
8
+ import "./chunk-75QI2URL.mjs";
9
+ import "./chunk-AHQWDCHV.mjs";
9
10
  import "./chunk-3TPCJCVO.mjs";
10
11
  import "./chunk-7P6ASYW6.mjs";
11
12
  export {
@@ -10,17 +10,17 @@ import {
10
10
  schemaForCid,
11
11
  structFields,
12
12
  validate
13
- } from "./chunk-52RP7HHW.mjs";
13
+ } from "./chunk-AUKAVTTK.mjs";
14
14
  import {
15
15
  HM_SCHEMAS
16
- } from "./chunk-Y5XKORRF.mjs";
16
+ } from "./chunk-MLR4UDOJ.mjs";
17
17
  import {
18
18
  parseCidString
19
19
  } from "./chunk-VWSAFDOL.mjs";
20
20
  import {
21
21
  packHmId,
22
22
  unpackHmId
23
- } from "./chunk-7IISPGNN.mjs";
23
+ } from "./chunk-75QI2URL.mjs";
24
24
 
25
25
  // src/schema-resolve.ts
26
26
  var DAG_CBOR_CODE = 113;
@@ -38,6 +38,42 @@ async function filesToIpfsBlobs(binaries) {
38
38
  }
39
39
  return { resultCIDs, blobs };
40
40
  }
41
+ async function directoryToIpfsBlobs(files) {
42
+ if (files.length === 0) throw new Error("A folder needs at least one file");
43
+ const seen = /* @__PURE__ */ new Set();
44
+ const entries = files.map((file) => {
45
+ const path = normalizeDirectoryFilePath(file.path);
46
+ if (seen.has(path)) throw new Error(`Duplicate file in folder: ${path}`);
47
+ seen.add(path);
48
+ return { path, content: file.content };
49
+ });
50
+ const blockstore = new MemoryBlockstore();
51
+ let rootCid;
52
+ const blobs = [];
53
+ const published = /* @__PURE__ */ new Set();
54
+ for await (const entry of unixFSImporter(entries, blockstore, { wrapWithDirectory: true })) {
55
+ if (entry.path === "" || entry.path === void 0) rootCid = entry.cid.toString();
56
+ blobs.push({ cid: entry.cid.toString(), data: await blockstore.get(entry.cid) });
57
+ published.add(entry.cid.multihash.digest.join(","));
58
+ }
59
+ if (!rootCid) throw new Error("Failed to build the folder root");
60
+ for await (const pair of blockstore.getAll()) {
61
+ const key = pair.cid.multihash.digest.join(",");
62
+ if (published.has(key)) continue;
63
+ published.add(key);
64
+ blobs.push({ cid: pair.cid.toString(), data: pair.block });
65
+ }
66
+ return { cid: rootCid, blobs };
67
+ }
68
+ function normalizeDirectoryFilePath(path) {
69
+ const segments = path.replace(/\\/g, "/").split("/").filter((segment) => segment !== "" && segment !== ".");
70
+ if (segments.length === 0) throw new Error("A folder file needs a name");
71
+ for (const segment of segments) {
72
+ if (segment === "..") throw new Error(`Invalid folder path: ${path}`);
73
+ if (/[\x00-\x1f]/.test(segment)) throw new Error(`Invalid folder path: ${path}`);
74
+ }
75
+ return segments.join("/");
76
+ }
41
77
  var FILE_PROTOCOL = "file://";
42
78
  function getBlockLink(block) {
43
79
  const b = block;
@@ -103,6 +139,8 @@ function hasFileLinks(nodes) {
103
139
  export {
104
140
  fileToIpfsBlobs,
105
141
  filesToIpfsBlobs,
142
+ directoryToIpfsBlobs,
143
+ normalizeDirectoryFilePath,
106
144
  resolveFileLinksInBlocks,
107
145
  hasFileLinks
108
146
  };
@@ -1,5 +1,10 @@
1
+ import {
2
+ pageParamsFromUrl,
3
+ pageParamsQuery
4
+ } from "./chunk-AHQWDCHV.mjs";
5
+
1
6
  // src/hm-types.ts
2
- import * as z from "zod/v3";
7
+ import * as z from "zod";
3
8
  var BlockRangeSchema = z.object({
4
9
  // a block range should either have start+end
5
10
  start: z.number().optional(),
@@ -17,6 +22,8 @@ var unpackedHmIdSchema = z.object({
17
22
  hostname: z.string().nullable(),
18
23
  scheme: z.string().nullable(),
19
24
  latest: z.boolean().nullable().optional(),
25
+ /** JSON-encoded custom HTML page input, excluded from canonical resource identity. */
26
+ pageParams: z.record(z.string(), z.string()).optional(),
20
27
  // deprecated:
21
28
  targetDocUid: z.string().nullable().optional(),
22
29
  targetDocPath: z.array(z.string()).nullable().optional()
@@ -225,7 +232,7 @@ var HMBlockFileSchema = z.object({
225
232
  size: z.number().optional().transform((value) => value == null ? null : toNumber(value)),
226
233
  // number of bytes, as a string
227
234
  name: z.string().optional()
228
- }).optional().default({}),
235
+ }).prefault({}),
229
236
  link: z.string()
230
237
  }).strict();
231
238
  var HMBlockButtonAlignmentSchema = z.union([z.literal("flex-start"), z.literal("center"), z.literal("flex-end")]).optional();
@@ -300,7 +307,13 @@ var HMDocumentMetadataSchema = z.object({
300
307
  * because removal leaves a null attribute behind rather than dropping the key; `parseSpaceAgentIds`
301
308
  * in @shm/ui/agents/space-agents is the reader for this field.
302
309
  */
303
- spaceAgents: z.record(z.unknown()).optional(),
310
+ spaceAgents: z.record(z.string(), z.unknown()).optional(),
311
+ /** Resource type; custom HTML pages use hm://hyper.media/page. */
312
+ type: z.string().optional(),
313
+ /** UnixFS folder whose index.html runs as an isolated custom HTML page. */
314
+ html: z.string().optional(),
315
+ /** Published HM struct schema describing the page's URL input. */
316
+ inputSchema: z.string().optional(),
304
317
  layout: z.union([z.literal("Seed/Experimental/Newspaper"), z.literal("")]).optional(),
305
318
  displayPublishTime: z.string().optional(),
306
319
  displayAuthor: z.string().optional(),
@@ -621,13 +634,13 @@ var HMBlockUnknownSchema = z.object({
621
634
  type: z.string(),
622
635
  id: z.string(),
623
636
  revision: z.string().optional(),
624
- attributes: z.record(z.any()).optional(),
637
+ attributes: z.record(z.string(), z.any()).optional(),
625
638
  annotations: z.array(z.any()).optional(),
626
639
  text: z.string().optional(),
627
640
  link: z.string().optional()
628
641
  }).passthrough();
629
642
  var HMBlockSchema = z.union([HMBlockKnownSchema, HMBlockUnknownSchema]);
630
- var knownBlockTypes = new Set(HMBlockKnownSchema.optionsMap.keys());
643
+ var knownBlockTypes = new Set(HMBlockKnownSchema.options.map((schema) => schema.shape.type.value));
631
644
  function isKnownBlockType(btype) {
632
645
  return knownBlockTypes.has(btype);
633
646
  }
@@ -985,7 +998,7 @@ var HMRawDocumentInfoSchema = z.object({
985
998
  account: z.string(),
986
999
  /** The document path, `/`-prefixed; empty for the space's home document. */
987
1000
  path: z.string().optional(),
988
- metadata: z.record(z.unknown()).optional(),
1001
+ metadata: z.record(z.string(), z.unknown()).optional(),
989
1002
  authors: z.array(z.string()).optional(),
990
1003
  createTime: z.string().optional(),
991
1004
  updateTime: z.string().optional(),
@@ -1178,7 +1191,7 @@ var HMListAccountsRequestSchema = z.object({
1178
1191
  output: HMListAccountsOutputSchema
1179
1192
  });
1180
1193
  var HMGetCIDOutputSchema = z.object({
1181
- value: z.any()
1194
+ value: z.any().optional()
1182
1195
  });
1183
1196
  var HMGetCIDInputSchema = z.object({
1184
1197
  cid: z.string()
@@ -1395,11 +1408,12 @@ var ProtoBlockSchema = z.object({
1395
1408
  annotations: z.array(ProtoAnnotationSchema).optional(),
1396
1409
  revision: z.string().optional()
1397
1410
  });
1411
+ var ProtoEmptySchema = z.object({});
1398
1412
  var ProtoSetAttributeValueSchema = z.union([
1399
1413
  z.object({ case: z.literal("stringValue"), value: z.string() }),
1400
1414
  z.object({ case: z.literal("intValue"), value: z.union([z.bigint(), z.coerce.bigint()]) }),
1401
1415
  z.object({ case: z.literal("boolValue"), value: z.boolean() }),
1402
- z.object({ case: z.literal("nullValue"), value: z.object({}) }),
1416
+ z.object({ case: z.literal("nullValue"), value: ProtoEmptySchema }),
1403
1417
  z.object({ case: z.undefined(), value: z.undefined().optional() })
1404
1418
  ]);
1405
1419
  var ProtoDocumentChangeSchema = z.object({
@@ -1572,12 +1586,13 @@ function packBaseId(uid, path) {
1572
1586
  return `${HYPERMEDIA_SCHEME}://${uid}${restPath}`;
1573
1587
  }
1574
1588
  function packHmId(hmId) {
1575
- const { path, version, latest, blockRef, blockRange, uid } = hmId;
1589
+ const { path, version, latest, blockRef, blockRange, uid, pageParams } = hmId;
1576
1590
  if (!uid) throw new Error("uid is required");
1577
1591
  let responseUrl = packBaseId(uid, path);
1578
1592
  responseUrl += getHMQueryString({
1579
1593
  version,
1580
- latest
1594
+ latest,
1595
+ pageParams
1581
1596
  });
1582
1597
  if (blockRef) {
1583
1598
  responseUrl += `#${blockRef}${serializeBlockRange(blockRange)}`;
@@ -1587,7 +1602,8 @@ function packHmId(hmId) {
1587
1602
  function getHMQueryString({
1588
1603
  version,
1589
1604
  latest,
1590
- panel
1605
+ panel,
1606
+ pageParams
1591
1607
  }) {
1592
1608
  const query = {};
1593
1609
  if (version) {
@@ -1599,7 +1615,9 @@ function getHMQueryString({
1599
1615
  if (panel) {
1600
1616
  query.panel = panel;
1601
1617
  }
1602
- return serializeHmQueryString(query);
1618
+ const base = serializeHmQueryString(query);
1619
+ const input = pageParamsQuery(pageParams);
1620
+ return base + (input ? (base ? "&" : "?") + input : "");
1603
1621
  }
1604
1622
  function serializeBlockRange(range) {
1605
1623
  let res = "";
@@ -1701,7 +1719,8 @@ function unpackHmId(hypermediaId) {
1701
1719
  blockRange,
1702
1720
  hostname: hostname || null,
1703
1721
  latest,
1704
- scheme: parsed.scheme
1722
+ scheme: parsed.scheme,
1723
+ ...pageParamsFromUrl(hypermediaId) ? { pageParams: pageParamsFromUrl(hypermediaId) } : {}
1705
1724
  };
1706
1725
  }
1707
1726
  function codePointLength(entry) {
@@ -0,0 +1,56 @@
1
+ // src/page-input.ts
2
+ var PAGE_INPUT_PREFIX = "p.";
3
+ function pageParamsFromUrl(url) {
4
+ const queryStart = url.indexOf("?");
5
+ if (queryStart === -1 || url.indexOf("#") !== -1 && url.indexOf("#") < queryStart) return void 0;
6
+ const params = new URLSearchParams(url.slice(queryStart + 1).split("#")[0]);
7
+ const entries = Array.from(params.entries()).filter(([key]) => key.startsWith(PAGE_INPUT_PREFIX));
8
+ return entries.length ? Object.fromEntries(entries.map(([key, value]) => [key.slice(PAGE_INPUT_PREFIX.length), value])) : void 0;
9
+ }
10
+ function pageParamsQuery(params) {
11
+ return new URLSearchParams(
12
+ Object.entries(params || {}).map(([key, value]) => [PAGE_INPUT_PREFIX + key, value])
13
+ ).toString();
14
+ }
15
+ function decodePageInput(params = {}) {
16
+ const values = /* @__PURE__ */ Object.create(null);
17
+ const errors = [];
18
+ if (Object.keys(params).length > 64 || pageParamsQuery(params).length > 8192)
19
+ return { values, errors: ["Page input exceeds the URL size limit."] };
20
+ for (const [key, value] of Object.entries(params)) {
21
+ try {
22
+ values[key] = JSON.parse(value, (_key, item) => {
23
+ if (typeof item === "number" && (!Number.isFinite(item) || Number.isInteger(item) && !Number.isSafeInteger(item)))
24
+ throw new Error("Number cannot be represented exactly");
25
+ return item;
26
+ });
27
+ } catch {
28
+ errors.push(`${key}: expected a JSON value with finite numbers and safe integers in the URL.`);
29
+ }
30
+ }
31
+ return { values, errors };
32
+ }
33
+ function encodePageInput(values) {
34
+ if (!values || typeof values !== "object" || Array.isArray(values)) throw new Error("Page input must be an object");
35
+ const params = Object.fromEntries(
36
+ Object.entries(values).map(([key, value]) => {
37
+ const json = JSON.stringify(value, (_key, item) => {
38
+ if (item === void 0 || typeof item === "function" || typeof item === "symbol" || typeof item === "number" && (!Number.isFinite(item) || Number.isInteger(item) && !Number.isSafeInteger(item)))
39
+ throw new Error("Page input must contain JSON values");
40
+ return item;
41
+ });
42
+ return [key, json];
43
+ })
44
+ );
45
+ const decoded = decodePageInput(params);
46
+ if (decoded.errors.length) throw new Error(decoded.errors.join("; "));
47
+ return params;
48
+ }
49
+
50
+ export {
51
+ PAGE_INPUT_PREFIX,
52
+ pageParamsFromUrl,
53
+ pageParamsQuery,
54
+ decodePageInput,
55
+ encodePageInput
56
+ };
@@ -2,7 +2,7 @@ import {
2
2
  HM_SCHEMAS,
3
3
  HM_SCHEMA_MANIFEST,
4
4
  HM_SCHEMA_PAGES
5
- } from "./chunk-Y5XKORRF.mjs";
5
+ } from "./chunk-MLR4UDOJ.mjs";
6
6
 
7
7
  // src/schema-engine.ts
8
8
  var LIBRARY_AUTHORITY = "hyper.media";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  normalizeQuerySort,
3
3
  unpackHmId
4
- } from "./chunk-7IISPGNN.mjs";
4
+ } from "./chunk-75QI2URL.mjs";
5
5
 
6
6
  // src/blocks-to-markdown.ts
7
7
  import { stringify as stringifyYaml } from "yaml";
@@ -7,12 +7,12 @@ import {
7
7
  } from "./chunk-PJ2RFT5A.mjs";
8
8
  import {
9
9
  resolveDocumentState
10
- } from "./chunk-ICFYYWGD.mjs";
10
+ } from "./chunk-QU42JTHS.mjs";
11
11
  import {
12
12
  entityQueryPathToHmIdPath,
13
13
  packHmId,
14
14
  unpackHmId
15
- } from "./chunk-7IISPGNN.mjs";
15
+ } from "./chunk-75QI2URL.mjs";
16
16
 
17
17
  // src/auto-link.ts
18
18
  import { CID } from "multiformats/cid";
@@ -15,7 +15,7 @@ import {
15
15
  HMActionSchema,
16
16
  HMRequestSchema,
17
17
  packHmId
18
- } from "./chunk-7IISPGNN.mjs";
18
+ } from "./chunk-75QI2URL.mjs";
19
19
 
20
20
  // src/client.ts
21
21
  import { encode as cborEncode } from "@ipld/dag-cbor";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  codePointLength
3
- } from "./chunk-7IISPGNN.mjs";
3
+ } from "./chunk-75QI2URL.mjs";
4
4
 
5
5
  // src/tei-to-blocks.ts
6
6
  function generateBlockId() {
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  entityQueryPathToHmIdPath,
9
9
  packBaseId
10
- } from "./chunk-7IISPGNN.mjs";
10
+ } from "./chunk-75QI2URL.mjs";
11
11
 
12
12
  // src/capability.ts
13
13
  import { base58btc } from "multiformats/bases/base58";
@@ -21,7 +21,7 @@ async function createCapability2(input, signer) {
21
21
  );
22
22
  return toPublishInput(encoded.data);
23
23
  }
24
- async function resolveCapability(client, targetAccount, signerAccount, path) {
24
+ async function resolveCapability(client, targetAccount, signerAccount, path, capability) {
25
25
  if (targetAccount === signerAccount) return void 0;
26
26
  const pathSegments = path ? entityQueryPathToHmIdPath(path) : null;
27
27
  const targetId = {
@@ -36,9 +36,14 @@ async function resolveCapability(client, targetAccount, signerAccount, path) {
36
36
  scheme: null
37
37
  };
38
38
  const caps = await client.request("ListCapabilities", { targetId });
39
- const match = caps.capabilities.find(
40
- (c) => c.delegate === signerAccount && (c.role === "WRITER" || c.role === "AGENT")
41
- );
39
+ const match = caps.capabilities.find((c) => {
40
+ if (capability && c.id !== capability) return false;
41
+ if (c.delegate !== signerAccount || c.role !== "WRITER" && c.role !== "AGENT") return false;
42
+ if (c.account && c.account !== targetAccount) return false;
43
+ const scope = c.path || "";
44
+ const target = path || "";
45
+ return target === scope || !c.noRecursive && (scope === "" || target.startsWith(scope + "/"));
46
+ });
42
47
  return match == null ? void 0 : match.id;
43
48
  }
44
49