@seed-hypermedia/client 0.0.79 → 0.0.81

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 (40) hide show
  1. package/dist/auth.mjs +2 -2
  2. package/dist/auto-link.mjs +3 -3
  3. package/dist/blobs.d.ts +2 -1
  4. package/dist/blobs.mjs +3 -1
  5. package/dist/blocks-to-markdown.mjs +2 -2
  6. package/dist/capability.mjs +3 -3
  7. package/dist/{chunk-EZ5UFUMQ.mjs → chunk-2JSUDZLE.mjs} +1 -1
  8. package/dist/{chunk-AC3EMQZG.mjs → chunk-2OMSCQ56.mjs} +1 -1
  9. package/dist/{chunk-5HHKGULK.mjs → chunk-55OXHA27.mjs} +2 -2
  10. package/dist/{chunk-SHOAYNJY.mjs → chunk-7PB3EULG.mjs} +1 -1
  11. package/dist/{chunk-AOCNYES4.mjs → chunk-AIQJ6BI3.mjs} +1 -1
  12. package/dist/{chunk-ZFQ6SZ5C.mjs → chunk-BO2QSSIU.mjs} +2 -2
  13. package/dist/{chunk-M7ZYWWI3.mjs → chunk-C42YWLL2.mjs} +1 -1
  14. package/dist/{chunk-3UP4S7XZ.mjs → chunk-D2LTD2KZ.mjs} +1 -1
  15. package/dist/{chunk-LJI66S7C.mjs → chunk-IREIRKVP.mjs} +1 -1
  16. package/dist/{chunk-R5FOS4BW.mjs → chunk-LCKCG574.mjs} +1 -1
  17. package/dist/{chunk-CCVGF25A.mjs → chunk-MZENVC36.mjs} +1 -1
  18. package/dist/{chunk-4HJWSEWS.mjs → chunk-MZUGCZJ6.mjs} +12 -7
  19. package/dist/{chunk-IT5LLTMP.mjs → chunk-NBCHK76Q.mjs} +27 -0
  20. package/dist/{chunk-CVUWZ27W.mjs → chunk-RCVLNXG6.mjs} +1 -1
  21. package/dist/{chunk-473ELALL.mjs → chunk-WGOIXGRU.mjs} +3 -3
  22. package/dist/{chunk-UX7OUR3C.mjs → chunk-YH52VFVR.mjs} +1 -1
  23. package/dist/client.mjs +2 -2
  24. package/dist/comment.mjs +2 -2
  25. package/dist/document-state.mjs +2 -2
  26. package/dist/editorblock-to-hmblock.mjs +2 -2
  27. package/dist/hm-resolver.mjs +2 -2
  28. package/dist/hm-types.d.ts +289 -81
  29. package/dist/hm-types.mjs +1 -1
  30. package/dist/hmauth.mjs +2 -2
  31. package/dist/hmblock-to-editorblock.mjs +2 -2
  32. package/dist/index.mjs +14 -14
  33. package/dist/pdf-to-blocks.mjs +3 -3
  34. package/dist/resource-read.mjs +4 -4
  35. package/dist/tei-to-blocks.mjs +2 -2
  36. package/dist/unicode.mjs +1 -1
  37. package/dist/vault-local.mjs +2 -2
  38. package/dist/vault-merge.mjs +2 -2
  39. package/dist/vault.mjs +2 -2
  40. package/package.json +1 -1
package/dist/auth.mjs CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  PARAM_TS,
12
12
  validateClientId,
13
13
  validateRedirectUri
14
- } from "./chunk-SHOAYNJY.mjs";
14
+ } from "./chunk-7PB3EULG.mjs";
15
15
  import {
16
16
  decode,
17
17
  encode
@@ -23,7 +23,7 @@ import {
23
23
  principalFromString,
24
24
  principalToString,
25
25
  verify
26
- } from "./chunk-IT5LLTMP.mjs";
26
+ } from "./chunk-NBCHK76Q.mjs";
27
27
  import "./chunk-DR3HJ6BV.mjs";
28
28
  import {
29
29
  decode as decode2
@@ -4,13 +4,13 @@ import {
4
4
  documentContainsLinkToChild,
5
5
  documentHasSelfQuery,
6
6
  shouldAutoLinkParent
7
- } from "./chunk-5HHKGULK.mjs";
7
+ } from "./chunk-55OXHA27.mjs";
8
8
  import "./chunk-JT57MV7Y.mjs";
9
9
  import "./chunk-PJ2RFT5A.mjs";
