@synonymdev/pubky 0.12.0 → 0.14.0

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 (5) hide show
  1. package/index.cjs +653 -496
  2. package/index.js +654 -497
  3. package/package.json +1 -1
  4. package/pubky.d.ts +218 -134
  5. package/pubky_bg.wasm +0 -0
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@synonymdev/pubky",
3
3
  "type": "module",
4
4
  "description": "Decentralized identity, auth flows, and user-owned storage",
5
- "version": "0.12.0",
5
+ "version": "0.14.0",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
package/pubky.d.ts CHANGED
@@ -4,14 +4,14 @@
4
4
  * An enum representing the available verbosity levels of the logger.
5
5
  */
6
6
 
7
- type Level = "error" | "warn" | "info" | "debug" | "trace";
7
+ export type Level = "error" | "warn" | "info" | "debug" | "trace";
8
8
  /**
9
9
  * The `ReadableStreamType` enum.
10
10
  *
11
11
  * *This API requires the following crate features to be activated: `ReadableStreamType`*
12
12
  */
13
13
 
14
- type ReadableStreamType = "bytes";
14
+ export type ReadableStreamType = "bytes";
15
15
  /**
16
16
  * A union type of all possible machine-readable codes for the `name` property
17
17
  * of a {@link PubkyError}.
@@ -88,6 +88,12 @@ export interface PubkyClientConfig {
88
88
  * Configuration on how to access pkarr packets on the mainline DHT.
89
89
  */
90
90
  pkarr?: PkarrConfig;
91
+ /**
92
+ * Maximum raw HTTP error-body bytes to capture. Defaults to 4096; zero skips the body.
93
+ * UTF-8 decoding can produce up to three times as many bytes of text, plus the
94
+ * truncation marker. This does not cap final message size or total memory use.
95
+ */
96
+ maxErrorBodyBytes?: number;
91
97
  }
92
98
 
93
99
  /**
@@ -447,13 +453,6 @@ export class BrowserSessionStore {
447
453
  private constructor();
448
454
  free(): void;
449
455
  [Symbol.dispose](): void;
450
- /**
451
- * Clear all local stored session records for this origin.
452
- *
453
- * Delegated keys referenced by those stored session records are removed.
454
- * Delegated keys that only belong to pending grant flows are preserved.
455
- */
456
- clear(): Promise<void>;
457
456
  /**
458
457
  * Clear all browser auth persistence owned by this SDK origin.
459
458
  *
@@ -463,6 +462,13 @@ export class BrowserSessionStore {
463
462
  * grants or immediately invalidate already-live in-memory sessions.
464
463
  */
465
464
  clearAll(): Promise<void>;
465
+ /**
466
+ * Clear all local stored session records for this origin.
467
+ *
468
+ * Delegated keys referenced by those stored session records are removed.
469
+ * Delegated keys that only belong to pending grant flows are preserved.
470
+ */
471
+ clear(): Promise<void>;
466
472
  /**
467
473
  * Whether IndexedDB is available for durable session persistence.
468
474
  */
