@seed-hypermedia/client 0.0.68 → 0.0.69
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/LICENSE +201 -0
- package/dist/auth.d.ts +79 -0
- package/dist/auth.mjs +265 -0
- package/dist/auto-link.mjs +20 -0
- package/dist/base64.mjs +9 -0
- package/dist/blobs.d.ts +168 -0
- package/dist/blobs.mjs +50 -0
- package/dist/block-diff.mjs +17 -0
- package/dist/blocks-to-markdown.mjs +22 -0
- package/dist/capability.mjs +11 -0
- package/dist/cbor.d.ts +13 -0
- package/dist/cbor.mjs +13 -0
- package/dist/change.mjs +23 -0
- package/dist/chunk-2MD3FXKB.mjs +14 -0
- package/dist/chunk-3TPCJCVO.mjs +24 -0
- package/dist/chunk-52P3E6H6.mjs +459 -0
- package/dist/{chunk-KCR3277A.mjs → chunk-5EWV4OPF.mjs} +1 -1
- package/dist/chunk-CBELM7KX.mjs +29 -0
- package/dist/chunk-DXDF36H5.mjs +289 -0
- package/dist/chunk-EY6RQVAP.mjs +138 -0
- package/dist/chunk-FYUZZ3HT.mjs +199 -0
- package/dist/chunk-GKGWSN6J.mjs +75 -0
- package/dist/chunk-H7L4TI6X.mjs +705 -0
- package/dist/chunk-HBIVZA6C.mjs +102 -0
- package/dist/chunk-I3YUHKYW.mjs +135 -0
- package/dist/chunk-KO4XH5L2.mjs +475 -0
- package/dist/chunk-LYECQKZE.mjs +49 -0
- package/dist/chunk-MKUWQB5W.mjs +297 -0
- package/dist/chunk-N3P7S5YZ.mjs +118 -0
- package/dist/chunk-NPG76WUS.mjs +348 -0
- package/dist/chunk-NX7YFFRX.mjs +124 -0
- package/dist/chunk-OZKQOI2X.mjs +334 -0
- package/dist/chunk-PPAY4WZX.mjs +40 -0
- package/dist/chunk-QS7TPMYT.mjs +411 -0
- package/dist/chunk-S2PVJK2P.mjs +517 -0
- package/dist/chunk-T5BTAJPW.mjs +725 -0
- package/dist/{chunk-EGCUJ6D6.mjs → chunk-UOL3F6XQ.mjs} +0 -12
- package/dist/chunk-VN7F33SS.mjs +108 -0
- package/dist/chunk-W4OGV22Y.mjs +57 -0
- package/dist/chunk-WJQSJ6UM.mjs +159 -0
- package/dist/chunk-XI2LXZM7.mjs +112 -0
- package/dist/chunk-YNVFRCUH.mjs +171 -0
- package/dist/chunk-YZX54L3G.mjs +33 -0
- package/dist/client.mjs +14 -0
- package/dist/comment.mjs +18 -0
- package/dist/contact.mjs +14 -0
- package/dist/document-state.mjs +8 -0
- package/dist/editor-types.mjs +0 -0
- package/dist/editorblock-to-hmblock.mjs +11 -0
- package/dist/encryption.mjs +13 -0
- package/dist/errors.mjs +11 -0
- package/dist/file-to-ipfs.mjs +13 -0
- package/dist/grobid.mjs +11 -0
- package/dist/hm-resolver.mjs +10 -0
- package/dist/hm-types.d.ts +566 -566
- package/dist/hmauth.d.ts +169 -0
- package/dist/hmauth.mjs +52 -0
- package/dist/hmblock-to-editorblock.mjs +12 -0
- package/dist/index.mjs +124 -5453
- package/dist/keyfile.mjs +19 -0
- package/dist/markdown-to-blocks.mjs +15 -0
- package/dist/pdf-to-blocks-embedded.mjs +7 -0
- package/dist/pdf-to-blocks.mjs +11 -0
- package/dist/ref.mjs +12 -0
- package/dist/resource-read.mjs +14 -0
- package/dist/signing.mjs +13 -0
- package/dist/tei-to-blocks.mjs +8 -0
- package/dist/unicode.mjs +19 -0
- package/dist/vault-local.mjs +7 -6
- package/dist/vault.mjs +3 -2
- package/package.json +18 -28
- package/src/index.ts +0 -144
package/dist/blobs.d.ts
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Blob types and signing infrastructure for the Seed Hypermedia protocol.
|
|
3
|
+
* Port of the Go blob and core packages, supporting Profile and Capability blob types.
|
|
4
|
+
*
|
|
5
|
+
* Provides two signing implementations:
|
|
6
|
+
* - NobleKeyPair: uses @noble/curves/ed25519 directly. For vault keys where raw seed storage is needed.
|
|
7
|
+
* - WebCryptoKeyPair: uses crypto.subtle with unexportable keys. For browser session keys.
|
|
8
|
+
*/
|
|
9
|
+
import { CID } from 'multiformats/cid';
|
|
10
|
+
export declare const ED25519_VARINT_PREFIX: Uint8Array<ArrayBuffer>;
|
|
11
|
+
export declare const ED25519_SIGNATURE_SIZE = 64;
|
|
12
|
+
export declare const ED25519_PUBLIC_KEY_SIZE = 32;
|
|
13
|
+
export declare const ED25519_PRINCIPAL_SIZE: number;
|
|
14
|
+
/** Packed binary public key: `<multicodec-varint><raw-key-bytes>`. */
|
|
15
|
+
export type Principal = Uint8Array;
|
|
16
|
+
/** Cryptographic signature bytes. */
|
|
17
|
+
export type Signature = Uint8Array;
|
|
18
|
+
/** Unix timestamp in milliseconds. */
|
|
19
|
+
export type Timestamp = number;
|
|
20
|
+
/** Role values for capability blobs. */
|
|
21
|
+
export type Role = 'WRITER' | 'AGENT';
|
|
22
|
+
/** Signs data and produces a cryptographic signature. */
|
|
23
|
+
export interface Signer {
|
|
24
|
+
readonly principal: Principal;
|
|
25
|
+
sign(data: Uint8Array): Promise<Signature>;
|
|
26
|
+
}
|
|
27
|
+
/** Verifies a signature against data. */
|
|
28
|
+
export interface Verifier {
|
|
29
|
+
verify(data: Uint8Array, sig: Signature): Promise<boolean>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Ed25519 key pair using @noble/curves. Stores the raw 32-byte private key seed,
|
|
33
|
+
* suitable for vault keys that need to persist the seed in encrypted storage.
|
|
34
|
+
*/
|
|
35
|
+
export declare class NobleKeyPair implements Signer {
|
|
36
|
+
readonly principal: Principal;
|
|
37
|
+
readonly publicKey: Uint8Array;
|
|
38
|
+
/** Raw 32-byte Ed25519 private key seed. Needed for vault storage. */
|
|
39
|
+
readonly seed: Uint8Array;
|
|
40
|
+
constructor(seed: Uint8Array);
|
|
41
|
+
sign(data: Uint8Array): Promise<Signature>;
|
|
42
|
+
}
|
|
43
|
+
/** Generate a random Ed25519 key pair with an accessible raw seed. */
|
|
44
|
+
export declare function generateNobleKeyPair(): NobleKeyPair;
|
|
45
|
+
/** Restore a NobleKeyPair from a stored 32-byte seed. */
|
|
46
|
+
export declare function nobleKeyPairFromSeed(seed: Uint8Array): NobleKeyPair;
|
|
47
|
+
/**
|
|
48
|
+
* Ed25519 key pair using Web Crypto. The private key is **non-exportable**,
|
|
49
|
+
* suitable for browser session keys that must not leave the browser's crypto subsystem.
|
|
50
|
+
*/
|
|
51
|
+
export declare class WebCryptoKeyPair implements Signer {
|
|
52
|
+
readonly principal: Principal;
|
|
53
|
+
readonly publicKey: Uint8Array;
|
|
54
|
+
/** The Web Crypto key pair. Exposed for LocalWebIdentity compatibility. */
|
|
55
|
+
readonly keyPair: CryptoKeyPair;
|
|
56
|
+
constructor(keyPair: CryptoKeyPair, publicKeyRaw: Uint8Array);
|
|
57
|
+
sign(data: Uint8Array): Promise<Signature>;
|
|
58
|
+
}
|
|
59
|
+
/** Generate a random Ed25519 key pair with an unexportable private key. */
|
|
60
|
+
export declare function generateWebCryptoKeyPair(): Promise<WebCryptoKeyPair>;
|
|
61
|
+
/**
|
|
62
|
+
* Verify the signature of a blob against its embedded signer Principal.
|
|
63
|
+
* Uses @noble/curves/ed25519 directly — works with any blob regardless of how it was signed.
|
|
64
|
+
*/
|
|
65
|
+
export declare function verify(blob: Blob): boolean;
|
|
66
|
+
/** Create a Principal from a raw Ed25519 public key (32 bytes). */
|
|
67
|
+
export declare function principalFromEd25519(rawPublicKey: Uint8Array): Principal;
|
|
68
|
+
/** Encode a Principal to its base58btc multibase string (starts with 'z'). */
|
|
69
|
+
export declare function principalToString(p: Principal): string;
|
|
70
|
+
/** Decode a Principal from its base58btc multibase string. */
|
|
71
|
+
export declare function principalFromString(s: string): Principal;
|
|
72
|
+
/** Check if two Principals are equal. */
|
|
73
|
+
export declare function principalEqual(a: Principal, b: Principal): boolean;
|
|
74
|
+
/** Open-ended base blob shape. Any blob type can be signed and verified through this interface. */
|
|
75
|
+
export interface Blob {
|
|
76
|
+
readonly type: string;
|
|
77
|
+
readonly signer: Principal;
|
|
78
|
+
readonly sig: Signature;
|
|
79
|
+
readonly ts: Timestamp;
|
|
80
|
+
readonly [key: string]: unknown;
|
|
81
|
+
}
|
|
82
|
+
/** Profile blob representing user identity information. */
|
|
83
|
+
export interface Profile extends Blob {
|
|
84
|
+
readonly type: 'Profile';
|
|
85
|
+
/** Points to another key acting as an identity redirect. */
|
|
86
|
+
readonly alias?: Principal;
|
|
87
|
+
/** Display name for the profile. */
|
|
88
|
+
readonly name?: string;
|
|
89
|
+
/** Icon/avatar URI (wire key is "avatar" for legacy compatibility with Go). */
|
|
90
|
+
readonly avatar?: string;
|
|
91
|
+
/** Short text description. */
|
|
92
|
+
readonly description?: string;
|
|
93
|
+
/** Account principal when signed by an agent key on behalf of the account. */
|
|
94
|
+
readonly account?: Principal;
|
|
95
|
+
}
|
|
96
|
+
/** Create a signed and encoded Profile blob. */
|
|
97
|
+
export declare function createProfile(signer: Signer, opts: {
|
|
98
|
+
/** Display name (required for non-alias profiles). */
|
|
99
|
+
name: string;
|
|
100
|
+
/** Icon/avatar URI. */
|
|
101
|
+
avatar?: string;
|
|
102
|
+
/** Short text description. */
|
|
103
|
+
description?: string;
|
|
104
|
+
/** Account principal. Omitted from encoding if it equals the signer. */
|
|
105
|
+
account?: Principal;
|
|
106
|
+
}, ts: Timestamp): Promise<Encoded<Profile>>;
|
|
107
|
+
/** Create a signed and encoded alias Profile blob (identity redirect). */
|
|
108
|
+
export declare function createProfileAlias(signer: Signer, alias: Principal, ts: Timestamp): Promise<Encoded<Profile>>;
|
|
109
|
+
/** Capability blob granting rights from issuer to delegate. */
|
|
110
|
+
export interface Capability extends Blob {
|
|
111
|
+
readonly type: 'Capability';
|
|
112
|
+
/** Public key receiving the delegation. */
|
|
113
|
+
readonly delegate: Principal;
|
|
114
|
+
/** For direct authentication against another principal. */
|
|
115
|
+
readonly audience?: Principal;
|
|
116
|
+
/** Path scope for the capability. */
|
|
117
|
+
readonly path?: string;
|
|
118
|
+
/** Access role being granted. */
|
|
119
|
+
readonly role: Role;
|
|
120
|
+
/** Human-readable label. */
|
|
121
|
+
readonly label?: string;
|
|
122
|
+
}
|
|
123
|
+
/** Create a signed and encoded Capability blob. */
|
|
124
|
+
export declare function createCapability(issuer: Signer, delegate: Principal, role: Role, ts: Timestamp, opts?: {
|
|
125
|
+
/** Path scope. */
|
|
126
|
+
path?: string;
|
|
127
|
+
/** Human-readable label. */
|
|
128
|
+
label?: string;
|
|
129
|
+
/** Audience principal for direct auth. */
|
|
130
|
+
audience?: Principal;
|
|
131
|
+
}): Promise<Encoded<Capability>>;
|
|
132
|
+
/** A decoded blob stored alongside its content-addressed CID. */
|
|
133
|
+
export interface Decoded<T extends Blob> {
|
|
134
|
+
readonly cid: CID;
|
|
135
|
+
readonly decoded: T;
|
|
136
|
+
}
|
|
137
|
+
/** A blob with its CID and decoded + encoded data. */
|
|
138
|
+
export interface Encoded<T extends Blob> extends Decoded<T> {
|
|
139
|
+
readonly data: Uint8Array;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Sign a blob with a Signer.
|
|
143
|
+
* Fills sig with zeros, CBOR-encodes, signs, replaces sig.
|
|
144
|
+
*/
|
|
145
|
+
export declare function sign<T extends Blob>(signer: Signer, blob: T): Promise<T>;
|
|
146
|
+
/** Encode a signed blob to DAG-CBOR and compute its content-addressed CID. */
|
|
147
|
+
export declare function encode<T extends Blob>(blob: T): Encoded<T>;
|
|
148
|
+
/**
|
|
149
|
+
* Decode raw CBOR bytes into a blob, verifying the CID matches.
|
|
150
|
+
* Throws if the recomputed CID doesn't match the expected one.
|
|
151
|
+
*/
|
|
152
|
+
export declare function decodeBlob<T extends Blob>(data: Uint8Array, expectedCid: CID): Encoded<T>;
|
|
153
|
+
/**
|
|
154
|
+
* @deprecated Use `NobleKeyPair` or `WebCryptoKeyPair` directly.
|
|
155
|
+
* Kept temporarily for consumers that haven't migrated yet.
|
|
156
|
+
*/
|
|
157
|
+
export type KeyPair = Signer & {
|
|
158
|
+
readonly publicKey: Uint8Array;
|
|
159
|
+
readonly keyPair?: CryptoKeyPair;
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* @deprecated Use `generateNobleKeyPair()` instead.
|
|
163
|
+
*/
|
|
164
|
+
export declare function generateKeyPair(): Promise<NobleKeyPair>;
|
|
165
|
+
/**
|
|
166
|
+
* @deprecated Use `nobleKeyPairFromSeed()` instead.
|
|
167
|
+
*/
|
|
168
|
+
export declare function keyPairFromPrivateKey(rawPrivateKey: Uint8Array): Promise<NobleKeyPair>;
|
package/dist/blobs.mjs
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ED25519_PRINCIPAL_SIZE,
|
|
3
|
+
ED25519_PUBLIC_KEY_SIZE,
|
|
4
|
+
ED25519_SIGNATURE_SIZE,
|
|
5
|
+
ED25519_VARINT_PREFIX,
|
|
6
|
+
NobleKeyPair,
|
|
7
|
+
WebCryptoKeyPair,
|
|
8
|
+
createCapability,
|
|
9
|
+
createProfile,
|
|
10
|
+
createProfileAlias,
|
|
11
|
+
decodeBlob,
|
|
12
|
+
encode,
|
|
13
|
+
generateKeyPair,
|
|
14
|
+
generateNobleKeyPair,
|
|
15
|
+
generateWebCryptoKeyPair,
|
|
16
|
+
keyPairFromPrivateKey,
|
|
17
|
+
nobleKeyPairFromSeed,
|
|
18
|
+
principalEqual,
|
|
19
|
+
principalFromEd25519,
|
|
20
|
+
principalFromString,
|
|
21
|
+
principalToString,
|
|
22
|
+
sign,
|
|
23
|
+
verify
|
|
24
|
+
} from "./chunk-FYUZZ3HT.mjs";
|
|
25
|
+
import "./chunk-3TPCJCVO.mjs";
|
|
26
|
+
import "./chunk-7P6ASYW6.mjs";
|
|
27
|
+
export {
|
|
28
|
+
ED25519_PRINCIPAL_SIZE,
|
|
29
|
+
ED25519_PUBLIC_KEY_SIZE,
|
|
30
|
+
ED25519_SIGNATURE_SIZE,
|
|
31
|
+
ED25519_VARINT_PREFIX,
|
|
32
|
+
NobleKeyPair,
|
|
33
|
+
WebCryptoKeyPair,
|
|
34
|
+
createCapability,
|
|
35
|
+
createProfile,
|
|
36
|
+
createProfileAlias,
|
|
37
|
+
decodeBlob,
|
|
38
|
+
encode,
|
|
39
|
+
generateKeyPair,
|
|
40
|
+
generateNobleKeyPair,
|
|
41
|
+
generateWebCryptoKeyPair,
|
|
42
|
+
keyPairFromPrivateKey,
|
|
43
|
+
nobleKeyPairFromSeed,
|
|
44
|
+
principalEqual,
|
|
45
|
+
principalFromEd25519,
|
|
46
|
+
principalFromString,
|
|
47
|
+
principalToString,
|
|
48
|
+
sign,
|
|
49
|
+
verify
|
|
50
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computeReplaceOps,
|
|
3
|
+
createBlocksMap,
|
|
4
|
+
hmBlockNodeToBlockNode,
|
|
5
|
+
matchBlockIds,
|
|
6
|
+
rebindTableIdentities,
|
|
7
|
+
toAPIBlockNode
|
|
8
|
+
} from "./chunk-OZKQOI2X.mjs";
|
|
9
|
+
import "./chunk-7P6ASYW6.mjs";
|
|
10
|
+
export {
|
|
11
|
+
computeReplaceOps,
|
|
12
|
+
createBlocksMap,
|
|
13
|
+
hmBlockNodeToBlockNode,
|
|
14
|
+
matchBlockIds,
|
|
15
|
+
rebindTableIdentities,
|
|
16
|
+
toAPIBlockNode
|
|
17
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
blocksToMarkdown,
|
|
3
|
+
commentToResolvedMarkdown,
|
|
4
|
+
contentToResolvedMarkdown,
|
|
5
|
+
documentToResolvedMarkdown,
|
|
6
|
+
draftFilename,
|
|
7
|
+
emitFrontmatter,
|
|
8
|
+
parseDraftFilename,
|
|
9
|
+
slugify
|
|
10
|
+
} from "./chunk-T5BTAJPW.mjs";
|
|
11
|
+
import "./chunk-SQEUO7FO.mjs";
|
|
12
|
+
import "./chunk-7P6ASYW6.mjs";
|
|
13
|
+
export {
|
|
14
|
+
blocksToMarkdown,
|
|
15
|
+
commentToResolvedMarkdown,
|
|
16
|
+
contentToResolvedMarkdown,
|
|
17
|
+
documentToResolvedMarkdown,
|
|
18
|
+
draftFilename,
|
|
19
|
+
emitFrontmatter,
|
|
20
|
+
parseDraftFilename,
|
|
21
|
+
slugify
|
|
22
|
+
};
|
package/dist/cbor.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as cborg from 'cborg';
|
|
2
|
+
export declare const encodeOpts: {
|
|
3
|
+
typeEncoders: {
|
|
4
|
+
undefined: () => null;
|
|
5
|
+
Map: (map: Map<any, any>) => null;
|
|
6
|
+
Object: (obj: any) => cborg.Token[] | null;
|
|
7
|
+
number: (num: number) => null;
|
|
8
|
+
};
|
|
9
|
+
float64: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare const code: 113;
|
|
12
|
+
export declare function encode<T = any>(obj: T): Uint8Array;
|
|
13
|
+
export declare function decode<T = any>(data: Uint8Array): T;
|
package/dist/cbor.mjs
ADDED
package/dist/change.mjs
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createChange,
|
|
3
|
+
createChangeOps,
|
|
4
|
+
createDocumentChange,
|
|
5
|
+
createDocumentChangeFromOps,
|
|
6
|
+
createGenesisChange,
|
|
7
|
+
signDocumentChange,
|
|
8
|
+
signPreparedChange,
|
|
9
|
+
visibilityToCbor
|
|
10
|
+
} from "./chunk-I3YUHKYW.mjs";
|
|
11
|
+
import "./chunk-XI2LXZM7.mjs";
|
|
12
|
+
import "./chunk-YZX54L3G.mjs";
|
|
13
|
+
import "./chunk-7P6ASYW6.mjs";
|
|
14
|
+
export {
|
|
15
|
+
createChange,
|
|
16
|
+
createChangeOps,
|
|
17
|
+
createDocumentChange,
|
|
18
|
+
createDocumentChangeFromOps,
|
|
19
|
+
createGenesisChange,
|
|
20
|
+
signDocumentChange,
|
|
21
|
+
signPreparedChange,
|
|
22
|
+
visibilityToCbor
|
|
23
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// src/base64.ts
|
|
2
|
+
import "core-js/modules/es.uint8-array.from-base64.js";
|
|
3
|
+
import "core-js/modules/es.uint8-array.to-base64.js";
|
|
4
|
+
function encode(data) {
|
|
5
|
+
return data.toBase64({ alphabet: "base64url", omitPadding: true });
|
|
6
|
+
}
|
|
7
|
+
function decode(data) {
|
|
8
|
+
return Uint8Array.fromBase64(data, { alphabet: "base64url" });
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
encode,
|
|
13
|
+
decode
|
|
14
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// src/cbor.ts
|
|
2
|
+
import * as dagCBOR from "@ipld/dag-cbor";
|
|
3
|
+
import * as cborg from "cborg";
|
|
4
|
+
var encodeOpts = {
|
|
5
|
+
...dagCBOR.encodeOptions,
|
|
6
|
+
typeEncoders: {
|
|
7
|
+
...dagCBOR.encodeOptions.typeEncoders,
|
|
8
|
+
undefined: () => null
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
var code2 = dagCBOR.code;
|
|
12
|
+
function encode2(obj) {
|
|
13
|
+
return cborg.encode(obj, encodeOpts);
|
|
14
|
+
}
|
|
15
|
+
function decode2(data) {
|
|
16
|
+
return dagCBOR.decode(data);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
encodeOpts,
|
|
21
|
+
code2 as code,
|
|
22
|
+
encode2 as encode,
|
|
23
|
+
decode2 as decode
|
|
24
|
+
};
|