@drakkar.software/starfish-client 3.0.0-alpha.1 → 3.0.0-alpha.11

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/logger.d.ts CHANGED
@@ -5,6 +5,9 @@ export interface SyncMetrics {
5
5
  conflictCount?: number;
6
6
  retryCount?: number;
7
7
  cacheHit?: boolean;
8
+ /** Elements an append-log pull dropped under `onElementError: "skip"`
9
+ * (failed verification/decryption). Omitted when none were skipped. */
10
+ skippedCount?: number;
8
11
  }
9
12
  /** Structured logger for sync operations. */
10
13
  export interface SyncLogger {
@@ -1,5 +1,5 @@
1
1
  import type { StoreApi } from "zustand/vanilla";
2
- import type { StarfishStore } from "./bindings/zustand.js";
2
+ import type { StarfishStore, StarfishLogStore } from "./bindings/zustand.js";
3
3
  /**
4
4
  * Minimal interface matching React Native's `AppState` module.
5
5
  * Pass `AppState` from `react-native` directly.
@@ -69,3 +69,30 @@ export interface MobileLifecycleOptions {
69
69
  * @returns A cleanup function that removes all event listeners.
70
70
  */
71
71
  export declare function createMobileLifecycle(store: StoreApi<StarfishStore>, deps: MobileLifecycleDeps, options?: MobileLifecycleOptions): () => void;
72
+ export interface AppendLogLifecycleOptions {
73
+ /**
74
+ * Pull new elements when the app returns to the foreground.
75
+ * Only pulls if the store is online and not already loading.
76
+ * Default: `true`.
77
+ */
78
+ pullOnForeground?: boolean;
79
+ }
80
+ /**
81
+ * Wires React Native app lifecycle events to an append-log store
82
+ * (`createStarfishLog`). A log is read-only, so this only pulls on foreground
83
+ * (there is nothing to flush on background). NetInfo connectivity changes are
84
+ * forwarded to `store.getState().setOnline()`.
85
+ *
86
+ * ```ts
87
+ * import { AppState } from "react-native"
88
+ * import NetInfo from "@react-native-community/netinfo"
89
+ * import { createStarfishLog, createAppendLogMobileLifecycle } from "@drakkar.software/starfish-client"
90
+ *
91
+ * const store = createStarfishLog({ cursor })
92
+ * const cleanup = createAppendLogMobileLifecycle(store, { appState: AppState, netInfo: NetInfo })
93
+ * useEffect(() => cleanup, [])
94
+ * ```
95
+ *
96
+ * @returns A cleanup function that removes all event listeners.
97
+ */
98
+ export declare function createAppendLogMobileLifecycle(store: StoreApi<StarfishLogStore>, deps: MobileLifecycleDeps, options?: AppendLogLifecycleOptions): () => void;
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { CapCert } from "@drakkar.software/starfish-protocol";
1
+ import type { Alg, CapCert } from "@drakkar.software/starfish-protocol";
2
2
  /** Push conflict error (HTTP 409). */
3
3
  export declare class ConflictError extends Error {
4
4
  constructor();
@@ -29,17 +29,44 @@ export interface StarfishCapProvider {
29
29
  * The client then sends it as `X-Starfish-Pub` so the server can verify the
30
30
  * request signature against it and check the cap's `aud` allow-list. Omit
31
31
  * `pubHex` for device/member caps (the server uses `cap.sub`).
32
+ *
33
+ * `presenterAlg` is the crypto suite of `devEdPrivHex` (the key that signs
34
+ * the request). It matters only for `audience` caps, where the presenter is
35
+ * an arbitrary redeemer whose suite is unrelated to the cap's `issAlg`; the
36
+ * client sends it as `X-Starfish-Alg`. For device/member caps the subject's
37
+ * suite is taken authoritatively from the verified cert, so this is ignored.
38
+ * Defaults to `"ed25519"` when omitted.
32
39
  */
33
40
  getCap(): Promise<{
34
41
  cap: CapCert;
35
42
  devEdPrivHex: string;
36
43
  pubHex?: string;
44
+ presenterAlg?: Alg;
37
45
  }>;
38
46
  }
39
47
  /** Options for creating a StarfishClient. */
40
48
  export interface StarfishClientOptions {
41
49
  /** Base URL of the Starfish server (e.g. "https://api.example.com/v1"). */
42
50
  baseUrl: string;
51
+ /**
52
+ * Optional namespace for a namespace-mounted server. When set, every request
53
+ * path `/{action}/…` is rewritten to `/v1/{namespace}/{action}/…` for BOTH the
54
+ * URL the client hits AND the canonical path it signs, so the signature the
55
+ * server reconstructs from the namespaced URL verifies (no rewrite layer
56
+ * needed). Mirrors the Python client's `namespace` parameter.
57
+ *
58
+ * Crucially this also rewrites the paths that namespace-unaware SDK helpers
59
+ * build internally (e.g. `starfish-keyring`'s `addCollectionRecipient`, blob
60
+ * uploads), so consumers no longer hand-prefix paths or wrap the client to
61
+ * reach a namespaced deployment. Leave unset (default) for a root-mounted
62
+ * server — paths pass through unchanged, byte-identical to before.
63
+ *
64
+ * Pass the bare namespace name (e.g. `"octochat"`); `baseUrl` then carries only
65
+ * the origin (and any reverse-proxy mount the proxy strips), not the `/v1`
66
+ * version segment. Must match `[A-Za-z0-9_-]+` and not be a reserved route name
67
+ * (`pull`, `push`, `health`, `batch`).
68
+ */
69
+ namespace?: string;
43
70
  /**
44
71
  * Cap-cert provider. When set, requests are signed with Ed25519 and carry
45
72
  * `Authorization: Cap <…>`. Omit for unauthenticated public-read collections.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drakkar.software/starfish-client",
3
- "version": "3.0.0-alpha.1",
3
+ "version": "3.0.0-alpha.11",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/Drakkar-Software/starfish.git",
@@ -60,7 +60,7 @@
60
60
  }
61
61
  },
62
62
  "dependencies": {
63
- "@drakkar.software/starfish-protocol": "3.0.0-alpha.1"
63
+ "@drakkar.software/starfish-protocol": "3.0.0-alpha.11"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@legendapp/state": "^2.0.0",