10
- import "./chunk-M7ZYWWI3.mjs";
10
+ import "./chunk-C42YWLL2.mjs";
11
11
  import "./chunk-LVAHHQIK.mjs";
12
12
  import "./chunk-DR3HJ6BV.mjs";
13
- import "./chunk-4HJWSEWS.mjs";
13
+ import "./chunk-MZUGCZJ6.mjs";
14
14
  import "./chunk-7P6ASYW6.mjs";
15
15
  export {
16
16
  autoLinkChildToParent,
package/dist/blobs.d.ts CHANGED
@@ -60,9 +60,10 @@ export declare class WebCryptoKeyPair implements Signer {
60
60
  }
61
61
  /** Generate a random Ed25519 key pair with an unexportable private key. */
62
62
  export declare function generateWebCryptoKeyPair(): Promise<WebCryptoKeyPair>;
63
+ export declare const nativeCryptoReady: Promise<void>;
63
64
  /**
64
65
  * Verify the signature of a blob against its embedded signer Principal.
65
- * Uses @noble/curves/ed25519 directly — works with any blob regardless of how it was signed.
66
+ * Uses native Ed25519 when available (server), @noble in the browser.
66
67
  */
67
68
  export declare function verify(blob: Blob): boolean;
68
69
  /** Create a Principal from a raw Ed25519 public key (32 bytes). */
package/dist/blobs.mjs CHANGED
@@ -14,6 +14,7 @@ import {
14
14
  generateNobleKeyPair,
15
15
  generateWebCryptoKeyPair,
16
16
  keyPairFromPrivateKey,
17
+ nativeCryptoReady,
17
18
  nobleKeyPairFromSeed,
18
19
  principalEqual,
19
20
  principalFromEd25519,
@@ -21,7 +22,7 @@ import {
21
22
  principalToString,
22
23
  sign,
23
24
  verify
24
- } from "./chunk-IT5LLTMP.mjs";
25
+ } from "./chunk-NBCHK76Q.mjs";
25
26
  import "./chunk-DR3HJ6BV.mjs";
26
27
  import "./chunk-3TPCJCVO.mjs";
27
28
  import "./chunk-7P6ASYW6.mjs";
@@ -41,6 +42,7 @@ export {
41
42
  generateNobleKeyPair,
42
43
  generateWebCryptoKeyPair,
43
44
  keyPairFromPrivateKey,
45
+ nativeCryptoReady,
44
46
  nobleKeyPairFromSeed,
45
47
  principalEqual,
46
48
  principalFromEd25519,
@@ -7,8 +7,8 @@ import {
7
7
  emitFrontmatter,
8
8
  parseDraftFilename,
9
9
  slugify
10
- } from "./chunk-UX7OUR3C.mjs";
11
- import "./chunk-4HJWSEWS.mjs";
10
+ } from "./chunk-YH52VFVR.mjs";
11
+ import "./chunk-MZUGCZJ6.mjs";
12
12
  import "./chunk-7P6ASYW6.mjs";
13
13
  export {
14
14
  blocksToMarkdown,
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  createCapability,
3
3
  resolveCapability
4
- } from "./chunk-ZFQ6SZ5C.mjs";
4
+ } from "./chunk-BO2QSSIU.mjs";
5
5
  import "./chunk-LVAHHQIK.mjs";
6
- import "./chunk-IT5LLTMP.mjs";
6
+ import "./chunk-NBCHK76Q.mjs";
7
7
  import "./chunk-DR3HJ6BV.mjs";
8
- import "./chunk-4HJWSEWS.mjs";
8
+ import "./chunk-MZUGCZJ6.mjs";
9
9
  import "./chunk-3TPCJCVO.mjs";
10
10
  import "./chunk-7P6ASYW6.mjs";
11
11
  export {
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  principalFromEd25519,
6
6
  principalToString
7
- } from "./chunk-IT5LLTMP.mjs";
7
+ } from "./chunk-NBCHK76Q.mjs";
8
8
 
9
9
  // src/vault.ts
10
10
  import * as dagCBOR from "@ipld/dag-cbor";
@@ -6,7 +6,7 @@ import {
6
6
  HMBlockSchema,
7
7
  codePointLength,
8
8
  toNumber
9
- } from "./chunk-4HJWSEWS.mjs";
9
+ } from "./chunk-MZUGCZJ6.mjs";
10
10
 
11
11
  // src/editorblock-to-hmblock.ts
