@seed-hypermedia/client 0.0.69 → 0.0.71

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 (61) hide show
  1. package/dist/auth.mjs +3 -2
  2. package/dist/auto-link.d.ts +3 -2
  3. package/dist/auto-link.mjs +7 -6
  4. package/dist/blobs.d.ts +6 -4
  5. package/dist/blobs.mjs +2 -1
  6. package/dist/blocks-to-markdown.mjs +2 -2
  7. package/dist/capability.d.ts +7 -2
  8. package/dist/capability.mjs +6 -3
  9. package/dist/change.d.ts +8 -7
  10. package/dist/change.mjs +4 -3
  11. package/dist/{chunk-NX7YFFRX.mjs → chunk-37WRGUK4.mjs} +5 -4
  12. package/dist/{chunk-NPG76WUS.mjs → chunk-4L2LE3JW.mjs} +1 -1
  13. package/dist/{chunk-T5BTAJPW.mjs → chunk-ALT5YCCW.mjs} +1 -1
  14. package/dist/{chunk-HBIVZA6C.mjs → chunk-AOB3PMFZ.mjs} +1 -1
  15. package/dist/{chunk-5EWV4OPF.mjs → chunk-DBHL3BYB.mjs} +8 -13
  16. package/dist/chunk-DR3HJ6BV.mjs +25 -0
  17. package/dist/{chunk-LYECQKZE.mjs → chunk-FNETXNBK.mjs} +1 -1
  18. package/dist/{chunk-MKUWQB5W.mjs → chunk-FUSG27NF.mjs} +3 -3
  19. package/dist/{chunk-S2PVJK2P.mjs → chunk-H34UYMNW.mjs} +1 -1
  20. package/dist/{chunk-FYUZZ3HT.mjs → chunk-IT5LLTMP.mjs} +15 -5
  21. package/dist/{chunk-I3YUHKYW.mjs → chunk-JT57MV7Y.mjs} +6 -5
  22. package/dist/{chunk-QS7TPMYT.mjs → chunk-KY6WRGXY.mjs} +6 -5
  23. package/dist/{chunk-YZX54L3G.mjs → chunk-LVAHHQIK.mjs} +8 -0
  24. package/dist/{chunk-KO4XH5L2.mjs → chunk-NUIZU7KO.mjs} +1 -1
  25. package/dist/{chunk-XI2LXZM7.mjs → chunk-PJ2RFT5A.mjs} +5 -4
  26. package/dist/{chunk-YNVFRCUH.mjs → chunk-QYA75XPV.mjs} +37 -17
  27. package/dist/{chunk-W4OGV22Y.mjs → chunk-RL3OEUFZ.mjs} +15 -24
  28. package/dist/{chunk-DXDF36H5.mjs → chunk-SHOAYNJY.mjs} +1 -1
  29. package/dist/{chunk-GKGWSN6J.mjs → chunk-TXVEL22U.mjs} +3 -3
  30. package/dist/{chunk-SQEUO7FO.mjs → chunk-W3FLBRBH.mjs} +1 -0
  31. package/dist/{chunk-WJQSJ6UM.mjs → chunk-X6OJRM5W.mjs} +4 -4
  32. package/dist/client.d.ts +3 -2
  33. package/dist/client.mjs +6 -5
  34. package/dist/comment.d.ts +5 -4
  35. package/dist/comment.mjs +4 -3
  36. package/dist/contact.d.ts +5 -4
  37. package/dist/contact.mjs +3 -2
  38. package/dist/document-state.mjs +2 -2
  39. package/dist/editorblock-to-hmblock.mjs +2 -2
  40. package/dist/hm-resolver.d.ts +7 -3
  41. package/dist/hm-resolver.mjs +2 -2
  42. package/dist/hm-types.d.ts +610 -566
  43. package/dist/hm-types.mjs +1 -1
  44. package/dist/hmauth.mjs +3 -2
  45. package/dist/hmblock-to-editorblock.mjs +2 -2
  46. package/dist/index.d.ts +2 -0
  47. package/dist/index.mjs +25 -17
  48. package/dist/pdf-to-blocks.mjs +3 -3
  49. package/dist/ref.d.ts +5 -4
  50. package/dist/ref.mjs +3 -2
  51. package/dist/resource-read.mjs +8 -7
  52. package/dist/signer.d.ts +42 -0
  53. package/dist/signer.mjs +9 -0
  54. package/dist/signing.d.ts +10 -2
  55. package/dist/signing.mjs +4 -1
  56. package/dist/tei-to-blocks.mjs +2 -2
  57. package/dist/unicode.mjs +1 -1
  58. package/dist/vault-local.mjs +4 -1
  59. package/dist/vault.d.ts +14 -4
  60. package/dist/vault.mjs +4 -1
  61. 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-DXDF36H5.mjs";
