velocious 1.0.700 → 1.0.702
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/README.md +1 -0
- package/build/configuration-types.js +73 -3
- package/build/configuration.js +113 -20
- package/build/frontend-model-resource/base-resource.js +150 -2
- package/build/frontend-models/resource-definition.js +47 -0
- package/build/src/configuration-types.d.ts +168 -7
- package/build/src/configuration-types.d.ts.map +1 -1
- package/build/src/configuration-types.js +68 -4
- package/build/src/configuration.d.ts +22 -2
- package/build/src/configuration.d.ts.map +1 -1
- package/build/src/configuration.js +110 -20
- package/build/src/frontend-model-resource/base-resource.d.ts +76 -3
- package/build/src/frontend-model-resource/base-resource.d.ts.map +1 -1
- package/build/src/frontend-model-resource/base-resource.js +127 -3
- package/build/src/frontend-models/resource-definition.d.ts.map +1 -1
- package/build/src/frontend-models/resource-definition.js +43 -1
- package/build/src/sync/local-mutation-log.d.ts +6 -3
- package/build/src/sync/local-mutation-log.d.ts.map +1 -1
- package/build/src/sync/local-mutation-log.js +11 -4
- package/build/src/sync/peer-mutation-bundle.d.ts +26 -0
- package/build/src/sync/peer-mutation-bundle.d.ts.map +1 -1
- package/build/src/sync/peer-mutation-bundle.js +7 -1
- package/build/src/sync/sync-api-client.d.ts +3 -1
- package/build/src/sync/sync-api-client.d.ts.map +1 -1
- package/build/src/sync/sync-api-client.js +46 -8
- package/build/src/sync/sync-client-types.d.ts +24 -12
- package/build/src/sync/sync-client-types.d.ts.map +1 -1
- package/build/src/sync/sync-client-types.js +7 -5
- package/build/src/sync/sync-client.d.ts +101 -0
- package/build/src/sync/sync-client.d.ts.map +1 -1
- package/build/src/sync/sync-client.js +236 -24
- package/build/src/sync/sync-offline-session.d.ts +328 -0
- package/build/src/sync/sync-offline-session.d.ts.map +1 -0
- package/build/src/sync/sync-offline-session.js +617 -0
- package/build/src/sync/sync-resource-base.d.ts +26 -28
- package/build/src/sync/sync-resource-base.d.ts.map +1 -1
- package/build/src/sync/sync-resource-base.js +11 -45
- package/build/sync/local-mutation-log.js +10 -3
- package/build/sync/peer-mutation-bundle.js +6 -0
- package/build/sync/sync-api-client.js +53 -7
- package/build/sync/sync-client-types.js +6 -4
- package/build/sync/sync-client.js +264 -21
- package/build/sync/sync-offline-session.js +713 -0
- package/build/sync/sync-resource-base.js +10 -53
- package/package.json +1 -1
- package/src/configuration-types.js +73 -3
- package/src/configuration.js +113 -20
- package/src/frontend-model-resource/base-resource.js +150 -2
- package/src/frontend-models/resource-definition.js +47 -0
- package/src/sync/local-mutation-log.js +10 -3
- package/src/sync/peer-mutation-bundle.js +6 -0
- package/src/sync/sync-api-client.js +53 -7
- package/src/sync/sync-client-types.js +6 -4
- package/src/sync/sync-client.js +264 -21
- package/src/sync/sync-offline-session.js +713 -0
- package/src/sync/sync-resource-base.js +10 -53
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
export type SyncOfflineDeviceIdentity = {
|
|
2
|
+
/**
|
|
3
|
+
* - Backend-signed device certificate.
|
|
4
|
+
*/
|
|
5
|
+
certificate: import("./device-identity.js").DeviceCertificate;
|
|
6
|
+
/**
|
|
7
|
+
* - Device private signing key (JWK).
|
|
8
|
+
*/
|
|
9
|
+
privateKey: import("./device-identity.js").SyncJsonWebKey;
|
|
10
|
+
};
|
|
11
|
+
export type SyncOfflineReplayResult = {
|
|
12
|
+
/**
|
|
13
|
+
* - Records left in `conflict`.
|
|
14
|
+
*/
|
|
15
|
+
conflictCount: number;
|
|
16
|
+
/**
|
|
17
|
+
* - Records still pending (blocked dependencies or unacknowledged).
|
|
18
|
+
*/
|
|
19
|
+
pendingCount: number;
|
|
20
|
+
/**
|
|
21
|
+
* - Records the backend rejected.
|
|
22
|
+
*/
|
|
23
|
+
rejectedCount: number;
|
|
24
|
+
/**
|
|
25
|
+
* - Per-mutation mapped results in replay order.
|
|
26
|
+
*/
|
|
27
|
+
results: Array<{
|
|
28
|
+
clientMutationId: string;
|
|
29
|
+
idempotencyKey: string;
|
|
30
|
+
mutation: import("./device-identity.js").SyncMutation;
|
|
31
|
+
recordId: string;
|
|
32
|
+
serverResult: Record<string, ReturnType<typeof JSON.parse>> | null;
|
|
33
|
+
status: import("./local-mutation-log.js").LocalMutationStatus;
|
|
34
|
+
}>;
|
|
35
|
+
/**
|
|
36
|
+
* - Records acknowledged by the backend.
|
|
37
|
+
*/
|
|
38
|
+
syncedCount: number;
|
|
39
|
+
};
|
|
40
|
+
export type SyncOfflineSessionSummary = {
|
|
41
|
+
/**
|
|
42
|
+
* - Certificate device identity.
|
|
43
|
+
*/
|
|
44
|
+
actorDeviceId: string;
|
|
45
|
+
/**
|
|
46
|
+
* - Certificate user identity.
|
|
47
|
+
*/
|
|
48
|
+
actorUserId: string;
|
|
49
|
+
/**
|
|
50
|
+
* - Live grant expiry.
|
|
51
|
+
*/
|
|
52
|
+
expiresAt: string;
|
|
53
|
+
/**
|
|
54
|
+
* - Live grant id.
|
|
55
|
+
*/
|
|
56
|
+
grantId: string;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Stored device signing identity: the backend-signed certificate plus the
|
|
60
|
+
* device private key matching the certificate's public key.
|
|
61
|
+
* @typedef {object} SyncOfflineDeviceIdentity
|
|
62
|
+
* @property {import("./device-identity.js").DeviceCertificate} certificate - Backend-signed device certificate.
|
|
63
|
+
* @property {import("./device-identity.js").SyncJsonWebKey} privateKey - Device private signing key (JWK).
|
|
64
|
+
*/
|
|
65
|
+
/**
|
|
66
|
+
* Result of one offline session replay pass over the durable mutation logs.
|
|
67
|
+
* @typedef {object} SyncOfflineReplayResult
|
|
68
|
+
* @property {number} conflictCount - Records left in `conflict`.
|
|
69
|
+
* @property {number} pendingCount - Records still pending (blocked dependencies or unacknowledged).
|
|
70
|
+
* @property {number} rejectedCount - Records the backend rejected.
|
|
71
|
+
* @property {Array<{clientMutationId: string, idempotencyKey: string, mutation: import("./device-identity.js").SyncMutation, recordId: string, serverResult: Record<string, ReturnType<typeof JSON.parse>> | null, status: import("./local-mutation-log.js").LocalMutationStatus}>} results - Per-mutation mapped results in replay order.
|
|
72
|
+
* @property {number} syncedCount - Records acknowledged by the backend.
|
|
73
|
+
*/
|
|
74
|
+
/**
|
|
75
|
+
* Session summary returned by start/refresh.
|
|
76
|
+
* @typedef {object} SyncOfflineSessionSummary
|
|
77
|
+
* @property {string} actorDeviceId - Certificate device identity.
|
|
78
|
+
* @property {string} actorUserId - Certificate user identity.
|
|
79
|
+
* @property {string} expiresAt - Live grant expiry.
|
|
80
|
+
* @property {string} grantId - Live grant id.
|
|
81
|
+
*/
|
|
82
|
+
/**
|
|
83
|
+
* Framework-owned long-offline session behind SyncClient: device identity
|
|
84
|
+
* lifecycle, backend-issued offline grants, mutation signing, signed replay,
|
|
85
|
+
* and peer bundle transfer. SyncClient owns the public API; this class owns the
|
|
86
|
+
* session state. The app only provides durable storage adapters, the
|
|
87
|
+
* enrollment hook, and the grant scopes callback.
|
|
88
|
+
*/
|
|
89
|
+
export default class SyncOfflineSession {
|
|
90
|
+
authenticationToken: () => string | Promise<string>;
|
|
91
|
+
config: import("../configuration-types.js").NormalizedVelociousSyncClientOfflineConfiguration;
|
|
92
|
+
mutationLogs: import("./local-mutation-log.js").default[];
|
|
93
|
+
post: (path: string, payload: Record<string, ReturnType<typeof JSON.parse>>, options?: {
|
|
94
|
+
signal?: AbortSignal;
|
|
95
|
+
}) => Promise<ReturnType<typeof JSON.parse>>;
|
|
96
|
+
/** @type {SyncOfflineDeviceIdentity | null} */
|
|
97
|
+
_identity: SyncOfflineDeviceIdentity | null;
|
|
98
|
+
/** @type {Map<string, import("./offline-grant.js").SignedOfflineGrant>} */
|
|
99
|
+
_grants: Map<string, import("./offline-grant.js").SignedOfflineGrant>;
|
|
100
|
+
_grantsLoaded: boolean;
|
|
101
|
+
/** @type {import("./offline-grant.js").SignedOfflineGrant | null} */
|
|
102
|
+
_activeGrant: import("./offline-grant.js").SignedOfflineGrant | null;
|
|
103
|
+
/** @type {Record<string, import("../configuration-types.js").NormalizedFrontendModelResourceSyncConfiguration> | null} */
|
|
104
|
+
_syncManifest: Record<string, import("../configuration-types.js").NormalizedFrontendModelResourceSyncConfiguration> | null;
|
|
105
|
+
/** @type {Promise<SyncOfflineSessionSummary> | null} */
|
|
106
|
+
_startPromise: Promise<SyncOfflineSessionSummary> | null;
|
|
107
|
+
/** @type {Promise<SyncOfflineReplayResult> | null} */
|
|
108
|
+
_replayPromise: Promise<SyncOfflineReplayResult> | null;
|
|
109
|
+
/**
|
|
110
|
+
* Builds an offline session from the normalized `sync.client.offline` block.
|
|
111
|
+
* @param {object} args - Session args.
|
|
112
|
+
* @param {() => string | Promise<string>} args.authenticationToken - Resolves the auth token sent with bootstrap/replay requests.
|
|
113
|
+
* @param {import("../configuration-types.js").NormalizedVelociousSyncClientOfflineConfiguration} args.config - Normalized offline configuration.
|
|
114
|
+
* @param {Array<import("./local-mutation-log.js").default>} args.mutationLogs - Durable local mutation logs the session signs, replays, resigns, and exports.
|
|
115
|
+
* @param {(path: string, payload: Record<string, ReturnType<typeof JSON.parse>>, options?: {signal?: AbortSignal}) => Promise<ReturnType<typeof JSON.parse>>} args.post - Framework POSTer over the configured transport.
|
|
116
|
+
*/
|
|
117
|
+
constructor({ authenticationToken, config, mutationLogs, post }: {
|
|
118
|
+
authenticationToken: () => string | Promise<string>;
|
|
119
|
+
config: import("../configuration-types.js").NormalizedVelociousSyncClientOfflineConfiguration;
|
|
120
|
+
mutationLogs: Array<import("./local-mutation-log.js").default>;
|
|
121
|
+
post: (path: string, payload: Record<string, ReturnType<typeof JSON.parse>>, options?: {
|
|
122
|
+
signal?: AbortSignal;
|
|
123
|
+
}) => Promise<ReturnType<typeof JSON.parse>>;
|
|
124
|
+
});
|
|
125
|
+
/**
|
|
126
|
+
* Whether the session currently has a usable device identity and live grant.
|
|
127
|
+
* @returns {boolean} - Whether the session is active.
|
|
128
|
+
*/
|
|
129
|
+
isActive(): boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Resolves the device signing identity (generating and enrolling a key pair
|
|
132
|
+
* when the app-owned storage has none) and bootstraps a live offline grant.
|
|
133
|
+
* Idempotent and single-flighted: concurrent starts share one bootstrap.
|
|
134
|
+
* @returns {Promise<SyncOfflineSessionSummary>} - Session summary.
|
|
135
|
+
*/
|
|
136
|
+
start(): Promise<SyncOfflineSessionSummary>;
|
|
137
|
+
/**
|
|
138
|
+
* Drops the in-memory session (identity and grants stay in the app-owned
|
|
139
|
+
* durable storage; pending mutations stay in the durable mutation logs).
|
|
140
|
+
* @returns {Promise<void>} - Resolves after the session is dropped.
|
|
141
|
+
*/
|
|
142
|
+
stop(): Promise<void>;
|
|
143
|
+
/**
|
|
144
|
+
* Runs one start attempt: identity first, then grant bootstrap.
|
|
145
|
+
* @returns {Promise<SyncOfflineSessionSummary>} - Session summary.
|
|
146
|
+
*/
|
|
147
|
+
_startSession(): Promise<SyncOfflineSessionSummary>;
|
|
148
|
+
/**
|
|
149
|
+
* Returns the current session summary.
|
|
150
|
+
* @returns {SyncOfflineSessionSummary} - Session summary.
|
|
151
|
+
*/
|
|
152
|
+
sessionSummary(): SyncOfflineSessionSummary;
|
|
153
|
+
/**
|
|
154
|
+
* Resolves the device identity: load it from the app-owned storage, or
|
|
155
|
+
* generate a key pair, run the app-owned enrollment hook, verify the returned
|
|
156
|
+
* certificate against the configured backend public key, and store it.
|
|
157
|
+
* @returns {Promise<SyncOfflineDeviceIdentity>} - Device signing identity.
|
|
158
|
+
*/
|
|
159
|
+
_ensureIdentity(): Promise<SyncOfflineDeviceIdentity>;
|
|
160
|
+
/**
|
|
161
|
+
* Verifies a stored/enrolled certificate against the configured backend
|
|
162
|
+
* public key (when one is configured) and returns the identity.
|
|
163
|
+
* @param {SyncOfflineDeviceIdentity} identity - Candidate identity.
|
|
164
|
+
* @returns {Promise<SyncOfflineDeviceIdentity>} - Verified identity.
|
|
165
|
+
*/
|
|
166
|
+
_verifiedIdentity(identity: SyncOfflineDeviceIdentity): Promise<SyncOfflineDeviceIdentity>;
|
|
167
|
+
/**
|
|
168
|
+
* Loads app-retained grants once so a restarted device can still replay
|
|
169
|
+
* mutations that were signed under an older grant (peer-forwarded mutations
|
|
170
|
+
* keep the grant their original signer used).
|
|
171
|
+
* @returns {Promise<void>} - Resolves after retention is loaded.
|
|
172
|
+
*/
|
|
173
|
+
_loadRetainedGrants(): Promise<void>;
|
|
174
|
+
/**
|
|
175
|
+
* Returns the active grant when it is still live, otherwise null. Expiry is
|
|
176
|
+
* checked by timestamp only: the grant's HMAC signature is backend-only and
|
|
177
|
+
* can never be verified on the device.
|
|
178
|
+
* @param {Date} [now] - Check time.
|
|
179
|
+
* @returns {import("./offline-grant.js").SignedOfflineGrant | null} - Live grant or null.
|
|
180
|
+
*/
|
|
181
|
+
_liveGrant(now?: Date): import("./offline-grant.js").SignedOfflineGrant | null;
|
|
182
|
+
/**
|
|
183
|
+
* Ensures a live grant exists, bootstrapping a new one when the current grant
|
|
184
|
+
* is missing or expired. A refreshed grant re-signs this device's pending
|
|
185
|
+
* records so the backend always sees the grant an intent is replayed under.
|
|
186
|
+
* @returns {Promise<import("./offline-grant.js").SignedOfflineGrant>} - Live grant.
|
|
187
|
+
*/
|
|
188
|
+
_ensureLiveGrant(): Promise<import("./offline-grant.js").SignedOfflineGrant>;
|
|
189
|
+
/**
|
|
190
|
+
* Requests a fresh offline grant from the built-in sync bootstrap endpoint
|
|
191
|
+
* and retains it under its grant id together with the sync manifest whose
|
|
192
|
+
* policy hashes mutations are signed against.
|
|
193
|
+
* @returns {Promise<import("./offline-grant.js").SignedOfflineGrant>} - Newly issued grant.
|
|
194
|
+
*/
|
|
195
|
+
bootstrapGrant(): Promise<import("./offline-grant.js").SignedOfflineGrant>;
|
|
196
|
+
/**
|
|
197
|
+
* Forces a grant refresh: bootstrap a new grant and re-sign this device's
|
|
198
|
+
* pending records under it.
|
|
199
|
+
* @returns {Promise<SyncOfflineSessionSummary>} - Refreshed session summary.
|
|
200
|
+
*/
|
|
201
|
+
refreshGrant(): Promise<SyncOfflineSessionSummary>;
|
|
202
|
+
/**
|
|
203
|
+
* Re-signs this device's still-pending records under a new grant. Safe
|
|
204
|
+
* because the replay idempotency key is
|
|
205
|
+
* `actorUserId:actorDeviceId:clientMutationId` and never carries the grant
|
|
206
|
+
* id. Records signed by another device (peer-forwarded mutations) keep their
|
|
207
|
+
* original signed envelope and original grant - they must always replay with
|
|
208
|
+
* the grant their signer used.
|
|
209
|
+
* @param {import("./offline-grant.js").SignedOfflineGrant} signedGrant - Grant the records are re-signed under.
|
|
210
|
+
* @returns {Promise<void>} - Resolves after pending records are re-signed.
|
|
211
|
+
*/
|
|
212
|
+
_resignPendingRecords(signedGrant: import("./offline-grant.js").SignedOfflineGrant): Promise<void>;
|
|
213
|
+
/**
|
|
214
|
+
* Checks whether a log record was signed/queued by this device's identity
|
|
215
|
+
* (or has no identity yet and can adopt it).
|
|
216
|
+
* @param {import("./local-mutation-log.js").LocalMutationLogRecord} record - Durable record.
|
|
217
|
+
* @returns {boolean} - Whether the record belongs to this device.
|
|
218
|
+
*/
|
|
219
|
+
_isOwnRecord(record: import("./local-mutation-log.js").LocalMutationLogRecord): boolean;
|
|
220
|
+
/**
|
|
221
|
+
* Signs one mutation payload with the device key under the live grant,
|
|
222
|
+
* filling the actor/grant/policy-hash identity from the session.
|
|
223
|
+
* @param {Omit<import("./device-identity.js").SyncMutation, "actorDeviceId" | "actorUserId" | "offlineGrantId" | "policyHash">} mutation - Mutation payload to sign (the session supplies the rotating identity fields).
|
|
224
|
+
* @returns {Promise<import("./device-identity.js").SignedSyncMutation>} - Signed mutation envelope.
|
|
225
|
+
*/
|
|
226
|
+
signMutation(mutation: Omit<import("./device-identity.js").SyncMutation, "actorDeviceId" | "actorUserId" | "offlineGrantId" | "policyHash">): Promise<import("./device-identity.js").SignedSyncMutation>;
|
|
227
|
+
/**
|
|
228
|
+
* Returns the grant a new mutation is signed under: the live grant when one
|
|
229
|
+
* exists, otherwise the newest retained grant (queueing stays possible while
|
|
230
|
+
* offline - the replay pass refreshes the grant and re-signs the pending
|
|
231
|
+
* records), and only bootstraps when no grant has ever been retained.
|
|
232
|
+
* @returns {Promise<import("./offline-grant.js").SignedOfflineGrant>} - Grant to sign under.
|
|
233
|
+
*/
|
|
234
|
+
_grantForSigning(): Promise<import("./offline-grant.js").SignedOfflineGrant>;
|
|
235
|
+
/**
|
|
236
|
+
* Returns the policy hash the live session's sync manifest carries for one model.
|
|
237
|
+
* @param {string} model - Model/resource name.
|
|
238
|
+
* @returns {string} - Policy hash.
|
|
239
|
+
*/
|
|
240
|
+
policyHashFor(model: string): string;
|
|
241
|
+
/**
|
|
242
|
+
* Drains the durable mutation logs through the built-in signed replay
|
|
243
|
+
* endpoint. Pending records are batched, each signed mutation travels with
|
|
244
|
+
* the signed grant it was signed under, and per-mutation results are mapped
|
|
245
|
+
* back onto the log records as synced/conflict/rejected.
|
|
246
|
+
* @param {object} [options] - Replay options.
|
|
247
|
+
* @param {number} [options.batchSize] - Max mutations per request.
|
|
248
|
+
* @param {AbortSignal} [options.signal] - Lifecycle cancellation signal.
|
|
249
|
+
* @returns {Promise<SyncOfflineReplayResult>} - Mapped replay result.
|
|
250
|
+
*/
|
|
251
|
+
replayPending(options?: {
|
|
252
|
+
batchSize?: number;
|
|
253
|
+
signal?: AbortSignal;
|
|
254
|
+
}): Promise<SyncOfflineReplayResult>;
|
|
255
|
+
/**
|
|
256
|
+
* Runs one signed replay pass.
|
|
257
|
+
* @param {object} options - Pass options.
|
|
258
|
+
* @param {number} [options.batchSize] - Max mutations per request.
|
|
259
|
+
* @param {AbortSignal} [options.signal] - Lifecycle cancellation signal.
|
|
260
|
+
* @returns {Promise<SyncOfflineReplayResult>} - Mapped replay result.
|
|
261
|
+
*/
|
|
262
|
+
_replayPass({ batchSize, signal }?: {
|
|
263
|
+
batchSize?: number;
|
|
264
|
+
signal?: AbortSignal;
|
|
265
|
+
}): Promise<SyncOfflineReplayResult>;
|
|
266
|
+
/**
|
|
267
|
+
* Builds one signed replay mutation: the signed envelope plus the signed
|
|
268
|
+
* grant the mutation was signed under. Fails closed when the session does
|
|
269
|
+
* not retain that grant.
|
|
270
|
+
* @param {import("./local-mutation-log.js").LocalMutationLogRecord} record - Durable record.
|
|
271
|
+
* @returns {Record<string, ReturnType<typeof JSON.parse>>} - Replay mutation payload.
|
|
272
|
+
*/
|
|
273
|
+
_replayMutation(record: import("./local-mutation-log.js").LocalMutationLogRecord): Record<string, ReturnType<typeof JSON.parse>>;
|
|
274
|
+
/**
|
|
275
|
+
* Normalizes a signed replay response into results keyed by idempotency key.
|
|
276
|
+
* @param {ReturnType<typeof JSON.parse>} response - Raw replay response.
|
|
277
|
+
* @returns {Map<string, Record<string, ReturnType<typeof JSON.parse>>>} - Results by idempotency key.
|
|
278
|
+
*/
|
|
279
|
+
_replayResultsById(response: ReturnType<typeof JSON.parse>): Map<string, Record<string, ReturnType<typeof JSON.parse>>>;
|
|
280
|
+
/**
|
|
281
|
+
* Exports the durable non-terminal mutations of every session log as one
|
|
282
|
+
* signed peer bundle.
|
|
283
|
+
* @param {object} [options] - Export options.
|
|
284
|
+
* @param {import("./local-mutation-log.js").LocalMutationStatus[]} [options.statuses] - Statuses to export.
|
|
285
|
+
* @param {() => Date} [options.now] - Export clock.
|
|
286
|
+
* @returns {Promise<import("./peer-mutation-bundle.js").PeerMutationBundle>} - Signed peer bundle.
|
|
287
|
+
*/
|
|
288
|
+
exportBundle(options?: {
|
|
289
|
+
statuses?: import("./local-mutation-log.js").LocalMutationStatus[];
|
|
290
|
+
now?: () => Date;
|
|
291
|
+
}): Promise<import("./peer-mutation-bundle.js").PeerMutationBundle>;
|
|
292
|
+
/**
|
|
293
|
+
* Imports a peer bundle: every entry is verified against the configured
|
|
294
|
+
* backend public key before it is appended to a local mutation log. Entries
|
|
295
|
+
* already present by idempotency key are skipped as duplicates.
|
|
296
|
+
* @param {object} args - Import args.
|
|
297
|
+
* @param {import("./peer-mutation-bundle.js").PeerMutationBundle} args.bundle - Peer bundle to import.
|
|
298
|
+
* @param {Array<import("./offline-grant.js").SignedOfflineGrant>} [args.signedOfflineGrants] - Grants the peer signed its mutations under. They are retained so imported mutations replay with the grant their signer used.
|
|
299
|
+
* @param {import("./local-mutation-log.js").default} [args.mutationLog] - Target log. Defaults to the first session log.
|
|
300
|
+
* @returns {Promise<import("./peer-mutation-bundle.js").PeerMutationBundleImportResult>} - Import result.
|
|
301
|
+
*/
|
|
302
|
+
importBundle({ bundle, mutationLog, signedOfflineGrants }: {
|
|
303
|
+
bundle: import("./peer-mutation-bundle.js").PeerMutationBundle;
|
|
304
|
+
signedOfflineGrants?: Array<import("./offline-grant.js").SignedOfflineGrant>;
|
|
305
|
+
mutationLog?: import("./local-mutation-log.js").default;
|
|
306
|
+
}): Promise<import("./peer-mutation-bundle.js").PeerMutationBundleImportResult>;
|
|
307
|
+
/**
|
|
308
|
+
* Persists retained grants through the optional app-owned grant storage.
|
|
309
|
+
* @returns {Promise<void>} - Resolves after retention is persisted.
|
|
310
|
+
*/
|
|
311
|
+
_persistGrants(): Promise<void>;
|
|
312
|
+
/**
|
|
313
|
+
* Returns the session clock.
|
|
314
|
+
* @returns {Date} - Current time.
|
|
315
|
+
*/
|
|
316
|
+
_now(): Date;
|
|
317
|
+
/**
|
|
318
|
+
* Returns the device identity or fails closed.
|
|
319
|
+
* @returns {SyncOfflineDeviceIdentity} - Device identity.
|
|
320
|
+
*/
|
|
321
|
+
_requireIdentity(): SyncOfflineDeviceIdentity;
|
|
322
|
+
/**
|
|
323
|
+
* Returns the live grant or fails closed.
|
|
324
|
+
* @returns {import("./offline-grant.js").SignedOfflineGrant} - Live grant.
|
|
325
|
+
*/
|
|
326
|
+
_requireLiveGrant(): import("./offline-grant.js").SignedOfflineGrant;
|
|
327
|
+
}
|
|
328
|
+
//# sourceMappingURL=sync-offline-session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-offline-session.d.ts","sourceRoot":"","sources":["../../../src/sync/sync-offline-session.js"],"names":[],"m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