@seed-hypermedia/client 0.0.69 → 0.0.70
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.
- package/dist/auth.mjs +3 -2
- package/dist/auto-link.d.ts +3 -2
- package/dist/auto-link.mjs +5 -4
- package/dist/blobs.d.ts +6 -4
- package/dist/blobs.mjs +2 -1
- package/dist/capability.d.ts +7 -2
- package/dist/capability.mjs +5 -2
- package/dist/change.d.ts +8 -7
- package/dist/change.mjs +4 -3
- package/dist/{chunk-NX7YFFRX.mjs → chunk-37WRGUK4.mjs} +5 -4
- package/dist/{chunk-MKUWQB5W.mjs → chunk-3KESF5XJ.mjs} +2 -2
- package/dist/{chunk-GKGWSN6J.mjs → chunk-4Q3SAL5R.mjs} +1 -1
- package/dist/{chunk-W4OGV22Y.mjs → chunk-BUPMCRR4.mjs} +14 -23
- package/dist/{chunk-5EWV4OPF.mjs → chunk-DBHL3BYB.mjs} +8 -13
- package/dist/chunk-DR3HJ6BV.mjs +25 -0
- package/dist/{chunk-WJQSJ6UM.mjs → chunk-EU36RFR3.mjs} +2 -2
- package/dist/{chunk-FYUZZ3HT.mjs → chunk-IT5LLTMP.mjs} +15 -5
- package/dist/{chunk-I3YUHKYW.mjs → chunk-JT57MV7Y.mjs} +6 -5
- package/dist/{chunk-YZX54L3G.mjs → chunk-LVAHHQIK.mjs} +8 -0
- package/dist/{chunk-QS7TPMYT.mjs → chunk-NYWCMQTH.mjs} +5 -4
- package/dist/{chunk-XI2LXZM7.mjs → chunk-PJ2RFT5A.mjs} +5 -4
- package/dist/{chunk-DXDF36H5.mjs → chunk-SHOAYNJY.mjs} +1 -1
- package/dist/client.d.ts +3 -2
- package/dist/client.mjs +5 -4
- package/dist/comment.d.ts +5 -4
- package/dist/comment.mjs +3 -2
- package/dist/contact.d.ts +5 -4
- package/dist/contact.mjs +3 -2
- package/dist/hm-types.d.ts +566 -566
- package/dist/hmauth.mjs +3 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +17 -9
- package/dist/ref.d.ts +5 -4
- package/dist/ref.mjs +3 -2
- package/dist/resource-read.mjs +6 -5
- package/dist/signer.d.ts +42 -0
- package/dist/signer.mjs +9 -0
- package/dist/signing.d.ts +10 -2
- package/dist/signing.mjs +4 -1
- package/dist/vault-local.mjs +4 -1
- package/dist/vault.d.ts +14 -4
- package/dist/vault.mjs +4 -1
- 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-
|
|
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-
|
|
26
|
+
} from "./chunk-IT5LLTMP.mjs";
|
|
27
|
+
import "./chunk-DR3HJ6BV.mjs";
|
|
27
28
|
import {
|
|
28
29
|
decode as decode2
|
|
29
30
|
} from "./chunk-3TPCJCVO.mjs";
|
package/dist/auto-link.d.ts
CHANGED
|
@@ -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,
|
|
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:
|
|
56
|
+
signer: AnySigner;
|
|
56
57
|
};
|
|
57
58
|
/**
|
|
58
59
|
* Auto-link a newly published child document to its parent.
|
package/dist/auto-link.mjs
CHANGED
|
@@ -4,11 +4,12 @@ import {
|
|
|
4
4
|
documentContainsLinkToChild,
|
|
5
5
|
documentHasSelfQuery,
|
|
6
6
|
shouldAutoLinkParent
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-EU36RFR3.mjs";
|
|
8
|
+
import "./chunk-JT57MV7Y.mjs";
|
|
9
|
+
import "./chunk-PJ2RFT5A.mjs";
|
|
10
10
|
import "./chunk-HBIVZA6C.mjs";
|
|
11
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-LVAHHQIK.mjs";
|
|
12
|
+
import "./chunk-DR3HJ6BV.mjs";
|
|
12
13
|
import "./chunk-SQEUO7FO.mjs";
|
|
13
14
|
import "./chunk-7P6ASYW6.mjs";
|
|
14
15
|
export {
|
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(
|
|
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(
|
|
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(
|
|
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:
|
|
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
package/dist/capability.d.ts
CHANGED
|
@@ -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
|
|
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:
|
|
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.
|
package/dist/capability.mjs
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createCapability,
|
|
3
3
|
resolveCapability
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-BUPMCRR4.mjs";
|
|
5
|
+
import "./chunk-LVAHHQIK.mjs";
|
|
6
|
+
import "./chunk-IT5LLTMP.mjs";
|
|
7
|
+
import "./chunk-DR3HJ6BV.mjs";
|
|
6
8
|
import "./chunk-SQEUO7FO.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
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
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-
|
|
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
|
|
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
|
|
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
|
|
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 = {
|
|
@@ -7,10 +7,10 @@ import {
|
|
|
7
7
|
createDocumentChange,
|
|
8
8
|
createGenesisChange,
|
|
9
9
|
signDocumentChange
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-JT57MV7Y.mjs";
|
|
11
11
|
import {
|
|
12
12
|
createVersionRef
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-PJ2RFT5A.mjs";
|
|
14
14
|
import {
|
|
15
15
|
HMActionSchema,
|
|
16
16
|
HMRequestSchema,
|
|
@@ -1,34 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
|
-
signObject,
|
|
3
2
|
toPublishInput
|
|
4
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LVAHHQIK.mjs";
|
|
4
|
+
import {
|
|
5
|
+
createCapability
|
|
6
|
+
} from "./chunk-IT5LLTMP.mjs";
|
|
5
7
|
import {
|
|
6
8
|
entityQueryPathToHmIdPath,
|
|
7
9
|
packBaseId
|
|
8
10
|
} from "./chunk-SQEUO7FO.mjs";
|
|
9
11
|
|
|
10
12
|
// src/capability.ts
|
|
11
|
-
import { encode as cborEncode } from "@ipld/dag-cbor";
|
|
12
13
|
import { base58btc } from "multiformats/bases/base58";
|
|
13
|
-
async function
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
role: input.role
|
|
23
|
-
};
|
|
24
|
-
if (input.path) {
|
|
25
|
-
unsigned.path = input.path;
|
|
26
|
-
}
|
|
27
|
-
if (input.label) {
|
|
28
|
-
unsigned.label = input.label;
|
|
29
|
-
}
|
|
30
|
-
unsigned.sig = await signObject(signer, unsigned);
|
|
31
|
-
return toPublishInput(cborEncode(unsigned));
|
|
14
|
+
async function createCapability2(input, signer) {
|
|
15
|
+
const encoded = await createCapability(
|
|
16
|
+
signer,
|
|
17
|
+
new Uint8Array(base58btc.decode(input.delegateUid)),
|
|
18
|
+
input.role,
|
|
19
|
+
Date.now(),
|
|
20
|
+
{ path: input.path || void 0, label: input.label || void 0 }
|
|
21
|
+
);
|
|
22
|
+
return toPublishInput(encoded.data);
|
|
32
23
|
}
|
|
33
24
|
async function resolveCapability(client, targetAccount, signerAccount, path) {
|
|
34
25
|
if (targetAccount === signerAccount) return void 0;
|
|
@@ -52,6 +43,6 @@ async function resolveCapability(client, targetAccount, signerAccount, path) {
|
|
|
52
43
|
}
|
|
53
44
|
|
|
54
45
|
export {
|
|
55
|
-
createCapability,
|
|
46
|
+
createCapability2 as createCapability,
|
|
56
47
|
resolveCapability
|
|
57
48
|
};
|
|
@@ -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
|
|
24
|
-
|
|
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
|
|
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,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createChange,
|
|
3
3
|
createChangeOps
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-JT57MV7Y.mjs";
|
|
5
5
|
import {
|
|
6
6
|
createVersionRef
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-PJ2RFT5A.mjs";
|
|
8
8
|
import {
|
|
9
9
|
resolveDocumentState
|
|
10
10
|
} from "./chunk-HBIVZA6C.mjs";
|
|
@@ -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(
|
|
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(
|
|
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(
|
|
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
|
-
...
|
|
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-
|
|
3
|
+
} from "./chunk-PJ2RFT5A.mjs";
|
|
4
4
|
import {
|
|
5
5
|
cborCodec,
|
|
6
|
-
normalizeBytes
|
|
7
|
-
|
|
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
|
|
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
|
|
49
|
+
const pubKey = await signerPublicKey(signer);
|
|
49
50
|
const unsigned = {
|
|
50
51
|
type: "Change",
|
|
51
52
|
signer: new Uint8Array(pubKey),
|
|
@@ -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
|
};
|
|
@@ -3,8 +3,9 @@ import {
|
|
|
3
3
|
} from "./chunk-N3P7S5YZ.mjs";
|
|
4
4
|
import {
|
|
5
5
|
signObject,
|
|
6
|
+
signerPublicKey,
|
|
6
7
|
toPublishInput
|
|
7
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-LVAHHQIK.mjs";
|
|
8
9
|
import {
|
|
9
10
|
hmIdPathToEntityQueryPath,
|
|
10
11
|
packHmId
|
|
@@ -248,7 +249,7 @@ async function createCommentBlob({
|
|
|
248
249
|
rootReplyCommentVersion,
|
|
249
250
|
visibility
|
|
250
251
|
}) {
|
|
251
|
-
const signerKey = await signer
|
|
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
|
|
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
|
|
364
|
+
const signerKey = await signerPublicKey(signer);
|
|
364
365
|
cleanContentOfUndefined(input.content);
|
|
365
366
|
const trimmedContent = trimTrailingEmptyBlocks(input.content);
|
|
366
367
|
const comment = {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
signObject,
|
|
3
|
+
signerPublicKey,
|
|
3
4
|
toPublishInput
|
|
4
|
-
} from "./chunk-
|
|
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
|
|
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
|
|
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
|
|
85
|
+
const signerKey = await signerPublicKey(signer);
|
|
85
86
|
const unsigned = buildUnsignedRef({
|
|
86
87
|
signerKey,
|
|
87
88
|
space: input.space,
|
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { type HMPrepareDocumentChangeInput, type HMRequest
|
|
2
|
+
import { type HMPrepareDocumentChangeInput, type HMRequest } from './hm-types';
|
|
3
|
+
import type { AnySigner } from './signer';
|
|
3
4
|
/**
|
|
4
5
|
* Deserializes a URL query string using a Zod schema.
|
|
5
6
|
* If the query contains only a __value key, returns the primitive value directly.
|
|
@@ -34,7 +35,7 @@ export type SeedClient = {
|
|
|
34
35
|
}>['output']>;
|
|
35
36
|
publish(input: PublishBlobsRequest['input']): Promise<PublishBlobsRequest['output']>;
|
|
36
37
|
publishBlobs(input: PublishBlobsRequest['input']): Promise<PublishBlobsRequest['output']>;
|
|
37
|
-
publishDocument(input: PublishDocumentInput, signer:
|
|
38
|
+
publishDocument(input: PublishDocumentInput, signer: AnySigner): Promise<void>;
|
|
38
39
|
baseUrl: string;
|
|
39
40
|
};
|
|
40
41
|
export declare function createSeedClient(baseUrl: string, options?: SeedClientOptions): SeedClient;
|