14
+ } from "./chunk-SHOAYNJY.mjs";
15
15
  import {
16
16
  decode,
17
17
  encode
@@ -23,7 +23,8 @@ import {
23
23
  principalFromString,
24
24
  principalToString,
25
25
  verify
26
- } from "./chunk-FYUZZ3HT.mjs";
26
+ } from "./chunk-IT5LLTMP.mjs";
27
+ import "./chunk-DR3HJ6BV.mjs";
27
28
  import {
28
29
  decode as decode2
29
30
  } from "./chunk-3TPCJCVO.mjs";
@@ -9,7 +9,8 @@
9
9
  * - Operation builder: what DocumentOperations to emit
10
10
  * - Full I/O convenience: fetch parent, check, build ops, sign, publish
11
11
  */
12
- import type { HMDocument, HMSigner, UnpackedHypermediaId } from './hm-types';
12
+ import type { HMDocument, UnpackedHypermediaId } from './hm-types';
13
+ import type { AnySigner } from './signer';
13
14
  import type { SeedClient } from './client';
14
15
  import type { DocumentOperation } from './change';
15
16
  /**
@@ -52,7 +53,7 @@ export type AutoLinkChildToParentOptions = {
52
53
  /** hm:// URL of the published child document (without version). */
53
54
  childHmUrl: string;
54
55
  /** Signer for the parent document change. */
55
- signer: HMSigner;
56
+ signer: AnySigner;
56
57
  };
57
58
  /**
58
59
  * Auto-link a newly published child document to its parent.
@@ -4,12 +4,13 @@ import {
4
4
  documentContainsLinkToChild,
5
5
  documentHasSelfQuery,
6
6
  shouldAutoLinkParent
7
- } from "./chunk-WJQSJ6UM.mjs";
8
- import "./chunk-I3YUHKYW.mjs";
9
- import "./chunk-XI2LXZM7.mjs";
10
- import "./chunk-HBIVZA6C.mjs";
11
- import "./chunk-YZX54L3G.mjs";
12
- import "./chunk-SQEUO7FO.mjs";
7
+ } from "./chunk-X6OJRM5W.mjs";
8
+ import "./chunk-JT57MV7Y.mjs";
9
+ import "./chunk-PJ2RFT5A.mjs";
10
+ import "./chunk-AOB3PMFZ.mjs";
11
+ import "./chunk-LVAHHQIK.mjs";
12
+ import "./chunk-DR3HJ6BV.mjs";
13
+ import "./chunk-W3FLBRBH.mjs";
13
14
  import "./chunk-7P6ASYW6.mjs";
14
15
  export {
15
16
  autoLinkChildToParent,
package/dist/blobs.d.ts CHANGED
@@ -7,6 +7,8 @@
7
7
  * - WebCryptoKeyPair: uses crypto.subtle with unexportable keys. For browser session keys.
8
8
  */
9
9
  import { CID } from 'multiformats/cid';
10
+ import { type AnySigner } from './signer';
11
+ export type { AnySigner };
10
12
  export declare const ED25519_VARINT_PREFIX: Uint8Array<ArrayBuffer>;
11
13
  export declare const ED25519_SIGNATURE_SIZE = 64;
12
14
  export declare const ED25519_PUBLIC_KEY_SIZE = 32;
@@ -94,7 +96,7 @@ export interface Profile extends Blob {
94
96
  readonly account?: Principal;
95
97
  }
96
98
  /** Create a signed and encoded Profile blob. */
