@drakkar.software/starfish-client 3.0.0-alpha.1 → 3.0.0-alpha.2
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/append.d.ts +50 -0
- package/dist/background-sync.js +29 -0
- package/dist/bindings/broadcast.d.ts +19 -0
- package/dist/bindings/broadcast.js +65 -0
- package/dist/bindings/react.d.ts +12 -0
- package/dist/bindings/react.js +25 -0
- package/dist/bindings/suspense.js +49 -0
- package/dist/bindings/zustand.js +36 -0
- package/dist/bindings/zustand.js.map +2 -2
- package/dist/client.d.ts +20 -0
- package/dist/client.js +112 -0
- package/dist/config.d.ts +2 -2
- package/dist/config.js +18 -0
- package/dist/crypto.js +49 -0
- package/dist/debounced-sync.js +120 -0
- package/dist/dedup.js +35 -0
- package/dist/entitlements.js +41 -0
- package/dist/export.js +115 -0
- package/dist/group-crypto.d.ts +111 -0
- package/dist/group-crypto.js +205 -0
- package/dist/group-crypto.js.map +7 -0
- package/dist/history.js +61 -0
- package/dist/identity.d.ts +82 -4
- package/dist/identity.js +354 -2
- package/dist/identity.js.map +4 -4
- package/dist/index.js +36 -0
- package/dist/index.js.map +2 -2
- package/dist/logger.js +80 -0
- package/dist/migrate.js +38 -0
- package/dist/mobile-lifecycle.js +55 -0
- package/dist/multi-store.js +92 -0
- package/dist/polling.js +52 -0
- package/dist/resolvers.js +223 -0
- package/dist/service-worker.js +55 -0
- package/dist/storage/indexeddb.js +59 -0
- package/dist/sync.js +127 -0
- package/dist/types.js +18 -0
- package/dist/validate.js +28 -0
- package/package.json +2 -2
- package/dist/_crypto_helpers.d.ts +0 -4
- package/dist/cap-mint.d.ts +0 -20
- package/dist/cap-mint.js +0 -12
- package/dist/cap-mint.js.map +0 -7
- package/dist/directory.d.ts +0 -9
- package/dist/directory.js +0 -24
- package/dist/directory.js.map +0 -7
- package/dist/keyring.d.ts +0 -6
- package/dist/keyring.js +0 -26
- package/dist/keyring.js.map +0 -7
- package/dist/pairing.d.ts +0 -6
- package/dist/pairing.js +0 -26
- package/dist/pairing.js.map +0 -7
- package/dist/recipients.d.ts +0 -6
- package/dist/recipients.js +0 -16
- package/dist/recipients.js.map +0 -7
package/dist/index.js
CHANGED
|
@@ -179,6 +179,42 @@ var StarfishClient = class {
|
|
|
179
179
|
}
|
|
180
180
|
return res.json();
|
|
181
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* Append an element to an appendOnly (`by_timestamp`) collection.
|
|
184
|
+
*
|
|
185
|
+
* Unlike {@link push}, appendOnly writes carry no hash/conflict check — an
|
|
186
|
+
* authorized append is always accepted. Each element is stored server-side as
|
|
187
|
+
* `{ts, data}` and pulls can filter by `ts` via `since`/`checkpoint`.
|
|
188
|
+
*
|
|
189
|
+
* @param path - the push endpoint (e.g. "/push/events")
|
|
190
|
+
* @param data - the element payload. For a `delegated` collection, encrypt it
|
|
191
|
+
* first (e.g. `createKeyringEncryptor(keyring, kem).encrypt(data)`); the
|
|
192
|
+
* server stores it opaquely and never reads it.
|
|
193
|
+
* @param opts.ts - optional client-supplied element timestamp (ms). Must be a
|
|
194
|
+
* non-negative integer strictly greater than the latest stored element's ts
|
|
195
|
+
* (else the server responds 409). Omit to let the server assign one.
|
|
196
|
+
* @throws {StarfishHttpError} on a non-2xx response (e.g. 409 for a
|
|
197
|
+
* non-monotonic timestamp).
|
|
198
|
+
*/
|
|
199
|
+
async append(path, data, opts = {}) {
|
|
200
|
+
const bodyObj = { data };
|
|
201
|
+
if (opts.ts !== void 0) bodyObj["ts"] = opts.ts;
|
|
202
|
+
const body = JSON.stringify(bodyObj);
|
|
203
|
+
const authHeaders = await this.buildAuthHeaders("POST", path, body);
|
|
204
|
+
const res = await this.fetch(`${this.baseUrl}${path}`, {
|
|
205
|
+
method: "POST",
|
|
206
|
+
headers: {
|
|
207
|
+
"Content-Type": "application/json",
|
|
208
|
+
Accept: "application/json",
|
|
209
|
+
...authHeaders
|
|
210
|
+
},
|
|
211
|
+
body
|
|
212
|
+
});
|
|
213
|
+
if (!res.ok) {
|
|
214
|
+
throw new StarfishHttpError(res.status, await res.text());
|
|
215
|
+
}
|
|
216
|
+
return res.json();
|
|
217
|
+
}
|
|
182
218
|
/**
|
|
183
219
|
* Pull binary data from a blob collection.
|
|
184
220
|
* Returns raw bytes with the content hash from the ETag header.
|