@seed-hypermedia/client 0.0.67 → 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.d.ts +37 -1
- 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.d.ts +1 -1
- package/dist/index.mjs +126 -5006
- package/dist/keyfile.mjs +19 -0
- package/dist/markdown-to-blocks.d.ts +7 -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 -137
package/dist/hmauth.d.ts
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hypermedia Auth Protocol.
|
|
3
|
+
*
|
|
4
|
+
* Protocol types, validation, URL building, and constants for the
|
|
5
|
+
* Seed Hypermedia delegation flow. Used by both the Vault (server-side)
|
|
6
|
+
* and client applications.
|
|
7
|
+
*
|
|
8
|
+
* Client-side auth session management (startAuth, handleCallback, etc.)
|
|
9
|
+
* lives in the web app's auth-session module.
|
|
10
|
+
*/
|
|
11
|
+
import type { CID } from 'multiformats/cid';
|
|
12
|
+
import * as blobs from './blobs';
|
|
13
|
+
/** Configuration for the Hypermedia auth client. */
|
|
14
|
+
export interface HypermediaAuthConfig {
|
|
15
|
+
/** The URL of the Vault application. e.g. "https://example.com/vault" */
|
|
16
|
+
vaultUrl: string;
|
|
17
|
+
/** The client ID (origin of this site). Usually `window.location.origin`. */
|
|
18
|
+
clientId?: string;
|
|
19
|
+
/** The redirect URI. Defaults to current page URL (without search params). */
|
|
20
|
+
redirectUri?: string;
|
|
21
|
+
/** Optional email to pre-fill in the vault's login/registration form. */
|
|
22
|
+
email?: string;
|
|
23
|
+
/** Optional display name of this site, shown in the vault's consent UI. */
|
|
24
|
+
siteName?: string;
|
|
25
|
+
}
|
|
26
|
+
/** Stored session key with metadata. */
|
|
27
|
+
export interface StoredSession {
|
|
28
|
+
/** The CryptoKeyPair (publicKey + unextractable privateKey). */
|
|
29
|
+
keyPair: CryptoKeyPair;
|
|
30
|
+
/** The raw public key bytes (32 bytes). */
|
|
31
|
+
publicKeyRaw: Uint8Array;
|
|
32
|
+
/** The base58btc-encoded principal string. */
|
|
33
|
+
principal: string;
|
|
34
|
+
/** The vault URL this session is for. */
|
|
35
|
+
vaultUrl: string;
|
|
36
|
+
/** When this session was created. */
|
|
37
|
+
createdAt: number;
|
|
38
|
+
}
|
|
39
|
+
/** Profile metadata returned from the Vault about the delegating account. */
|
|
40
|
+
export interface AccountProfile {
|
|
41
|
+
/** Display name of the account. */
|
|
42
|
+
name?: string;
|
|
43
|
+
/** Short text description. */
|
|
44
|
+
description?: string;
|
|
45
|
+
/** Avatar URI. */
|
|
46
|
+
avatar?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface AuthResult {
|
|
49
|
+
/** The account principal (base58btc) that authorized this session. */
|
|
50
|
+
accountPrincipal: string;
|
|
51
|
+
/** The signed capability blob with raw CBOR bytes and CID. */
|
|
52
|
+
capability: blobs.Encoded<blobs.Capability>;
|
|
53
|
+
/** The signed profile blob for the account with raw CBOR bytes and CID, when provided by the vault. */
|
|
54
|
+
profile?: blobs.Encoded<blobs.Profile>;
|
|
55
|
+
/** The stored session with the unextractable signing key. */
|
|
56
|
+
session: StoredSession;
|
|
57
|
+
/** Notification server URL configured by the vault (optional). */
|
|
58
|
+
notifyServerUrl?: string;
|
|
59
|
+
}
|
|
60
|
+
/** URL parameter name for the client ID (origin of the requesting site). */
|
|
61
|
+
export declare const PARAM_CLIENT_ID = "client_id";
|
|
62
|
+
/** URL parameter name for the redirect URI. */
|
|
63
|
+
export declare const PARAM_REDIRECT_URI = "redirect_uri";
|
|
64
|
+
/** URL parameter name for the session key principal. */
|
|
65
|
+
export declare const PARAM_SESSION_KEY = "session_key";
|
|
66
|
+
/** URL parameter name for callback correlation state. */
|
|
67
|
+
export declare const PARAM_STATE = "state";
|
|
68
|
+
/** URL parameter name for request timestamp (unix ms). */
|
|
69
|
+
export declare const PARAM_TS = "ts";
|
|
70
|
+
/** URL parameter name for request proof signature. */
|
|
71
|
+
export declare const PARAM_PROOF = "proof";
|
|
72
|
+
/** URL parameter name for delegation callback data. */
|
|
73
|
+
export declare const PARAM_DATA = "data";
|
|
74
|
+
/** URL parameter name for callback errors. */
|
|
75
|
+
export declare const PARAM_ERROR = "error";
|
|
76
|
+
/** Optional URL parameter for pre-filling the user's email in the vault. */
|
|
77
|
+
export declare const PARAM_EMAIL = "email";
|
|
78
|
+
/** Optional URL parameter with the requesting site's display name, for vault UI copy. Claimed by the client — display only. */
|
|
79
|
+
export declare const PARAM_SITE_NAME = "site_name";
|
|
80
|
+
/** Vault route path for handling delegation requests. */
|
|
81
|
+
export declare const DELEGATION_PATH = "/delegate";
|
|
82
|
+
/** Encode a 32-byte Ed25519 public key as a base58btc multibase principal string. */
|
|
83
|
+
export declare function principalEncode(rawPublicKey: Uint8Array): string;
|
|
84
|
+
/** Decode a base58btc multibase principal string to the raw 32-byte Ed25519 public key. */
|
|
85
|
+
export declare function principalDecode(principal: string): Uint8Array;
|
|
86
|
+
/** Parsed and validated delegation request from URL parameters. */
|
|
87
|
+
export interface DelegationRequest {
|
|
88
|
+
/** Original delegation request URL as received by the vault, including `proof`. */
|
|
89
|
+
originalUrl: string;
|
|
90
|
+
/** The origin of the requesting site (must be HTTPS). e.g. "https://example.com". */
|
|
91
|
+
clientId: string;
|
|
92
|
+
/** Where to redirect after delegation. Must be a strict extension of clientId. */
|
|
93
|
+
redirectUri: string;
|
|
94
|
+
/** Base58btc-encoded principal of the session key to delegate to. */
|
|
95
|
+
sessionKeyPrincipal: string;
|
|
96
|
+
/** Opaque callback correlation state from the requesting site. */
|
|
97
|
+
state: string;
|
|
98
|
+
/** Request timestamp (unix ms) signed by the session key. */
|
|
99
|
+
requestTs: number;
|
|
100
|
+
/** Base64url-encoded Ed25519 signature over the request URL bytes without trailing `proof`. */
|
|
101
|
+
proof: string;
|
|
102
|
+
/** Inferred vault origin where this request was received. */
|
|
103
|
+
vaultOrigin: string;
|
|
104
|
+
/** Optional pre-filled email from the requesting site. */
|
|
105
|
+
email?: string;
|
|
106
|
+
/** Optional display name of the requesting site. Claimed by the client — display only. */
|
|
107
|
+
siteName?: string;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Validate a client ID string.
|
|
111
|
+
* Must be a valid HTTPS origin (HTTP allowed for localhost) with no path, query, or fragment.
|
|
112
|
+
*/
|
|
113
|
+
export declare function validateClientId(clientId: string): void;
|
|
114
|
+
/**
|
|
115
|
+
* Validate a redirect URI against a client ID.
|
|
116
|
+
* Must be a valid HTTPS URL (HTTP allowed for localhost) whose origin matches the client ID.
|
|
117
|
+
*/
|
|
118
|
+
export declare function validateRedirectUri(redirectUri: string, clientId: string): void;
|
|
119
|
+
/**
|
|
120
|
+
* Validate a session key principal format.
|
|
121
|
+
* Must be a base58btc multibase Ed25519 principal.
|
|
122
|
+
*/
|
|
123
|
+
export declare function validateSessionKeyPrincipal(sessionKeyPrincipal: string): void;
|
|
124
|
+
/**
|
|
125
|
+
* Validate callback correlation state format.
|
|
126
|
+
* Must be base64url and at least 16 bytes of entropy.
|
|
127
|
+
*/
|
|
128
|
+
export declare function validateState(state: string): void;
|
|
129
|
+
/**
|
|
130
|
+
* Validate and parse request timestamp.
|
|
131
|
+
* Must be a finite positive integer.
|
|
132
|
+
*/
|
|
133
|
+
export declare function validateRequestTimestamp(ts: string): number;
|
|
134
|
+
/**
|
|
135
|
+
* Parse delegation params from the URL's search params.
|
|
136
|
+
* Returns null if not a delegation request (no params present).
|
|
137
|
+
* Throws descriptive errors if params are present but invalid.
|
|
138
|
+
*/
|
|
139
|
+
export declare function parseDelegationRequest(url: URL | string): DelegationRequest | null;
|
|
140
|
+
/**
|
|
141
|
+
* Verify request proof-of-possession.
|
|
142
|
+
* Checks freshness, vault origin binding, and Ed25519 signature with the delegated session key.
|
|
143
|
+
*/
|
|
144
|
+
export declare function verifyDelegationRequestProof(request: DelegationRequest, vaultOrigin: string, now?: number): Promise<void>;
|
|
145
|
+
/** Callback data passed back to the requesting site after authorization. */
|
|
146
|
+
export interface CallbackData {
|
|
147
|
+
/** Account principal (the issuer of the capability). */
|
|
148
|
+
account: blobs.Principal;
|
|
149
|
+
/** Signed capability blob (decoded object). */
|
|
150
|
+
capability: blobs.Capability;
|
|
151
|
+
/** Content-addressed CID of the capability blob. */
|
|
152
|
+
capabilityCid: CID;
|
|
153
|
+
/** Signed profile blob (decoded object) for the delegating account, when provided by the vault. */
|
|
154
|
+
profile?: blobs.Profile;
|
|
155
|
+
/** Content-addressed CID of the profile blob, when provided by the vault. */
|
|
156
|
+
profileCid?: CID;
|
|
157
|
+
/** Notification server URL configured by the vault (optional). */
|
|
158
|
+
notifyServerUrl?: string;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Build the callback URL to redirect the user back with the signed capability.
|
|
162
|
+
* Encodes callback data as CBOR, compresses with gzip, then base64url-encodes.
|
|
163
|
+
*/
|
|
164
|
+
export declare function buildCallbackUrl(redirectUri: string, state: string, accountPrincipal: blobs.Principal, capability: blobs.Encoded<blobs.Capability>, profile: blobs.Encoded<blobs.Profile>, notifyServerUrl?: string): Promise<string>;
|
|
165
|
+
/**
|
|
166
|
+
* Create a signed delegation capability for a session key.
|
|
167
|
+
* Returns an encoded Capability blob with role "AGENT" and a label identifying the client.
|
|
168
|
+
*/
|
|
169
|
+
export declare function createDelegation(issuer: blobs.Signer, sessionKeyPrincipal: blobs.Principal, clientId: string): Promise<blobs.Encoded<blobs.Capability>>;
|
package/dist/hmauth.mjs
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DELEGATION_PATH,
|
|
3
|
+
PARAM_CLIENT_ID,
|
|
4
|
+
PARAM_DATA,
|
|
5
|
+
PARAM_EMAIL,
|
|
6
|
+
PARAM_ERROR,
|
|
7
|
+
PARAM_PROOF,
|
|
8
|
+
PARAM_REDIRECT_URI,
|
|
9
|
+
PARAM_SESSION_KEY,
|
|
10
|
+
PARAM_SITE_NAME,
|
|
11
|
+
PARAM_STATE,
|
|
12
|
+
PARAM_TS,
|
|
13
|
+
buildCallbackUrl,
|
|
14
|
+
createDelegation,
|
|
15
|
+
parseDelegationRequest,
|
|
16
|
+
principalDecode,
|
|
17
|
+
principalEncode,
|
|
18
|
+
validateClientId,
|
|
19
|
+
validateRedirectUri,
|
|
20
|
+
validateRequestTimestamp,
|
|
21
|
+
validateSessionKeyPrincipal,
|
|
22
|
+
validateState,
|
|
23
|
+
verifyDelegationRequestProof
|
|
24
|
+
} from "./chunk-DXDF36H5.mjs";
|
|
25
|
+
import "./chunk-2MD3FXKB.mjs";
|
|
26
|
+
import "./chunk-FYUZZ3HT.mjs";
|
|
27
|
+
import "./chunk-3TPCJCVO.mjs";
|
|
28
|
+
import "./chunk-7P6ASYW6.mjs";
|
|
29
|
+
export {
|
|
30
|
+
DELEGATION_PATH,
|
|
31
|
+
PARAM_CLIENT_ID,
|
|
32
|
+
PARAM_DATA,
|
|
33
|
+
PARAM_EMAIL,
|
|
34
|
+
PARAM_ERROR,
|
|
35
|
+
PARAM_PROOF,
|
|
36
|
+
PARAM_REDIRECT_URI,
|
|
37
|
+
PARAM_SESSION_KEY,
|
|
38
|
+
PARAM_SITE_NAME,
|
|
39
|
+
PARAM_STATE,
|
|
40
|
+
PARAM_TS,
|
|
41
|
+
buildCallbackUrl,
|
|
42
|
+
createDelegation,
|
|
43
|
+
parseDelegationRequest,
|
|
44
|
+
principalDecode,
|
|
45
|
+
principalEncode,
|
|
46
|
+
validateClientId,
|
|
47
|
+
validateRedirectUri,
|
|
48
|
+
validateRequestTimestamp,
|
|
49
|
+
validateSessionKeyPrincipal,
|
|
50
|
+
validateState,
|
|
51
|
+
verifyDelegationRequestProof
|
|
52
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
annotationContains,
|
|
3
|
+
hmBlockToEditorBlock,
|
|
4
|
+
hmBlocksToEditorContent
|
|
5
|
+
} from "./chunk-KO4XH5L2.mjs";
|
|
6
|
+
import "./chunk-SQEUO7FO.mjs";
|
|
7
|
+
import "./chunk-7P6ASYW6.mjs";
|
|
8
|
+
export {
|
|
9
|
+
annotationContains,
|
|
10
|
+
hmBlockToEditorBlock,
|
|
11
|
+
hmBlocksToEditorContent
|
|
12
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export type { BlockNode, SeedBlock, Annotation } from './markdown-to-blocks';
|
|
|
33
33
|
export { blocksToMarkdown, emitFrontmatter, slugify, draftFilename, parseDraftFilename, documentToResolvedMarkdown, commentToResolvedMarkdown, contentToResolvedMarkdown, } from './blocks-to-markdown';
|
|
34
34
|
export type { ResolvedMarkdownOptions } from './blocks-to-markdown';
|
|
35
35
|
export type { BlocksToMarkdownOptions } from './blocks-to-markdown';
|
|
36
|
-
export { createBlocksMap, matchBlockIds, computeReplaceOps, hmBlockNodeToBlockNode } from './block-diff';
|
|
36
|
+
export { createBlocksMap, matchBlockIds, computeReplaceOps, hmBlockNodeToBlockNode, rebindTableIdentities, toAPIBlockNode, } from './block-diff';
|
|
37
37
|
export type { APIBlockNode, APIBlock } from './block-diff';
|
|
38
38
|
export { autoLinkChildToParent, createAutoLinkOps, documentContainsLinkToChild, documentHasSelfQuery, shouldAutoLinkParent, } from './auto-link';
|
|
39
39
|
export type { AutoLinkChildToParentOptions } from './auto-link';
|