12
12
  function toHMBlockType(editorBlockType) {
@@ -7,12 +7,12 @@ import {
7
7
  } from "./chunk-PJ2RFT5A.mjs";
8
8
  import {
9
9
  resolveDocumentState
10
- } from "./chunk-M7ZYWWI3.mjs";
10
+ } from "./chunk-C42YWLL2.mjs";
11
11
  import {
12
12
  entityQueryPathToHmIdPath,
13
13
  packHmId,
14
14
  unpackHmId
15
- } from "./chunk-4HJWSEWS.mjs";
15
+ } from "./chunk-MZUGCZJ6.mjs";
16
16
 
17
17
  // src/auto-link.ts
18
18
  import { CID } from "multiformats/cid";
@@ -8,7 +8,7 @@ import {
8
8
  principalFromEd25519,
9
9
  principalFromString,
10
10
  principalToString
11
- } from "./chunk-IT5LLTMP.mjs";
11
+ } from "./chunk-NBCHK76Q.mjs";
12
12
  import {
13
13
  encode as encode2
14
14
  } from "./chunk-3TPCJCVO.mjs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isSurrogate
3
- } from "./chunk-4HJWSEWS.mjs";
3
+ } from "./chunk-MZUGCZJ6.mjs";
4
4
 
5
5
  // src/hmblock-to-editorblock.ts
6
6
  function toEditorBlockType(hmBlockType) {
@@ -3,11 +3,11 @@ import {
3
3
  } from "./chunk-LVAHHQIK.mjs";
4
4
  import {
5
5
  createCapability
6
- } from "./chunk-IT5LLTMP.mjs";
6
+ } from "./chunk-NBCHK76Q.mjs";
7
7
  import {
8
8
  entityQueryPathToHmIdPath,
9
9
  packBaseId
10
- } from "./chunk-4HJWSEWS.mjs";
10
+ } from "./chunk-MZUGCZJ6.mjs";
11
11
 
12
12
  // src/capability.ts
13
13
  import { base58btc } from "multiformats/bases/base58";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  packHmId,
3
3
  unpackHmId
4
- } from "./chunk-4HJWSEWS.mjs";
4
+ } from "./chunk-MZUGCZJ6.mjs";
5
5
 
6
6
  // src/document-state.ts
7
7
  async function resolveDocumentState(client, targetId) {
@@ -2,7 +2,7 @@ import {
2
2
  entityQueryPathToHmIdPath,
3
3
  parseFragment,
4
4
  unpackHmId
5
- } from "./chunk-4HJWSEWS.mjs";
5
+ } from "./chunk-MZUGCZJ6.mjs";
6
6
 
7
7
  // src/hm-resolver.ts
8
8
  async function resolveHypermediaUrl(url, opts) {
@@ -9,7 +9,7 @@ import {
9
9
  import {
10
10
  hmIdPathToEntityQueryPath,
11
11
  packHmId
12
- } from "./chunk-4HJWSEWS.mjs";
12
+ } from "./chunk-MZUGCZJ6.mjs";
13
13
 
14
14
  // src/comment.ts
15
15
  import { decode as cborDecode, encode as cborEncode } from "@ipld/dag-cbor";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  teiToBlocks
3
- } from "./chunk-CCVGF25A.mjs";
3
+ } from "./chunk-MZENVC36.mjs";
4
4
  import {
5
5
  embeddedPdfToBlocks
6
6
  } from "./chunk-52P3E6H6.mjs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  codePointLength
3
- } from "./chunk-4HJWSEWS.mjs";
3
+ } from "./chunk-MZUGCZJ6.mjs";
4
4
 
5
5
  // src/tei-to-blocks.ts
