@drakkar.software/starfish-client 1.19.2 → 2.0.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.
@@ -31,13 +31,13 @@ export function createMobileLifecycle(store, deps, options = {}) {
31
31
  const appSub = deps.appState.addEventListener("change", (appState) => {
32
32
  if (appState === "background" && flushOnBackground) {
33
33
  if (store.getState().dirty) {
34
- store.getState().flush().catch((err) => { console.error("[Starfish] background flush failed:", err); });
34
+ store.getState().flush().catch(() => { });
35
35
  }
36
36
  }
37
37
  else if (appState === "active" && pullOnForeground) {
38
38
  const { online, syncing } = store.getState();
39
39
  if (online && !syncing) {
40
- store.getState().pull().catch((err) => { console.error("[Starfish] foreground pull failed:", err); });
40
+ store.getState().pull().catch(() => { });
41
41
  }
42
42
  }
43
43
  // "inactive" (iOS transition) and other states are intentionally ignored
package/dist/polling.js CHANGED
@@ -14,7 +14,7 @@ export function startPolling(pullFn, getState, intervalMs = 30_000) {
14
14
  const timer = setInterval(() => {
15
15
  const { online, syncing } = getState();
16
16
  if (online && !syncing)
17
- pullFn().catch((err) => { console.error("[Starfish] poll failed:", err); });
17
+ pullFn().catch(() => { });
18
18
  }, intervalMs);
19
19
  return () => clearInterval(timer);
20
20
  }
@@ -42,7 +42,7 @@ export function startAdaptivePolling(pullFn, getState, options) {
42
42
  return;
43
43
  const { online, syncing } = getState();
44
44
  if (online && !syncing)
45
- pullFn().catch((err) => { console.error("[Starfish] adaptive poll failed:", err); });
45
+ pullFn().catch(() => { });
46
46
  }, intervalMs);
47
47
  return {
48
48
  pause: () => { paused = true; },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drakkar.software/starfish-client",
3
- "version": "1.19.2",
3
+ "version": "2.0.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/Drakkar-Software/starfish.git",
@@ -69,7 +69,7 @@
69
69
  },
70
70
  "dependencies": {
71
71
  "@noble/curves": "^2.2.0",
72
- "@drakkar.software/starfish-protocol": "1.18.1"
72
+ "@drakkar.software/starfish-protocol": "2.0.0"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@legendapp/state": "^2.0.0",
package/dist/hash.d.ts DELETED
@@ -1,10 +0,0 @@
1
- /**
2
- * Deterministic JSON serialization with sorted keys (recursive).
3
- * Must produce identical output to the server's stableStringify.
4
- */
5
- export declare function stableStringify(value: unknown): string;
6
- /**
7
- * Compute SHA-256 hex digest of the stable-stringified data.
8
- * Works in both browser (crypto.subtle) and Node.js environments.
9
- */
10
- export declare function computeHash(data: Record<string, unknown>): Promise<string>;
package/dist/hash.js DELETED
@@ -1,34 +0,0 @@
1
- import { getCrypto } from "./platform.js";
2
- /**
3
- * Deterministic JSON serialization with sorted keys (recursive).
4
- * Must produce identical output to the server's stableStringify.
5
- */
6
- export function stableStringify(value) {
7
- if (value === null || value === undefined)
8
- return "null";
9
- if (typeof value === "boolean" || typeof value === "number")
10
- return JSON.stringify(value);
11
- if (typeof value === "string")
12
- return JSON.stringify(value);
13
- if (Array.isArray(value)) {
14
- return "[" + value.map(v => stableStringify(v)).join(",") + "]";
15
- }
16
- if (typeof value === "object") {
17
- const obj = value;
18
- const keys = Object.keys(obj).sort();
19
- const pairs = keys.map(k => JSON.stringify(k) + ":" + stableStringify(obj[k]));
20
- return "{" + pairs.join(",") + "}";
21
- }
22
- return "null";
23
- }
24
- /**
25
- * Compute SHA-256 hex digest of the stable-stringified data.
26
- * Works in both browser (crypto.subtle) and Node.js environments.
27
- */
28
- export async function computeHash(data) {
29
- const encoded = new TextEncoder().encode(stableStringify(data));
30
- const buf = await getCrypto().subtle.digest("SHA-256", encoded);
31
- return Array.from(new Uint8Array(buf))
32
- .map(b => b.toString(16).padStart(2, "0"))
33
- .join("");
34
- }
@@ -1,52 +0,0 @@
1
- /**
2
- * Platform abstraction for crypto and base64 operations.
3
- *
4
- * Browser and Node.js >= 15 work with zero configuration (globalThis.crypto).
5
- * React Native users must call configurePlatform() before using the SDK.
6
- */
7
- /** Minimal crypto interface required by the SDK (subset of Web Crypto API). */
8
- export interface CryptoProvider {
9
- subtle: {
10
- digest(algorithm: string, data: BufferSource): Promise<ArrayBuffer>;
11
- importKey(format: "raw", keyData: BufferSource, algorithm: string | Algorithm, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>;
12
- deriveKey(algorithm: HkdfParams, baseKey: CryptoKey, derivedKeyType: AesKeyGenParams, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>;
13
- encrypt(algorithm: AesGcmParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>;
14
- decrypt(algorithm: AesGcmParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>;
15
- };
16
- getRandomValues<T extends ArrayBufferView>(array: T): T;
17
- }
18
- /** Base64 encode/decode for Uint8Array <-> string. */
19
- export interface Base64Provider {
20
- encode(data: Uint8Array): string;
21
- decode(encoded: string): Uint8Array;
22
- }
23
- export interface PlatformConfig {
24
- crypto?: CryptoProvider;
25
- base64?: Base64Provider;
26
- }
27
- /**
28
- * Configure platform-specific providers for environments
29
- * that lack the Web Crypto API (e.g., React Native).
30
- *
31
- * Call once at app startup, before using any SDK functions.
32
- * Not needed for browser or Node.js >= 15.
33
- *
34
- * @example
35
- * ```ts
36
- * import { configurePlatform } from "@satellite/client"
37
- * import QuickCrypto from "react-native-quick-crypto"
38
- *
39
- * configurePlatform({
40
- * crypto: QuickCrypto,
41
- * base64: {
42
- * encode: (data) => Buffer.from(data).toString("base64"),
43
- * decode: (str) => new Uint8Array(Buffer.from(str, "base64")),
44
- * },
45
- * })
46
- * ```
47
- */
48
- export declare function configurePlatform(config: PlatformConfig): void;
49
- /** Resolve the active crypto provider. */
50
- export declare function getCrypto(): CryptoProvider;
51
- /** Resolve the active base64 provider. */
52
- export declare function getBase64(): Base64Provider;
package/dist/platform.js DELETED
@@ -1,62 +0,0 @@
1
- /**
2
- * Platform abstraction for crypto and base64 operations.
3
- *
4
- * Browser and Node.js >= 15 work with zero configuration (globalThis.crypto).
5
- * React Native users must call configurePlatform() before using the SDK.
6
- */
7
- let _crypto;
8
- let _base64;
9
- /**
10
- * Configure platform-specific providers for environments
11
- * that lack the Web Crypto API (e.g., React Native).
12
- *
13
- * Call once at app startup, before using any SDK functions.
14
- * Not needed for browser or Node.js >= 15.
15
- *
16
- * @example
17
- * ```ts
18
- * import { configurePlatform } from "@satellite/client"
19
- * import QuickCrypto from "react-native-quick-crypto"
20
- *
21
- * configurePlatform({
22
- * crypto: QuickCrypto,
23
- * base64: {
24
- * encode: (data) => Buffer.from(data).toString("base64"),
25
- * decode: (str) => new Uint8Array(Buffer.from(str, "base64")),
26
- * },
27
- * })
28
- * ```
29
- */
30
- export function configurePlatform(config) {
31
- if (config.crypto)
32
- _crypto = config.crypto;
33
- if (config.base64)
34
- _base64 = config.base64;
35
- }
36
- /** Resolve the active crypto provider. */
37
- export function getCrypto() {
38
- if (_crypto)
39
- return _crypto;
40
- if (typeof globalThis !== "undefined" && globalThis.crypto?.subtle) {
41
- return globalThis.crypto;
42
- }
43
- throw new Error("@satellite/client: No crypto provider available. " +
44
- "In React Native, call configurePlatform({ crypto: ... }) before using the SDK.");
45
- }
46
- /** Resolve the active base64 provider. */
47
- export function getBase64() {
48
- if (_base64)
49
- return _base64;
50
- if (typeof globalThis !== "undefined" && typeof globalThis.btoa === "function") {
51
- return {
52
- encode(data) {
53
- return btoa(String.fromCharCode(...data));
54
- },
55
- decode(encoded) {
56
- return Uint8Array.from(atob(encoded), (c) => c.charCodeAt(0));
57
- },
58
- };
59
- }
60
- throw new Error("@satellite/client: No base64 provider available. " +
61
- "In React Native, call configurePlatform({ base64: ... }) before using the SDK.");
62
- }