@@ -510,19 +516,20 @@ export class Client {
510
516
  * Create a Pubky HTTP client.
511
517
  *
512
518
  * @param {PubkyClientConfig} [config]
513
- * Optional transport overrides:
514
- * `{ pkarr?: { relays?: string[], request_timeout?: number } }`.
519
+ * Optional error-body limit and PKARR overrides:
520
+ * `{ maxErrorBodyBytes?: number, pkarr?: { relays?: string[], requestTimeout?: number } }`.
515
521
  *
516
522
  * @returns {Client}
517
523
  * A configured low-level client. Prefer `new Pubky().client` unless you
518
- * need custom relays/timeouts.
524
+ * need custom relays, timeouts or error-body limits.
519
525
  *
520
526
  * @throws {InvalidInput}
521
- * If any PKARR relay URL is invalid.
527
+ * If a relay URL is invalid or the error-body limit is not an integer in 0..=4294967295.
522
528
  *
523
529
  * @example
524
530
  * const client = new Client({
525
- * pkarr: { relays: ["https://relay1/","https://relay2/"], request_timeout: 8000 }
531
+ * maxErrorBodyBytes: 1024,
532
+ * pkarr: { relays: ["https://relay1/","https://relay2/"], requestTimeout: 8000 }
526
533
  * });
527
534
  * const pubky = Pubky.withClient(client);
528
535
  */
@@ -559,16 +566,6 @@ export class CookieSession {
559
566
  private constructor();
560
567
  free(): void;
561
568
  [Symbol.dispose](): void;
562
- /**
563
- * Export session metadata for legacy cookie restore.
564
- *
565
- * The returned string contains no secrets; the browser cookie jar must
566
- * still hold the HTTP-only cookie.
567
- *
568
- * @returns {string}
569
- * @deprecated Use `GrantSession.exportLocalSecret()` instead.
570
- */
571
- export(): string;
572
569
  /**
573
570
  * Export the cookie secret needed to restore this cookie session.
574
571
  *
@@ -579,6 +576,16 @@ export class CookieSession {
579
576
  * @deprecated Use `GrantSession.exportLocalSecret()` instead.
580
577
  */
581
578
  exportSecret(): Promise<string>;
579
+ /**
580
+ * Export session metadata for legacy cookie restore.
581
+ *
582
+ * The returned string contains no secrets; the browser cookie jar must
583
+ * still hold the HTTP-only cookie.
584
+ *
585
+ * @returns {string}
586
+ * @deprecated Use `GrantSession.exportLocalSecret()` instead.
587
+ */
588
+ export(): string;
582
589
  }
583
590
 
584
591
  /**
@@ -654,6 +661,7 @@ export class Event {
654
661
  * Builder for creating an event stream subscription.
655
662
  *
656
663
  * Construct via `Pubky.eventStreamForUser()` or `Pubky.eventStreamFor()`.
664
+ * Configuration methods consume this builder unless documented otherwise.
657
665
  *
658
666
  * @example
659
667
  * ```typescript
@@ -686,6 +694,8 @@ export class EventStreamBuilder {
686
694
  *
687
695
  * Each user can have an independent cursor position. If a user already exists,
688
696
  * their cursor value is overwritten.
697
+ * Updates this builder and returns a copy for chaining. Rejected input
698
+ * leaves this builder unchanged.
689
699
  *
690
700
  * @param {Array<[string, string | null]>} users - Array of [z32PublicKey, cursor] tuples
691
701
  * @returns {EventStreamBuilder} - Builder for chaining
@@ -744,6 +754,20 @@ export class EventStreamBuilder {
744
754
  * @returns {EventStreamBuilder} - Builder for chaining
745
755
  */
746
756
  live(): EventStreamBuilder;
757
+ /**
758
+ * Set a client-side byte limit for SSE payloads. Unbounded by default.
759
+ * Limits accumulated data (including newlines joining data fields), each
760
+ * event name, and each ID separately in historical and live streams.
761
+ * Comments, unknown fields and framing bytes are excluded.
762
+ * There is no total block or stream byte limit.
763
+ * Overflow cancels the response and errors the ReadableStream.
764
+ * Updates this builder and returns a copy for chaining. Rejected input
765
+ * leaves this builder unchanged.
766
+ *
767
+ * @param {number} limit - Integer in 1..=4294967295.
768
+ * @throws {InvalidInput} If the limit is not a positive 32-bit integer.
769
+ */
770
+ maxEventBytes(limit: number): EventStreamBuilder;
747
771
  /**
748
772
  * Filter events by path. Call once per path to receive the
749
773
  * union of several scopes (e.g. `/pub/` plus a private `/priv/app/`).
@@ -827,6 +851,15 @@ export class GrantAuthFlow {
827
851
  * Block until the user approves on their signer device; returns a grant-backed `Session`.
828
852
  */
829
853
  awaitApproval(): Promise<Session>;
854
+ /**
855
+ * Resume a previously saved pending delegated grant auth flow.
856
+ *
857
+ * Runtime: delegated grant keys require a secure browser context with
858
+ * WebCrypto `crypto.subtle` and IndexedDB. The saved `keyId` must still
859
+ * exist in IndexedDB for the same origin. Unsupported runtimes reject with
860
+ * `ClientStateError`.
861
+ */
862
+ static resumeDelegated(saved_state: string): Promise<GrantAuthFlow>;
830
863
  /**
831
864
  * Resume a previously saved pending grant auth flow (standalone).
832
865
  * Prefer `pubky.resumeGrantAuthFlow()` to reuse a facade client.
@@ -838,15 +871,6 @@ export class GrantAuthFlow {
838
871
  * @returns {GrantAuthFlow} A flow reconnected to the original relay channel.
839
872
  */
840
873
  static resume(saved_state: string): GrantAuthFlow;
841
- /**
842
- * Resume a previously saved pending delegated grant auth flow.
843
- *
844
- * Runtime: delegated grant keys require a secure browser context with
845
- * WebCrypto `crypto.subtle` and IndexedDB. The saved `keyId` must still
846
- * exist in IndexedDB for the same origin. Unsupported runtimes reject with
847
- * `ClientStateError`.
848
- */
849
- static resumeDelegated(saved_state: string): Promise<GrantAuthFlow>;
850
874
  /**
851
875
  * Save sensitive state required to resume this delegated pending grant flow.
852
876
  *
@@ -862,6 +886,17 @@ export class GrantAuthFlow {
862
886
  * `pubky.resumeGrantAuthFlow()`.
863
887
  */
864
888
  saveLocal(): string;
889
+ /**
890
+ * Start a browser delegated grant-backed flow.
891
+ *
892
+ * The SDK creates a fresh non-extractable WebCrypto Ed25519 key in
893
+ * IndexedDB and uses that key for grant Proof-of-Possession signing.
894
+ *
895
+ * Runtime: delegated grant keys require a secure browser context with
896
+ * WebCrypto `crypto.subtle` and IndexedDB. Unsupported runtimes reject
897
+ * with `ClientStateError`.
898
+ */
899
+ static startDelegated(capabilities: Capabilities, kind: AuthFlowKind, options: GrantAuthFlowOptions): Promise<GrantAuthFlow>;
865
900
  /**
866
901
  * Start a grant-backed flow with a new DHT client.
867
902
  * Prefer `pubky.startGrantAuthFlow()` to reuse a facade DHT client.
@@ -881,17 +916,6 @@ export class GrantAuthFlow {
881
916
  * then `awaitApproval()` to receive a grant-backed `Session`.
882
917
  */
883
918
  static start(capabilities: Capabilities, kind: AuthFlowKind, options: GrantAuthFlowOptions): GrantAuthFlow;
884
- /**
885
- * Start a browser delegated grant-backed flow.
886
- *
887
- * The SDK creates a fresh non-extractable WebCrypto Ed25519 key in
888
- * IndexedDB and uses that key for grant Proof-of-Possession signing.
889
- *
890
- * Runtime: delegated grant keys require a secure browser context with
891
- * WebCrypto `crypto.subtle` and IndexedDB. Unsupported runtimes reject
892
- * with `ClientStateError`.
893
- */
894
- static startDelegated(capabilities: Capabilities, kind: AuthFlowKind, options: GrantAuthFlowOptions): Promise<GrantAuthFlow>;
895
919
  /**
896
920
  * Non-blocking single poll step (advanced UIs).
897
921
  *
@@ -1060,6 +1084,18 @@ export class IntoUnderlyingByteSource {
1060
1084
  readonly type: ReadableStreamType;
1061
1085
  }
1062
1086
 
1087
+ declare class IntoUnderlyingByteSource2 {
1088
+ private constructor();
1089
+ free(): void;
1090
+ [Symbol.dispose](): void;
1091
+ cancel(): void;
1092
+ pull(controller: ReadableByteStreamController): Promise<any>;
1093
+ start(controller: ReadableByteStreamController): void;
1094
+ readonly autoAllocateChunkSize: number;
1095
+ readonly type: ReadableStreamType;
1096
+ }
1097
+ export type { IntoUnderlyingByteSource2 };
1098
+
1063
1099
  export class IntoUnderlyingSink {
1064
1100
  private constructor();
1065
1101
  free(): void;
@@ -1069,6 +1105,16 @@ export class IntoUnderlyingSink {
1069
1105
  write(chunk: any): Promise<any>;
1070
1106
  }
1071
1107
 
1108
+ declare class IntoUnderlyingSink2 {
1109
+ private constructor();
1110
+ free(): void;
1111
+ [Symbol.dispose](): void;
1112
+ abort(reason: any): Promise<any>;
1113
+ close(): Promise<any>;
1114
+ write(chunk: any): Promise<any>;
1115
+ }
1116
+ export type { IntoUnderlyingSink2 };
1117
+
1072
1118
  export class IntoUnderlyingSource {
1073
1119
  private constructor();
1074
1120
  free(): void;
@@ -1077,6 +1123,15 @@ export class IntoUnderlyingSource {
1077
1123
  pull(controller: ReadableStreamDefaultController): Promise<any>;
1078
1124
  }
1079
1125
 
1126
+ declare class IntoUnderlyingSource2 {
1127
+ private constructor();
1128
+ free(): void;
1129
+ [Symbol.dispose](): void;
1130
+ cancel(): void;
1131
+ pull(controller: ReadableStreamDefaultController): Promise<any>;
1132
+ }
1133
+ export type { IntoUnderlyingSource2 };
1134
+
1080
1135
  export class Keypair {
1081
1136
  private constructor();
1082
1137
  free(): void;
@@ -1124,14 +1179,6 @@ export class Pkdns {
1124
1179
  * PKDNS actor with publishing enabled (requires a keypair).
1125
1180
  */
1126
1181
  static fromKeypair(keypair: Keypair): Pkdns;
1127
- /**
1128
- * Resolve the homeserver for **this** user (requires keypair).
1129
- *
1130
- * @returns {Promise<PublicKey|undefined>} Homeserver public key or `undefined` if not found.
1131
- * @throws When no keypair is attached, Pkarr resolution fails, or a resolved `_pubky` target
1132
- * is malformed.
1133
- */
1134
- getHomeserver(): Promise<PublicKey | undefined>;
1135
1182
  /**
1136
1183
  * Resolve the homeserver for a given public key (read-only).
1137
1184
  *
@@ -1141,6 +1188,14 @@ export class Pkdns {
1141
1188
  * @throws When Pkarr resolution fails or a resolved `_pubky` target is malformed.
1142
1189
  */
1143
1190
  getHomeserverOf(pubky: PublicKey): Promise<PublicKey | undefined>;
1191
+ /**
1192
+ * Resolve the homeserver for **this** user (requires keypair).
1193
+ *
1194
+ * @returns {Promise<PublicKey|undefined>} Homeserver public key or `undefined` if not found.
1195
+ * @throws When no keypair is attached, Pkarr resolution fails, or a resolved `_pubky` target
1196
+ * is malformed.
1197
+ */
1198
+ getHomeserver(): Promise<PublicKey | undefined>;
1144
1199
  /**
1145
1200
  * Read-only PKDNS actor (no keypair; resolve only).
1146
1201
  */
@@ -1172,19 +1227,19 @@ export class Pubky {
1172
1227
  free(): void;
1173
1228
  [Symbol.dispose](): void;
1174
1229
  /**
1175
- * Create an event stream builder for a specific homeserver.
1230
+ * Create an event stream builder for a single user.
1176
1231
  *
1177
- * Use this when you already know the homeserver pubkey. This avoids
1178
- * Pkarr resolution overhead. Obtain a homeserver pubkey via `getHomeserverOf()`.
1232
+ * This is the simplest way to subscribe to events for one user. The homeserver
1233
+ * is automatically resolved from the user's Pkarr record.
1179
1234
  *
1180
- * @param {PublicKey} homeserver - The homeserver public key
1235
+ * @param {PublicKey} user - The user's public key
1236
+ * @param {string | null} cursor - Optional cursor position to start from
1181
1237
  * @returns {EventStreamBuilder} - Builder for configuring and subscribing to the stream
1182
1238
  *
1183
1239
  * @example
1184
1240
  * ```typescript
1185
- * const homeserver = await pubky.getHomeserverOf(user1);
1186
- * const stream = await pubky.eventStreamFor(homeserver)
1187
- * .addUsers([[user1.z32(), null], [user2.z32(), null]])
1241
+ * const user = PublicKey.from("o1gg96ewuojmopcjbz8895478wdtxtzzuxnfjjz8o8e77csa1ngo");
1242
+ * const stream = await pubky.eventStreamForUser(user, null)
1188
1243
  * .live()
1189
1244
  * .subscribe();
1190
1245
  *
@@ -1193,21 +1248,21 @@ export class Pubky {
1193
1248
  * }
1194
1249
  * ```
1195
1250
  */
1196
- eventStreamFor(homeserver: PublicKey): EventStreamBuilder;
1251
+ eventStreamForUser(user: PublicKey, cursor?: string | null): EventStreamBuilder;
1197
1252
  /**
1198
- * Create an event stream builder for a single user.
1253
+ * Create an event stream builder for a specific homeserver.
1199
1254
  *
1200
- * This is the simplest way to subscribe to events for one user. The homeserver
1201
- * is automatically resolved from the user's Pkarr record.
1255
+ * Use this when you already know the homeserver pubkey. This avoids
1256
+ * Pkarr resolution overhead. Obtain a homeserver pubkey via `getHomeserverOf()`.
1202
1257
  *
1203
- * @param {PublicKey} user - The user's public key
1204
- * @param {string | null} cursor - Optional cursor position to start from
1258
+ * @param {PublicKey} homeserver - The homeserver public key
1205
1259
  * @returns {EventStreamBuilder} - Builder for configuring and subscribing to the stream
1206
1260
  *
1207
1261
  * @example
1208
1262
  * ```typescript
1209
- * const user = PublicKey.from("o1gg96ewuojmopcjbz8895478wdtxtzzuxnfjjz8o8e77csa1ngo");
1210
- * const stream = await pubky.eventStreamForUser(user, null)
1263
+ * const homeserver = await pubky.getHomeserverOf(user1);
1264
+ * const stream = await pubky.eventStreamFor(homeserver)
1265
+ * .addUsers([[user1.z32(), null], [user2.z32(), null]])
1211
1266
  * .live()
1212
1267
  * .subscribe();
1213
1268
  *
@@ -1216,7 +1271,7 @@ export class Pubky {
1216
1271
  * }
1217
1272
  * ```
1218
1273
  */
1219
- eventStreamForUser(user: PublicKey, cursor?: string | null): EventStreamBuilder;
1274
+ eventStreamFor(homeserver: PublicKey): EventStreamBuilder;
1220
1275
  /**
1221
1276
  * Resolve the homeserver for a given public key (read-only).
1222
1277
  *
@@ -1530,13 +1585,6 @@ export class PublicStorage {
1530
1585
  * @returns {Promise<boolean>}
1531
1586
  */
1532
1587
  exists(address: Address): Promise<boolean>;
1533
- /**
1534
- * Perform a streaming `GET` and expose the raw `Response` object.
1535
- *
1536
- * @param {Address} address
1537
- * @returns {Promise<Response>}
1538
- */
1539
- get(address: Address): Promise<Response>;
1540
1588
  /**
1541
1589
  * Fetch bytes from an addressed path.
1542
1590
  *
@@ -1558,6 +1606,13 @@ export class PublicStorage {
1558
1606
  * @returns {Promise<string>}
1559
1607
  */
1560
1608
  getText(address: Address): Promise<string>;
1609
+ /**
1610
+ * Perform a streaming `GET` and expose the raw `Response` object.
1611
+ *
1612
+ * @param {Address} address
1613
+ * @returns {Promise<Response>}
1614
+ */
1615
+ get(address: Address): Promise<Response>;
1561
1616
  /**
1562
1617
  * List a directory. Results are `pubky://…` identifier URLs.
1563
1618
  *
@@ -1605,18 +1660,6 @@ export class Session {
1605
1660
  private constructor();
1606
1661
  free(): void;
1607
1662
  [Symbol.dispose](): void;
1608
- /**
1609
- * Export the session metadata so it can be restored after a tab refresh.
1610
- *
1611
- * The export string contains **no secrets**; it only serializes the public `SessionInfo`.
1612
- * Browsers remain responsible for persisting the HTTP-only session cookie.
1613
- *
1614
- * @returns {string}
1615
- * A base64 string to store (e.g. in `localStorage`).
1616
- *
1617
- * @deprecated Use `GrantSession.exportLocalSecret()` instead.
1618
- */
1619
- export(): string;
1620
1663
  /**
1621
1664
  * Export the local secret material needed to restore this session.
1622
1665
  *
@@ -1632,6 +1675,18 @@ export class Session {
1632
1675
  * A secret token that can be passed to `pubky.restoreSession()`.
1633
1676
  */
1634
1677
  exportLocalSecret(): Promise<string>;
1678
+ /**
1679
+ * Export the session metadata so it can be restored after a tab refresh.
1680
+ *
1681
+ * The export string contains **no secrets**; it only serializes the public `SessionInfo`.
1682
+ * Browsers remain responsible for persisting the HTTP-only session cookie.
1683
+ *
1684
+ * @returns {string}
1685
+ * A base64 string to store (e.g. in `localStorage`).
1686
+ *
1687
+ * @deprecated Use `GrantSession.exportLocalSecret()` instead.
1688
+ */
1689
+ export(): string;
1635
1690
  /**
1636
1691
  * Restore a session from an `export()` string.
1637
1692
  *
@@ -1714,94 +1769,123 @@ export class SessionInfo {
1714
1769
 
1715
1770
  /**
1716
1771
  * Read/write storage scoped to **your** session (absolute paths: `/pub/...` or `/priv/...`).
1772
+ *
1773
+ * Failures reject with a {@link PubkyError}. Path validation, transport, and HTTP
1774
+ * failures use `RequestError`; only HTTP errors include `data.statusCode`.
1775
+ * URL parsing failures use `InvalidInput`. Credential preparation, refresh,
1776
+ * and reading response bodies can also fail.
1777
+ *
1778
+ * Only {@link SessionStorage.exists} and {@link SessionStorage.stats} treat
1779
+ * HTTP 404/410 as missing. Other HTTP failures, including 401/403 and 5xx, reject.
1780
+ * Writes require write permission and can fail on directory targets (400),
1781
+ * file/directory path conflicts (409), or exceeded quotas (507).
1717
1782
  */
1718
1783
  export class SessionStorage {
1719
1784
  private constructor();
1720
1785
  free(): void;
1721
1786
  [Symbol.dispose](): void;
1722
1787
  /**
1723
- * Delete a path (file or empty directory).
1788
+ * Delete a file. Directory targets are unsupported.
1724
1789
  *
1725
- * @param {Path} path
1790
+ * @param {Path} path File path; must not end with `/`.
1726
1791
  * @returns {Promise<void>}
1792
+ * @throws {PubkyError} Missing file (404), directory target (400), or shared errors
1793
+ * (see {@link SessionStorage}).
1727
1794
  */
1728
1795
  delete(path: Path): Promise<void>;
1729
1796
  /**
1730
- * Check existence.
1797
+ * Check existence with a HEAD request.
1731
1798
  *
1732
1799
  * @param {Path} path
1733
- * @returns {Promise<boolean>}
1800
+ * @returns {Promise<boolean>} `true` on success; `false` for HTTP 404/410.
1801
+ * @throws {PubkyError} All other failures (see {@link SessionStorage}).
1734
1802
  */
1735
1803
  exists(path: Path): Promise<boolean>;
1736
- /**
1737
- * GET a streaming response for an absolute session path.
1738
- *
1739
- * @param {Path} path
1740
- * @returns {Promise<Response>}
1741
- */
1742
- get(path: Path): Promise<Response>;
1743
1804
  /**
1744
1805
  * GET bytes from an absolute session path.
1745
1806
  *
1746
1807
  * @param {Path} path
1747
- * @returns {Promise<Uint8Array>}
1808
+ * @returns {Promise<Uint8Array>} The complete response body.
1809
+ * @throws {PubkyError} Missing resource (404/410) or shared errors (see {@link SessionStorage}).
1748
1810
  */
1749
1811
  getBytes(path: Path): Promise<Uint8Array>;
1750
1812
  /**
1751
1813
  * GET JSON from an absolute session path.
1752
1814
  *
1753
1815
  * @param {Path} path
1754
- * @returns {Promise<any>}
1816
+ * @returns {Promise<any>} The parsed JSON value.
1817
+ * @throws {PubkyError} Missing resource (404/410), JSON parsing/conversion failures,
1818
+ * or shared errors (see {@link SessionStorage}).
1755
1819
  */
1756
1820
  getJson(path: Path): Promise<any>;
1757
1821
  /**
1758
1822
  * GET text from an absolute session path.
1759
1823
  *
1760
1824
  * @param {Path} path
1761
- * @returns {Promise<string>}
1825
+ * @returns {Promise<string>} The complete response body decoded as text.
1826
+ * @throws {PubkyError} Missing resource (404/410) or shared errors (see {@link SessionStorage}).
1762
1827
  */
1763
1828
  getText(path: Path): Promise<string>;
1764
1829
  /**
1765
- * List a directory (absolute session path). Returns `pubky://…` URLs.
1830
+ * GET a streaming response for an absolute session path.
1831
+ *
1832
+ * Reading the returned response body can still fail after this resolves.
1833
+ *
1834
+ * @param {Path} path
1835
+ * @returns {Promise<Response>} A successful response with an unread body.
1836
+ * @throws {PubkyError} Missing resource (404/410) or other request/response errors.
1837
+ * See {@link SessionStorage} for shared errors.
1838
+ */
1839
+ get(path: Path): Promise<Response>;
1840
+ /**
1841
+ * List a directory (absolute session path).
1766
1842
  *
1767
1843
  * @param {Path} path Must end with `/`.
1768
- * @param {string|null=} cursor Optional suffix or full URL to start **after**.
1844
+ * @param {string|null=} cursor Optional last entry URL to start **after**.
1769
1845
  * @param {boolean=} reverse Default `false`.
1770
1846
  * @param {number=} limit Optional result limit.
1771
1847
  * @param {boolean=} shallow Default `false`.
1772
- * @returns {Promise<string[]>}
1848
+ * @returns {Promise<string[]>} `pubky://…` entry URLs, or an empty array for an empty page.
1849
+ * @throws {PubkyError} Missing directory (404), invalid cursor (400), invalid response
1850
+ * entries, or shared errors (see {@link SessionStorage}).
1773
1851
  */
1774
1852
  list(path: Path, cursor?: string | null, reverse?: boolean | null, limit?: number | null, shallow?: boolean | null): Promise<string[]>;
1775
1853
  /**
1776
- * PUT binary at an absolute session path.
1854
+ * Create or replace a file with binary data at an absolute session path.
1777
1855
  *
1778
- * @param {Path} path
1779
- * @param {Uint8Array} bytes
1856
+ * @param {Path} path File path; must not end with `/`.
1857
+ * @param {Uint8Array} body
1780
1858
  * @returns {Promise<void>}
1859
+ * @throws {PubkyError} Upload or shared write/request errors (see {@link SessionStorage}).
1781
1860
  */
1782
1861
  putBytes(path: Path, body: Uint8Array): Promise<void>;
1783
1862
  /**
1784
- * PUT JSON at an absolute session path.
1863
+ * Create or replace a file with JSON at an absolute session path.
1785
1864
  *
1786
- * @param {Path} path Absolute path (e.g. `"/pub/app/data.json"`).
1787
- * @param {any} value JSON-serializable value.
1865
+ * @param {Path} path File path (e.g. `"/pub/app/data.json"`); must not end with `/`.
1866
+ * @param {any} body JSON-serializable value.
1788
1867
  * @returns {Promise<void>}
1868
+ * @throws {PubkyError} `InvalidInput` if `body` cannot be converted to JSON;
1869
+ * otherwise serialization, upload, or shared write/request errors (see {@link SessionStorage}).
1789
1870
  */
1790
1871
  putJson(path: Path, body: any): Promise<void>;
1791
1872
  /**
1792
- * PUT text at an absolute session path.
1873
+ * Create or replace a file with text at an absolute session path.
1793
1874
  *
1794
- * @param {Path} path
1795
- * @param {string} text
1875
+ * @param {Path} path File path; must not end with `/`.
1876
+ * @param {string} body
1796
1877
  * @returns {Promise<void>}
1878
+ * @throws {PubkyError} Upload or shared write/request errors (see {@link SessionStorage}).
1797
1879
  */
1798
1880
  putText(path: Path, body: string): Promise<void>;
1799
1881
  /**
1800
1882
  * Get metadata for an absolute, session-scoped path (e.g. `"/pub/app/file.json"`).
1801
1883
  *
1884
+ * On success, missing or unparseable metadata headers leave their properties absent.
1885
+ *
1802
1886
  * @param {Path} path Absolute path under your user (starts with `/`).
1803
- * @returns {Promise<ResourceStats|undefined>} `undefined` if the resource does not exist.
1804
- * @throws {PubkyError} On invalid input or transport/server errors.
1887
+ * @returns {Promise<ResourceStats|undefined>} Metadata on success; `undefined` for HTTP 404/410.
1888
+ * @throws {PubkyError} All other failures (see {@link SessionStorage}).
1805
1889
  */
1806
1890
  stats(path: Path): Promise<ResourceStats | undefined>;
1807
1891
  }
@@ -1836,39 +1920,45 @@ export class Signer {
1836
1920
  */
1837
1921
  handleDeepLink(pubkyauth_url: string): Promise<void>;
1838
1922
  /**
1839
- * Fast sign-in for a returning user. Publishes PKDNS in the background.
1923
+ * Blocking sign-in. Waits for PKDNS publish to complete (slower; safer).
1840
1924
  *
1841
1925
  * Creates a valid grant-backed homeserver Session with root capabilities.
1842
1926
  * `clientId` is shown in the user's grant/session list.
1843
1927
  * @param {string} clientId App identifier, typically a domain.
1844
1928
  *
1845
1929
  * @returns {Promise<Session>}
1930
+ */
1931
+ signinBlocking(client_id: string): Promise<Session>;
1932
+ /**
1933
+ * Legacy cookie blocking signin. Prefer `signinBlocking(clientId)`.
1846
1934
  *
1847
- * @throws {PubkyError}
1935
+ * @deprecated Prefer `signinBlocking(clientId)`.
1848
1936
  */
1849
- signin(client_id: string): Promise<Session>;
1937
+ signinCookieBlocking(): Promise<Session>;
1850
1938
  /**
1851
- * Blocking sign-in. Waits for PKDNS publish to complete (slower; safer).
1939
+ * Legacy cookie signin. Prefer `signin(clientId)`.
1940
+ *
1941
+ * @deprecated Prefer `signin(clientId)`.
1942
+ */
1943
+ signinCookie(): Promise<Session>;
1944
+ /**
1945
+ * Fast sign-in for a returning user. Publishes PKDNS in the background.
1852
1946
  *
1853
1947
  * Creates a valid grant-backed homeserver Session with root capabilities.
1854
1948
  * `clientId` is shown in the user's grant/session list.
1855
1949
  * @param {string} clientId App identifier, typically a domain.
1856
1950
  *
1857
1951
  * @returns {Promise<Session>}
1858
- */
1859
- signinBlocking(client_id: string): Promise<Session>;
1860
- /**
1861
- * Legacy cookie signin. Prefer `signin(clientId)`.
1862
1952
  *
1863
- * @deprecated Prefer `signin(clientId)`.
1953
+ * @throws {PubkyError}
1864
1954
  */
1865
- signinCookie(): Promise<Session>;
1955
+ signin(client_id: string): Promise<Session>;
1866
1956
  /**
1867
- * Legacy cookie blocking signin. Prefer `signinBlocking(clientId)`.
1957
+ * Legacy cookie signup. Prefer `signup()` plus `signin(clientId)`.
1868
1958
  *
1869
- * @deprecated Prefer `signinBlocking(clientId)`.
1959
+ * @deprecated Prefer `signup()` followed by `signin(clientId)`.
1870
1960
  */
1871
- signinCookieBlocking(): Promise<Session>;
1961
+ signupCookie(homeserver: PublicKey, signup_token?: string | null): Promise<Session>;
1872
1962
  /**
1873
1963
  * Sign up at a homeserver.
1874
1964
  *
@@ -1883,12 +1973,6 @@ export class Signer {
1883
1973
  * - `RequestError` (network/server)
1884
1974
  */
1885
1975
  signup(homeserver: PublicKey, signup_token?: string | null): Promise<void>;
1886
- /**
1887
- * Legacy cookie signup. Prefer `signup()` plus `signin(clientId)`.
1888
- *
1889
- * @deprecated Prefer `signup()` followed by `signin(clientId)`.
1890
- */
1891
- signupCookie(homeserver: PublicKey, signup_token?: string | null): Promise<Session>;
1892
1976
  /**
1893
1977
  * Get a PKDNS actor bound to this signer's client & keypair (publishing enabled).
1894
1978
  *
package/pubky_bg.wasm CHANGED
Binary file