6
6
  function generateBlockId() {
@@ -35,7 +35,8 @@ var HMQueryTableColumnSchema = z.object({
35
35
  width: z.number().positive().optional()
36
36
  });
37
37
  var HMQueryTableConfigSchema = z.object({
38
- columns: z.array(HMQueryTableColumnSchema)
38
+ columns: z.array(HMQueryTableColumnSchema),
39
+ sorting: z.array(z.object({ id: z.string(), desc: z.boolean() })).optional()
39
40
  });
40
41
  var baseAnnotationProperties = {
41
42
  starts: z.array(z.number()),
@@ -431,8 +432,8 @@ var HMDocumentInfoSchema = z.object({
431
432
  generationInfo: HMGenerationInfoSchema,
432
433
  redirectInfo: HMRedirectInfoSchema.optional(),
433
434
  metadata: HMDocumentMetadataSchema,
434
- /** Folder status derived by the published-document indexer. */
435
- isFolder: z.boolean().optional(),
435
+ /** Collection status derived by the published-document indexer. */
436
+ isCollection: z.boolean().optional(),
436
437
  // Indexer-derived first image block of the document's content (reading
437
438
  // order), used as a fallback cover on directory cards without fetching the
438
439
  // full document. Undefined = not derived (yet); empty string = derived, the
@@ -770,8 +771,8 @@ var HMDraftMetaBaseSchema = z.object({
770
771
  // (for .json drafts they come from the content file for backwards compat)
771
772
  deps: z.array(z.string().min(1)).default([]),
772
773
  navigation: z.array(HMNavigationItemSchema).optional(),
773
- /** Folder status derived from the locally persisted draft content. */
774
- isFolder: z.boolean().default(false)
774
+ /** Collection status derived from the locally persisted draft content. */
775
+ isCollection: z.boolean().optional()
775
776
  });
776
777
  var draftLocationRefinement = (data) => data.editUid || data.locationUid;
777
778
  var HMDraftMetaSchema = HMDraftMetaBaseSchema.refine(draftLocationRefinement, {
@@ -783,8 +784,12 @@ var HMListedDraftSchema = HMDraftMetaBaseSchema.extend({
783
784
  message: "Either editUid or locationUid must be provided"
784
785
  });
785
786
  var HMListedDraftReadSchema = HMDraftMetaBaseSchema.extend({
786
- lastUpdateTime: z.number()
787
- });
787
+ lastUpdateTime: z.number(),
788
+ isFolder: z.boolean().optional()
789
+ }).transform(({ isFolder, ...draft }) => ({
790
+ ...draft,
791
+ isCollection: draft.isCollection ?? isFolder ?? false
792
+ }));
788
793
  var HMSubjectContactsRequestSchema = z.object({
789
794
  key: z.literal("SubjectContacts"),
790
795
  input: z.string(),
@@ -61,6 +61,31 @@ async function generateWebCryptoKeyPair() {
61
61
  const publicKeyRaw = new Uint8Array(await crypto.subtle.exportKey("raw", keyPair.publicKey));
62
62
  return new WebCryptoKeyPair(keyPair, publicKeyRaw);
63
63
  }
64
+ var ED25519_SPKI_DER_PREFIX = new Uint8Array([48, 42, 48, 5, 6, 3, 43, 101, 112, 3, 33, 0]);
65
+ var nativeCrypto;
66
+ var nativeCryptoReady = (async () => {
67
+ try {
68
+ const mod = await import("module");
69
+ const base = (typeof process !== "undefined" && process.cwd ? process.cwd() : "/") + "/";
70
+ nativeCrypto = mod.createRequire(base)("node:crypto");
71
+ } catch {
72
+ nativeCrypto = null;
73
+ }
74
+ })();
75
+ var nativeKeyCache = /* @__PURE__ */ new Map();
76
+ function nativeVerify(nc, sig, data, rawPubKey) {
77
+ const cacheKey = base58btc.encode(rawPubKey);
78
+ let key = nativeKeyCache.get(cacheKey);
79
+ if (key === void 0) {
80
+ const spki = new Uint8Array(ED25519_SPKI_DER_PREFIX.length + rawPubKey.length);
81
+ spki.set(ED25519_SPKI_DER_PREFIX);
82
+ spki.set(rawPubKey, ED25519_SPKI_DER_PREFIX.length);
83
+ key = nc.createPublicKey({ key: spki, format: "der", type: "spki" });
84
+ if (nativeKeyCache.size > 1e3) nativeKeyCache.clear();
85
+ nativeKeyCache.set(cacheKey, key);
86
+ }
87
+ return nc.verify(null, data, key, sig);
88
+ }
64
89
  function verify(blob) {
65
90
  if (blob.signer[0] !== ED25519_VARINT_PREFIX[0] || blob.signer[1] !== ED25519_VARINT_PREFIX[1]) return false;
66
91
  const rawPubKey = blob.signer.slice(ED25519_VARINT_PREFIX.length);
@@ -69,6 +94,7 @@ function verify(blob) {
69
94
  const unsigned = { ...blob, sig: new Uint8Array(ED25519_SIGNATURE_SIZE) };
70
95
  const data = new Uint8Array(encode(unsigned));
71
96
  try {
97
+ if (nativeCrypto) return nativeVerify(nativeCrypto, sigCopy, data, rawPubKey);
72
98
  return ed25519.verify(sigCopy, data, rawPubKey);
73
99
  } catch {
74
100
  return false;
@@ -193,6 +219,7 @@ export {
193
219
  nobleKeyPairFromSeed,
194
220
  WebCryptoKeyPair,
195
221
  generateWebCryptoKeyPair,
222
+ nativeCryptoReady,
196
223
  verify,
197
224
  principalFromEd25519,
198
225
  principalToString,
@@ -15,7 +15,7 @@ import {
15
15
  HMActionSchema,
16
16
  HMRequestSchema,
17
17
  packHmId
18
- } from "./chunk-4HJWSEWS.mjs";
18
+ } from "./chunk-MZUGCZJ6.mjs";
19
19
 
20
20
  // src/client.ts
21
21
  import { encode as cborEncode } from "@ipld/dag-cbor";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  resolveId
3
- } from "./chunk-3UP4S7XZ.mjs";
3
+ } from "./chunk-D2LTD2KZ.mjs";
4
4
  import {
5
5
  createSeedClient
6
- } from "./chunk-CVUWZ27W.mjs";
6
+ } from "./chunk-RCVLNXG6.mjs";
7
7
  import {
8
8
  unpackHmId
9
- } from "./chunk-4HJWSEWS.mjs";
9
+ } from "./chunk-MZUGCZJ6.mjs";
10
10
 
11
11
  // src/resource-read.ts
12
12
  async function resolveIdWithClient(rawId, options = {}) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpackHmId
3
- } from "./chunk-4HJWSEWS.mjs";
3
+ } from "./chunk-MZUGCZJ6.mjs";
4
4
 
5
5
  // src/blocks-to-markdown.ts
6
6
  var FM_STRING_KEYS = [
package/dist/client.mjs CHANGED
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  createSeedClient,
3
3
  deserializeQueryString
4
- } from "./chunk-CVUWZ27W.mjs";
4
+ } from "./chunk-RCVLNXG6.mjs";
5
5
  import "./chunk-CBELM7KX.mjs";
6
6
  import "./chunk-JT57MV7Y.mjs";
7
7
  import "./chunk-PJ2RFT5A.mjs";
8
8
  import "./chunk-LVAHHQIK.mjs";
9
9
  import "./chunk-DR3HJ6BV.mjs";
10
- import "./chunk-4HJWSEWS.mjs";
10
+ import "./chunk-MZUGCZJ6.mjs";
11
11
  import "./chunk-7P6ASYW6.mjs";
12
12
  export {
13
13
  createSeedClient,
package/dist/comment.mjs CHANGED
@@ -4,11 +4,11 @@ import {
4
4
  deleteComment,
5
5
  trimTrailingEmptyBlocks,
6
6
  updateComment
7
- } from "./chunk-LJI66S7C.mjs";
7
+ } from "./chunk-IREIRKVP.mjs";
8
8
  import "./chunk-N3P7S5YZ.mjs";
9
9
  import "./chunk-LVAHHQIK.mjs";
10
10
  import "./chunk-DR3HJ6BV.mjs";
11
- import "./chunk-4HJWSEWS.mjs";
11
+ import "./chunk-MZUGCZJ6.mjs";
12
12
  import "./chunk-7P6ASYW6.mjs";
13
13
  export {
14
14
  commentRecordIdFromBlob,
@@ -4,8 +4,8 @@ import {
4
4
  followToDocument,
5
5
  resolveDocumentState,
6
6
  resolveEditableDocument
7
- } from "./chunk-M7ZYWWI3.mjs";
8
- import "./chunk-4HJWSEWS.mjs";
7
+ } from "./chunk-C42YWLL2.mjs";
8
+ import "./chunk-MZUGCZJ6.mjs";
9
9
  import "./chunk-7P6ASYW6.mjs";
10
10
  export {
11
11
  describeRedirect,
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  editorBlockToHMBlock,
3
3
  editorBlocksToHMBlockNodes
4
- } from "./chunk-AC3EMQZG.mjs";
4
+ } from "./chunk-2OMSCQ56.mjs";
5
5
  import "./chunk-N3P7S5YZ.mjs";
6
- import "./chunk-4HJWSEWS.mjs";
6
+ import "./chunk-MZUGCZJ6.mjs";
7
7
  import "./chunk-7P6ASYW6.mjs";
8
8
  export {
9
9
  editorBlockToHMBlock,
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  resolveHypermediaUrl,
3
3
  resolveId
4
- } from "./chunk-3UP4S7XZ.mjs";
5
- import "./chunk-4HJWSEWS.mjs";
4
+ } from "./chunk-D2LTD2KZ.mjs";
5
+ import "./chunk-MZUGCZJ6.mjs";
6
6
  import "./chunk-7P6ASYW6.mjs";
7
7
  export {
8
8
  resolveHypermediaUrl,