97
- export declare function createProfile(signer: Signer, opts: {
99
+ export declare function createProfile(anySigner: AnySigner, opts: {
98
100
  /** Display name (required for non-alias profiles). */
99
101
  name: string;
100
102
  /** Icon/avatar URI. */
@@ -105,7 +107,7 @@ export declare function createProfile(signer: Signer, opts: {
105
107
  account?: Principal;
106
108
  }, ts: Timestamp): Promise<Encoded<Profile>>;
107
109
  /** Create a signed and encoded alias Profile blob (identity redirect). */
108
- export declare function createProfileAlias(signer: Signer, alias: Principal, ts: Timestamp): Promise<Encoded<Profile>>;
110
+ export declare function createProfileAlias(anySigner: AnySigner, alias: Principal, ts: Timestamp): Promise<Encoded<Profile>>;
109
111
  /** Capability blob granting rights from issuer to delegate. */
110
112
  export interface Capability extends Blob {
111
113
  readonly type: 'Capability';
@@ -121,7 +123,7 @@ export interface Capability extends Blob {
121
123
  readonly label?: string;
122
124
  }
123
125
  /** Create a signed and encoded Capability blob. */
124
- export declare function createCapability(issuer: Signer, delegate: Principal, role: Role, ts: Timestamp, opts?: {
126
+ export declare function createCapability(anyIssuer: AnySigner, delegate: Principal, role: Role, ts: Timestamp, opts?: {
125
127
  /** Path scope. */
126
128
  path?: string;
127
129
  /** Human-readable label. */
@@ -142,7 +144,7 @@ export interface Encoded<T extends Blob> extends Decoded<T> {
142
144
  * Sign a blob with a Signer.
143
145
  * Fills sig with zeros, CBOR-encodes, signs, replaces sig.
144
146
  */
145
- export declare function sign<T extends Blob>(signer: Signer, blob: T): Promise<T>;
147
+ export declare function sign<T extends Blob>(signer: AnySigner, blob: T): Promise<T>;
146
148
  /** Encode a signed blob to DAG-CBOR and compute its content-addressed CID. */
147
149
  export declare function encode<T extends Blob>(blob: T): Encoded<T>;
148
150
  /**
package/dist/blobs.mjs CHANGED
@@ -21,7 +21,8 @@ import {
21
21
  principalToString,
22
22
  sign,
23
23
  verify
24
- } from "./chunk-FYUZZ3HT.mjs";
24
+ } from "./chunk-IT5LLTMP.mjs";
25
+ import "./chunk-DR3HJ6BV.mjs";
25
26
  import "./chunk-3TPCJCVO.mjs";
26
27
  import "./chunk-7P6ASYW6.mjs";
27
28
  export {
@@ -7,8 +7,8 @@ import {
7
7
  emitFrontmatter,
8
8
  parseDraftFilename,
9
9
  slugify
10
- } from "./chunk-T5BTAJPW.mjs";
11
- import "./chunk-SQEUO7FO.mjs";
10
+ } from "./chunk-ALT5YCCW.mjs";
11
+ import "./chunk-W3FLBRBH.mjs";
12
12
  import "./chunk-7P6ASYW6.mjs";
13
13
  export {
14
14
  blocksToMarkdown,
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * Capability SDK — create and resolve capabilities (delegate access to other accounts).
3
3
  */
4
- import type { HMPublishBlobsInput, HMSigner } from './hm-types';
4
+ import type { HMPublishBlobsInput } from './hm-types';
5
+ import type { AnySigner } from './signer';
5
6
  import type { SeedClient } from './client';
6
7
  /** Role values for capability blobs. */
7
8
  export type CapabilityRole = 'WRITER' | 'AGENT';
@@ -18,8 +19,12 @@ export type CreateCapabilityInput = {
18
19
  /**
19
20
  * Create a signed capability blob ready for publishing.
20
21
  * The signer is the issuer granting access to the delegate.
22
+ *
23
+ * Wraps the blob primitive in `./blobs`, which is the single implementation of
24
+ * the Capability wire format; this adds the string-keyed input shape and the
25
+ * publish envelope the rest of the SDK expects.
21
26
  */
22
- export declare function createCapability(input: CreateCapabilityInput, signer: HMSigner): Promise<HMPublishBlobsInput>;
27
+ export declare function createCapability(input: CreateCapabilityInput, signer: AnySigner): Promise<HMPublishBlobsInput>;
23
28
  /**
24
29
  * Find a WRITER or AGENT capability for `signerAccount` on `targetAccount`.
25
30
  * Returns the capability CID if found, undefined if not needed (same account) or not found.
@@ -1,9 +1,12 @@
1
1
  import {
2
2
  createCapability,
3
3
  resolveCapability
4
- } from "./chunk-W4OGV22Y.mjs";
5
- import "./chunk-YZX54L3G.mjs";
6
- import "./chunk-SQEUO7FO.mjs";
4
+ } from "./chunk-RL3OEUFZ.mjs";
5
+ import "./chunk-LVAHHQIK.mjs";
6
+ import "./chunk-IT5LLTMP.mjs";
7
+ import "./chunk-DR3HJ6BV.mjs";
8
+ import "./chunk-W3FLBRBH.mjs";
9
+ import "./chunk-3TPCJCVO.mjs";
7
10
  import "./chunk-7P6ASYW6.mjs";
8
11
  export {
9
12
  createCapability,
package/dist/change.d.ts CHANGED
@@ -7,8 +7,9 @@
7
7
  *
8
8
  * Convenience wrappers combine both steps for common use cases.
9
9
  */
10
- import type { HMPrepareDocumentChangeInput, HMPublishBlobsInput, HMSigner } from './hm-types';
10
+ import type { HMPrepareDocumentChangeInput, HMPublishBlobsInput } from './hm-types';
11
11
  import { CID } from 'multiformats';
12
+ import type { AnySigner } from './signer';
12
13
  export type DocumentOperation = {
13
14
  type: 'SetAttributes';
14
15
  attrs: Array<{
@@ -55,14 +56,14 @@ export declare function createChangeOps(input: CreateChangeOpsInput): {
55
56
  * 4. Sign the CBOR-encoded blob (with zeroed sig)
56
57
  * 5. Encode final blob and compute SHA256 CID
57
58
  */
58
- export declare function createChange(unsignedBytes: Uint8Array, signer: HMSigner): Promise<{
59
+ export declare function createChange(unsignedBytes: Uint8Array, signer: AnySigner): Promise<{
59
60
  bytes: Uint8Array;
60
61
  cid: CID;
61
62
  genesis: CID | null;
62
63
  ts: number | undefined;
63
64
  }>;
64
65
  /** @deprecated Use createChange instead */
65
- export declare const signPreparedChange: (unsignedBytes: Uint8Array, signer: HMSigner) => Promise<{
66
+ export declare const signPreparedChange: (unsignedBytes: Uint8Array, signer: AnySigner) => Promise<{
66
67
  signedBytes: Uint8Array;
67
68
  cid: CID;
68
69
  genesis: CID | null;
@@ -71,7 +72,7 @@ export declare const signPreparedChange: (unsignedBytes: Uint8Array, signer: HMS
71
72
  * Create a signed genesis Change blob (empty, ts=0).
72
73
  * This deterministic sentinel is only intended for home documents.
73
74
  */
74
- export declare function createGenesisChange(signer: HMSigner): Promise<{
75
+ export declare function createGenesisChange(signer: AnySigner): Promise<{
75
76
  bytes: Uint8Array;
76
77
  cid: CID;
77
78
  }>;
@@ -81,7 +82,7 @@ export type CreateDocumentChangeFromOpsInput = CreateChangeOpsInput;
81
82
  * Convenience: create unsigned ops + sign in one step.
82
83
  * @deprecated Use createChangeOps() + createChange() for the decoupled API.
83
84
  */
84
- export declare function createDocumentChangeFromOps(input: CreateChangeOpsInput, signer: HMSigner): Promise<{
85
+ export declare function createDocumentChangeFromOps(input: CreateChangeOpsInput, signer: AnySigner): Promise<{
85
86
  bytes: Uint8Array;
86
87
  cid: CID;
87
88
  ts: bigint;
@@ -100,7 +101,7 @@ export type CreateDocumentChangeInput = {
100
101
  * Create a signed document Change blob from proto-format changes.
101
102
  * Only supports setMetadata — for all ops, use createChangeOps + createChange.
102
103
  */
103
- export declare function createDocumentChange(input: CreateDocumentChangeInput, signer: HMSigner): Promise<{
104
+ export declare function createDocumentChange(input: CreateDocumentChangeInput, signer: AnySigner): Promise<{
104
105
  bytes: Uint8Array;
105
106
  cid: CID;
106
107
  }>;
@@ -131,7 +132,7 @@ export type SignDocumentChangeInput = {
131
132
  * Combines: createChange + createVersionRef into a single publish payload.
132
133
  * The caller is responsible for calling PrepareChange beforehand and submitting via publishBlobs.
133
134
  */
134
- export declare function signDocumentChange(input: SignDocumentChangeInput, signer: HMSigner): Promise<{
135
+ export declare function signDocumentChange(input: SignDocumentChangeInput, signer: AnySigner): Promise<{
135
136
  changeCid: CID;
136
137
  publishInput: HMPublishBlobsInput;
137
138
  }>;
package/dist/change.mjs CHANGED
@@ -7,9 +7,10 @@ import {
7
7
  signDocumentChange,
8
8
  signPreparedChange,
9
9
  visibilityToCbor
10
- } from "./chunk-I3YUHKYW.mjs";
11
- import "./chunk-XI2LXZM7.mjs";
12
- import "./chunk-YZX54L3G.mjs";
10
+ } from "./chunk-JT57MV7Y.mjs";
11
+ import "./chunk-PJ2RFT5A.mjs";
12
+ import "./chunk-LVAHHQIK.mjs";
13
+ import "./chunk-DR3HJ6BV.mjs";
13
14
  import "./chunk-7P6ASYW6.mjs";
14
15
  export {
15
16
  createChange,
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  signObject,
3
+ signerPublicKey,
3
4
  toPublishInput
4
- } from "./chunk-YZX54L3G.mjs";
5
+ } from "./chunk-LVAHHQIK.mjs";
5
6
 
6
7
  // src/contact.ts
7
8
  import { decode as cborDecode, encode as cborEncode } from "@ipld/dag-cbor";
@@ -34,7 +35,7 @@ async function computeTSID(timestampMs, blobData) {
34
35
  return base58btc.encode(tsidBytes);
35
36
  }
36
37
  async function createContact(input, signer) {
37
- const signerKey = await signer.getPublicKey();
38
+ const signerKey = await signerPublicKey(signer);
38
39
  const ts = BigInt(Date.now());
39
40
  const signerUid = base58btc.encode(new Uint8Array(signerKey));
40
41
  const authority = input.accountUid || signerUid;
@@ -63,7 +64,7 @@ async function createContact(input, signer) {
63
64
  };
64
65
  }
65
66
  async function updateContact(input, signer) {
66
- const signerKey = await signer.getPublicKey();
67
+ const signerKey = await signerPublicKey(signer);
67
68
  const tsid = extractTsid(input.contactId);
68
69
  const accountUid = input.accountUid || extractAuthority(input.contactId);
69
70
  const unsigned = {
@@ -87,7 +88,7 @@ async function updateContact(input, signer) {
87
88
  return toPublishInput(cborEncode(unsigned));
88
89
  }
89
90
  async function deleteContact(input, signer) {
90
- const signerKey = await signer.getPublicKey();
91
+ const signerKey = await signerPublicKey(signer);
91
92
  const tsid = extractTsid(input.contactId);
92
93
  const accountUid = input.accountUid || extractAuthority(input.contactId);
93
94
  const unsigned = {
@@ -6,7 +6,7 @@ import {
6
6
  HMBlockSchema,
7
7
  codePointLength,
8
8
  toNumber
9
- } from "./chunk-SQEUO7FO.mjs";
9
+ } from "./chunk-W3FLBRBH.mjs";
10
10
 
11
11
  // src/editorblock-to-hmblock.ts
12
12
  function toHMBlockType(editorBlockType) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpackHmId
3
- } from "./chunk-SQEUO7FO.mjs";
3
+ } from "./chunk-W3FLBRBH.mjs";
4
4
 
5
5
  // src/blocks-to-markdown.ts
6
6
  var FM_STRING_KEYS = [
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpackHmId
3
- } from "./chunk-SQEUO7FO.mjs";
3
+ } from "./chunk-W3FLBRBH.mjs";
4
4
 
5
5
  // src/document-state.ts
6
6
  async function resolveDocumentState(client, targetId) {
@@ -1,12 +1,15 @@
1
1
  import {
2
2
  decrypt
3
3
  } from "./chunk-UOL3F6XQ.mjs";
4
+ import {
5
+ principalFromEd25519,
6
+ principalToString
7
+ } from "./chunk-IT5LLTMP.mjs";
4
8
 
5
9
  // src/vault.ts
6
10
  import * as dagCBOR from "@ipld/dag-cbor";
7
11
  import { ed25519 } from "@noble/curves/ed25519.js";
8
12
  import * as cborg from "cborg";
9
- import { base58btc } from "multiformats/bases/base58";
10
13
  var VAULT_VERSION = 2;
11
14
  var cborEncodeOpts = {
12
15
  ...dagCBOR.encodeOptions,
@@ -20,18 +23,10 @@ var accountExtraKey = /* @__PURE__ */ Symbol("vault-account-extra");
20
23
  var delegationExtraKey = /* @__PURE__ */ Symbol("vault-delegation-extra");
21
24
  var capabilityExtraKey = /* @__PURE__ */ Symbol("vault-capability-extra");
22
25
  var accountNamePattern = /^[A-Za-z0-9_-]+$/;
23
- var ED25519_MULTICODEC_PREFIX = new Uint8Array([237, 1]);
24
- function principalFromPublicKey(publicKey) {
25
- const principal = new Uint8Array(ED25519_MULTICODEC_PREFIX.length + publicKey.length);
26
- principal.set(ED25519_MULTICODEC_PREFIX, 0);
27
- principal.set(publicKey, ED25519_MULTICODEC_PREFIX.length);
28
- return principal;
29
- }
30
- function principalToString(principal) {
31
- return base58btc.encode(principal);
32
- }
26
+ var principalFromPublicKey = principalFromEd25519;
27
+ var principalToString2 = principalToString;
33
28
  function accountIdFromSeed(seed) {
34
- return principalToString(principalFromPublicKey(new Uint8Array(ed25519.getPublicKey(seed))));
29
+ return principalToString2(principalFromPublicKey(new Uint8Array(ed25519.getPublicKey(seed))));
35
30
  }
36
31
  function createEmpty() {
37
32
  return { version: VAULT_VERSION, accounts: [] };
@@ -314,7 +309,7 @@ async function decryptVaultState(envelope, dek) {
314
309
  export {
315
310
  VAULT_VERSION,
316
311
  principalFromPublicKey,
317
- principalToString,
312
+ principalToString2 as principalToString,
318
313
  accountIdFromSeed,
319
314
  createEmpty,
320
315
  serialize,
@@ -0,0 +1,25 @@
1
+ // src/signer.ts
2
+ function hasPrincipal(signer) {
3
+ return "principal" in signer;
4
+ }
5
+ function toHMSigner(signer) {
6
+ if (!hasPrincipal(signer)) return signer;
7
+ const { principal } = signer;
8
+ return {
9
+ getPublicKey: async () => principal,
10
+ sign: (data) => signer.sign(data)
11
+ };
12
+ }
13
+ async function toPrincipalSigner(signer) {
14
+ if (hasPrincipal(signer)) return signer;
15
+ const principal = await signer.getPublicKey();
16
+ return {
17
+ principal,
18
+ sign: (data) => signer.sign(data)
19
+ };
20
+ }
21
+
22
+ export {
23
+ toHMSigner,
24
+ toPrincipalSigner
25
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  teiToBlocks
3
- } from "./chunk-S2PVJK2P.mjs";
3
+ } from "./chunk-H34UYMNW.mjs";
4
4
  import {
5
5
  embeddedPdfToBlocks
6
6
  } from "./chunk-52P3E6H6.mjs";
@@ -7,15 +7,15 @@ import {
7
7
  createDocumentChange,
8
8
  createGenesisChange,
9
9
  signDocumentChange
10
- } from "./chunk-I3YUHKYW.mjs";
10
+ } from "./chunk-JT57MV7Y.mjs";
11
11
  import {
12
12
  createVersionRef
13
- } from "./chunk-XI2LXZM7.mjs";
13
+ } from "./chunk-PJ2RFT5A.mjs";
14
14
  import {
15
15
  HMActionSchema,
16
16
  HMRequestSchema,
17
17
  packHmId
18
- } from "./chunk-SQEUO7FO.mjs";
18
+ } from "./chunk-W3FLBRBH.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-SQEUO7FO.mjs";
3
+ } from "./chunk-W3FLBRBH.mjs";
4
4
 
5
5
  // src/tei-to-blocks.ts
6
6
  function generateBlockId() {
@@ -1,3 +1,6 @@
1
+ import {
2
+ toPrincipalSigner
3
+ } from "./chunk-DR3HJ6BV.mjs";
1
4
  import {
2
5
  code,
3
6
  decode,
@@ -103,7 +106,8 @@ function principalEqual(a, b) {
103
106
  }
104
107
  return true;
105
108
  }
106
- async function createProfile(signer, opts, ts) {
109
+ async function createProfile(anySigner, opts, ts) {
110
+ const signer = await toPrincipalSigner(anySigner);
107
111
  opts = { ...opts };
108
112
  if (opts.account && principalEqual(opts.account, signer.principal)) {
109
113
  delete opts.account;
@@ -123,7 +127,8 @@ async function createProfile(signer, opts, ts) {
123
127
  };
124
128
  return encode2(await sign(signer, blob));
125
129
  }
126
- async function createProfileAlias(signer, alias, ts) {
130
+ async function createProfileAlias(anySigner, alias, ts) {
131
+ const signer = await toPrincipalSigner(anySigner);
127
132
  const blob = {
128
133
  type: "Profile",
129
134
  signer: signer.principal,
@@ -133,7 +138,12 @@ async function createProfileAlias(signer, alias, ts) {
133
138
  };
134
139
  return encode2(await sign(signer, blob));
135
140
  }
136
- async function createCapability(issuer, delegate, role, ts, opts = {}) {
141
+ async function createCapability(anyIssuer, delegate, role, ts, opts = {}) {
142
+ const issuer = await toPrincipalSigner(anyIssuer);
143
+ const present = {};
144
+ if (opts.path !== void 0) present.path = opts.path;
145
+ if (opts.label !== void 0) present.label = opts.label;
146
+ if (opts.audience !== void 0) present.audience = opts.audience;
137
147
  const blob = {
138
148
  type: "Capability",
139
149
  signer: issuer.principal,
@@ -141,14 +151,14 @@ async function createCapability(issuer, delegate, role, ts, opts = {}) {
141
151
  ts,
142
152
  delegate,
143
153
  role,
144
- ...opts
154
+ ...present
145
155
  };
146
156
  return encode2(await sign(issuer, blob));
147
157
  }
148
158
  async function sign(signer, blob) {
149
159
  const unsigned = { ...blob, sig: new Uint8Array(ED25519_SIGNATURE_SIZE) };
150
160
  const data = new Uint8Array(encode(unsigned));
151
- const sig = await signer.sign(data);
161
+ const sig = await (await toPrincipalSigner(signer)).sign(data);
152
162
  return { ...unsigned, sig };
153
163
  }
154
164
  function encode2(blob) {
@@ -1,10 +1,11 @@
1
1
  import {
2
2
  createVersionRef
3
- } from "./chunk-XI2LXZM7.mjs";
3
+ } from "./chunk-PJ2RFT5A.mjs";
4
4
  import {
5
5
  cborCodec,
6
- normalizeBytes
7
- } from "./chunk-YZX54L3G.mjs";
6
+ normalizeBytes,
7
+ signerPublicKey
8
+ } from "./chunk-LVAHHQIK.mjs";
8
9
 
9
10
  // src/change.ts
10
11
  import { decode as cborDecode, encode as cborEncode } from "@ipld/dag-cbor";
@@ -34,7 +35,7 @@ async function createChange(unsignedBytes, signer) {
34
35
  const change = cborDecode(unsignedBytes);
35
36
  const genesis = change.genesis instanceof CID ? change.genesis : null;
36
37
  const ts = timestampToNumber(change.ts);
37
- change.signer = new Uint8Array(await signer.getPublicKey());
38
+ change.signer = new Uint8Array(await signerPublicKey(signer));
38
39
  change.sig = new Uint8Array(64);
39
40
  change.sig = await signer.sign(cborEncode(change));
40
41
  const block = await Block.encode({ value: change, codec: cborCodec, hasher: sha256 });
@@ -45,7 +46,7 @@ var signPreparedChange = async (unsignedBytes, signer) => {
45
46
  return { signedBytes: result.bytes, cid: result.cid, genesis: result.genesis };
46
47
  };
47
48
  async function createGenesisChange(signer) {
48
- const pubKey = await signer.getPublicKey();
49
+ const pubKey = await signerPublicKey(signer);
49
50
  const unsigned = {
50
51
  type: "Change",
51
52
  signer: new Uint8Array(pubKey),
@@ -3,12 +3,13 @@ import {
3
3
  } from "./chunk-N3P7S5YZ.mjs";
4
4
  import {
5
5
  signObject,
6
+ signerPublicKey,
6
7
  toPublishInput
7
- } from "./chunk-YZX54L3G.mjs";
8
+ } from "./chunk-LVAHHQIK.mjs";
8
9
  import {
9
10
  hmIdPathToEntityQueryPath,
10
11
  packHmId
11
- } from "./chunk-SQEUO7FO.mjs";
12
+ } from "./chunk-W3FLBRBH.mjs";
12
13
 
13
14
  // src/comment.ts
14
15
  import { decode as cborDecode, encode as cborEncode } from "@ipld/dag-cbor";
@@ -248,7 +249,7 @@ async function createCommentBlob({
248
249
  rootReplyCommentVersion,
249
250
  visibility
250
251
  }) {
251
- const signerKey = await signer.getPublicKey();
252
+ const signerKey = await signerPublicKey(signer);
252
253
  cleanContentOfUndefined(content);
253
254
  const unsignedComment = createUnsignedComment({
254
255
  content,
@@ -336,7 +337,7 @@ async function deleteComment(input, signer) {
336
337
  if (!tsid) {
337
338
  throw new Error(`Invalid comment ID format: ${input.commentId}`);
338
339
  }
339
- const signerKey = await signer.getPublicKey();
340
+ const signerKey = await signerPublicKey(signer);
340
341
  const tombstone = {
341
342
  type: "Comment",
342
343
  id: tsid,
@@ -360,7 +361,7 @@ async function updateComment(input, signer) {
360
361
  if (!tsid) {
361
362
  throw new Error(`Invalid comment ID format: ${input.commentId}`);
362
363
  }
363
- const signerKey = await signer.getPublicKey();
364
+ const signerKey = await signerPublicKey(signer);
364
365
  cleanContentOfUndefined(input.content);
365
366
  const trimmedContent = trimTrailingEmptyBlocks(input.content);
366
367
  const comment = {
@@ -1,3 +1,7 @@
1
+ import {
2
+ toHMSigner
3
+ } from "./chunk-DR3HJ6BV.mjs";
4
+
1
5
  // src/signing.ts
2
6
  import { encode as cborEncode } from "@ipld/dag-cbor";
3
7
  var cborCodec = {
@@ -13,6 +17,9 @@ function normalizeBytes(data) {
13
17
  async function signObject(signer, data) {
14
18
  return await signer.sign(cborEncode(data));
15
19
  }
20
+ async function signerPublicKey(signer) {
21
+ return toHMSigner(signer).getPublicKey();
22
+ }
16
23
  function toPublishInput(blobData, extraBlobs) {
17
24
  return {
18
25
  blobs: [
@@ -29,5 +36,6 @@ export {
29
36
  cborCodec,
30
37
  normalizeBytes,
31
38
  signObject,
39
+ signerPublicKey,
32
40
  toPublishInput
33
41
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isSurrogate
3
- } from "./chunk-SQEUO7FO.mjs";
3
+ } from "./chunk-W3FLBRBH.mjs";
4
4
 
5
5
  // src/hmblock-to-editorblock.ts
6
6
  function toEditorBlockType(hmBlockType) {
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  signObject,
3
+ signerPublicKey,
3
4
  toPublishInput
4
- } from "./chunk-YZX54L3G.mjs";
5
+ } from "./chunk-LVAHHQIK.mjs";
5
6
 
6
7
  // src/ref.ts
7
8
  import { encode as cborEncode } from "@ipld/dag-cbor";
@@ -51,7 +52,7 @@ function buildUnsignedRef({
51
52
  return unsigned;
52
53
  }
53
54
  async function createVersionRef(input, signer) {
54
- const signerKey = await signer.getPublicKey();
55
+ const signerKey = await signerPublicKey(signer);
55
56
  const unsigned = buildUnsignedRef({
56
57
  signerKey,
57
58
  space: input.space,
@@ -67,7 +68,7 @@ async function createVersionRef(input, signer) {
67
68
  return toPublishInput(cborEncode(unsigned));
68
69
  }
69
70
  async function createTombstoneRef(input, signer) {
70
- const signerKey = await signer.getPublicKey();
71
+ const signerKey = await signerPublicKey(signer);
71
72
  const unsigned = buildUnsignedRef({
72
73
  signerKey,
73
74
  space: input.space,
@@ -81,7 +82,7 @@ async function createTombstoneRef(input, signer) {
81
82
  return toPublishInput(cborEncode(unsigned));
82
83
  }
83
84
  async function createRedirectRef(input, signer) {
84
- const signerKey = await signer.getPublicKey();
85
+ const signerKey = await signerPublicKey(signer);
85
86
  const unsigned = buildUnsignedRef({
86
87
  signerKey,
87
88
  space: input.space,