@comapeo/core 3.0.0-0 → 3.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.
- package/dist/local-peers.d.ts.map +1 -1
- package/dist/sync/sync-api.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/local-peers.js +64 -21
- package/dist/blob-store/live-download.d.ts +0 -107
- package/dist/blob-store/live-download.d.ts.map +0 -1
- package/dist/capabilities.d.ts +0 -121
- package/dist/capabilities.d.ts.map +0 -1
- package/dist/core-manager/compat.d.ts +0 -4
- package/dist/core-manager/compat.d.ts.map +0 -1
- package/dist/discovery/dns-sd.d.ts +0 -54
- package/dist/discovery/dns-sd.d.ts.map +0 -1
- package/dist/fastify-plugins/maps/index.d.ts +0 -11
- package/dist/fastify-plugins/maps/index.d.ts.map +0 -1
- package/dist/fastify-plugins/maps/offline-fallback-map.d.ts +0 -12
- package/dist/fastify-plugins/maps/offline-fallback-map.d.ts.map +0 -1
- package/dist/fastify-plugins/maps/static-maps.d.ts +0 -11
- package/dist/fastify-plugins/maps/static-maps.d.ts.map +0 -1
- package/dist/invite-api.d.ts +0 -70
- package/dist/invite-api.d.ts.map +0 -1
- package/dist/lib/timing-safe-equal.d.ts +0 -15
- package/dist/lib/timing-safe-equal.d.ts.map +0 -1
- package/dist/media-server.d.ts +0 -36
- package/dist/media-server.d.ts.map +0 -1
- package/dist/server/ws-core-replicator.d.ts +0 -6
- package/dist/server/ws-core-replicator.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-peers.d.ts","sourceRoot":"","sources":["../src/local-peers.js"],"names":[],"mappings":"AAsCA,mDAAqE;
|
|
1
|
+
{"version":3,"file":"local-peers.d.ts","sourceRoot":"","sources":["../src/local-peers.js"],"names":[],"mappings":"AAsCA,mDAAqE;AAkOrE;;;;;;;;;;GAUG;AAEH,gDAAgD;AAChD;IAYE;;;;OAIG;IACH;;mBAGC;IAED;gBA5PqC,WAAW;q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,kBAFa,IAAI,CAsDhB;IAED;;OAEG;IACH,qBAFa,IAAI,CAQhB;IAED;;;;;;;;;;OAUG;IACH;;yBAOC;IAED;;;;OAIG;IACH,aAGC;IAkBD;;;OAGG;IACH,kDAHW,IAAI,GAAG,MAAM,GACX,IAAI,CAOhB;IAED;;;OAGG;IACH,kBAHW,QAAQ,GACN,OAAO,CAAC,IAAI,CAAC,CAazB;oFAjLmB,2BAElB;IAqIF;;OAEG;IACH,2BAGC;IAED;;OAEG;IACH,kCAGC;IA8BD;;;;OAIG;IACH,wCAJW,MAAM,eACN,WAAW,GACT,OAAO,CAAC,IAAI,CAAC,CA6BzB;IApWC,wBAME;;CA6eL;uBAxlBY,SAAS,GAAG,MAAM;+BAIlB,MAAM,GAAG,SAAS,GAAG,KAAK;;WAMzB,MAAM;YACN,MAAM;gBACN,MAAM;YACN,MAAM;;;;;;mBAMN,OAAO;;;;UACP,MAAM;;;;YACN,MAAM;;;;;;;;;aAMN,mCAAmC;;;;UACnC,mCAAmC;;;;;;aAKnC;QAAE,aAAa,EAAE,OAAO,CAAA;KAAE;;;;UAC1B;QAAE,aAAa,EAAE,OAAO,CAAA;KAAE;;;;2BAC1B,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC;;;kBAKrC,CAAC,SAAS,EAAE,KAAK,KAAK,IAAI;;6BArEX,oBAAoB;0BAEvB,iBAAiB;mCAcR,sBAAsB;uCAEN,aAAa;uBAdzC,cAAc"}
|
package/package.json
CHANGED
package/src/local-peers.js
CHANGED
|
@@ -64,6 +64,7 @@ class Peer {
|
|
|
64
64
|
#deviceType
|
|
65
65
|
#connectedAt = 0
|
|
66
66
|
#disconnectedAt = 0
|
|
67
|
+
#drainedListeners = new Set()
|
|
67
68
|
#protomux
|
|
68
69
|
#log
|
|
69
70
|
|
|
@@ -157,55 +158,94 @@ class Peer {
|
|
|
157
158
|
this.#disconnectedAt = Date.now()
|
|
158
159
|
// This promise should have already resolved, but if the peer never connected then we reject here
|
|
159
160
|
this.#connected.reject(new PeerFailedConnectionError())
|
|
161
|
+
for (const listener of this.#drainedListeners) {
|
|
162
|
+
listener.reject(new Error('RPC Disconnected before sending'))
|
|
163
|
+
}
|
|
164
|
+
this.#drainedListeners.clear()
|
|
160
165
|
this.#log('disconnected')
|
|
161
166
|
}
|
|
167
|
+
|
|
168
|
+
// Call this when the stream has drained all data to the network
|
|
169
|
+
drained() {
|
|
170
|
+
for (const listener of this.#drainedListeners) {
|
|
171
|
+
listener.resolve()
|
|
172
|
+
}
|
|
173
|
+
this.#drainedListeners.clear()
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* @param {boolean} didWrite
|
|
178
|
+
* @returns {Promise<void>}
|
|
179
|
+
*/
|
|
180
|
+
async #waitForDrain(didWrite) {
|
|
181
|
+
if (didWrite) return
|
|
182
|
+
const onDrain = pDefer()
|
|
183
|
+
|
|
184
|
+
this.#drainedListeners.add(onDrain)
|
|
185
|
+
|
|
186
|
+
await onDrain.promise
|
|
187
|
+
}
|
|
188
|
+
|
|
162
189
|
/**
|
|
163
190
|
* @param {Buffer} buf
|
|
191
|
+
* @returns {Promise<void>}
|
|
164
192
|
*/
|
|
165
|
-
[kTestOnlySendRawInvite](buf) {
|
|
193
|
+
async [kTestOnlySendRawInvite](buf) {
|
|
166
194
|
this.#assertConnected()
|
|
167
195
|
const messageType = MESSAGE_TYPES.Invite
|
|
168
|
-
this.#channel.messages[messageType].send(buf)
|
|
196
|
+
await this.#waitForDrain(this.#channel.messages[messageType].send(buf))
|
|
169
197
|
}
|
|
170
|
-
/**
|
|
171
|
-
|
|
198
|
+
/**
|
|
199
|
+
* @param {Invite} invite
|
|
200
|
+
* @returns {Promise<void>}
|
|
201
|
+
*/
|
|
202
|
+
async sendInvite(invite) {
|
|
172
203
|
this.#assertConnected('Peer disconnected before sending invite')
|
|
173
204
|
const buf = Buffer.from(Invite.encode(invite).finish())
|
|
174
205
|
const messageType = MESSAGE_TYPES.Invite
|
|
175
|
-
this.#channel.messages[messageType].send(buf)
|
|
206
|
+
await this.#waitForDrain(this.#channel.messages[messageType].send(buf))
|
|
176
207
|
this.#log('sent invite %h', invite.inviteId)
|
|
177
208
|
}
|
|
178
|
-
/**
|
|
179
|
-
|
|
209
|
+
/**
|
|
210
|
+
* @param {InviteCancel} inviteCancel
|
|
211
|
+
* @returns {Promise<void>}
|
|
212
|
+
*/
|
|
213
|
+
async sendInviteCancel(inviteCancel) {
|
|
180
214
|
this.#assertConnected('Peer disconnected before sending invite cancel')
|
|
181
215
|
const buf = Buffer.from(InviteCancel.encode(inviteCancel).finish())
|
|
182
216
|
const messageType = MESSAGE_TYPES.InviteCancel
|
|
183
|
-
this.#channel.messages[messageType].send(buf)
|
|
217
|
+
await this.#waitForDrain(this.#channel.messages[messageType].send(buf))
|
|
184
218
|
this.#log('sent invite cancel %h', inviteCancel.inviteId)
|
|
185
219
|
}
|
|
186
|
-
/**
|
|
187
|
-
|
|
220
|
+
/**
|
|
221
|
+
* @param {InviteResponse} response
|
|
222
|
+
* @returns {Promise<void>}
|
|
223
|
+
*/
|
|
224
|
+
async sendInviteResponse(response) {
|
|
188
225
|
this.#assertConnected('Peer disconnected before sending invite response')
|
|
189
226
|
const buf = Buffer.from(InviteResponse.encode(response).finish())
|
|
190
227
|
const messageType = MESSAGE_TYPES.InviteResponse
|
|
191
|
-
this.#channel.messages[messageType].send(buf)
|
|
228
|
+
await this.#waitForDrain(this.#channel.messages[messageType].send(buf))
|
|
192
229
|
this.#log('sent response for %h: %s', response.inviteId, response.decision)
|
|
193
230
|
}
|
|
194
231
|
/** @param {ProjectJoinDetails} details */
|
|
195
|
-
sendProjectJoinDetails(details) {
|
|
232
|
+
async sendProjectJoinDetails(details) {
|
|
196
233
|
this.#assertConnected(
|
|
197
234
|
'Peer disconnected before sending project join details'
|
|
198
235
|
)
|
|
199
236
|
const buf = Buffer.from(ProjectJoinDetails.encode(details).finish())
|
|
200
237
|
const messageType = MESSAGE_TYPES.ProjectJoinDetails
|
|
201
|
-
this.#channel.messages[messageType].send(buf)
|
|
238
|
+
await this.#waitForDrain(this.#channel.messages[messageType].send(buf))
|
|
202
239
|
this.#log('sent project join details for %h', details.projectKey)
|
|
203
240
|
}
|
|
204
|
-
/**
|
|
205
|
-
|
|
241
|
+
/**
|
|
242
|
+
* @param {DeviceInfo} deviceInfo
|
|
243
|
+
* @returns {Promise<void>}
|
|
244
|
+
*/
|
|
245
|
+
async sendDeviceInfo(deviceInfo) {
|
|
206
246
|
const buf = Buffer.from(DeviceInfo.encode(deviceInfo).finish())
|
|
207
247
|
const messageType = MESSAGE_TYPES.DeviceInfo
|
|
208
|
-
this.#channel.messages[messageType].send(buf)
|
|
248
|
+
await this.#waitForDrain(this.#channel.messages[messageType].send(buf))
|
|
209
249
|
this.#log('sent deviceInfo %o', deviceInfo)
|
|
210
250
|
}
|
|
211
251
|
/** @param {DeviceInfo} deviceInfo */
|
|
@@ -273,7 +313,7 @@ export class LocalPeers extends TypedEmitter {
|
|
|
273
313
|
async sendInvite(deviceId, invite) {
|
|
274
314
|
await this.#waitForPendingConnections()
|
|
275
315
|
const peer = await this.#getPeerByDeviceId(deviceId)
|
|
276
|
-
peer.sendInvite(invite)
|
|
316
|
+
await peer.sendInvite(invite)
|
|
277
317
|
}
|
|
278
318
|
|
|
279
319
|
/**
|
|
@@ -284,7 +324,7 @@ export class LocalPeers extends TypedEmitter {
|
|
|
284
324
|
async sendInviteCancel(deviceId, inviteCancel) {
|
|
285
325
|
await this.#waitForPendingConnections()
|
|
286
326
|
const peer = await this.#getPeerByDeviceId(deviceId)
|
|
287
|
-
peer.sendInviteCancel(inviteCancel)
|
|
327
|
+
await peer.sendInviteCancel(inviteCancel)
|
|
288
328
|
}
|
|
289
329
|
|
|
290
330
|
/**
|
|
@@ -296,7 +336,7 @@ export class LocalPeers extends TypedEmitter {
|
|
|
296
336
|
async sendInviteResponse(deviceId, inviteResponse) {
|
|
297
337
|
await this.#waitForPendingConnections()
|
|
298
338
|
const peer = await this.#getPeerByDeviceId(deviceId)
|
|
299
|
-
peer.sendInviteResponse(inviteResponse)
|
|
339
|
+
await peer.sendInviteResponse(inviteResponse)
|
|
300
340
|
}
|
|
301
341
|
|
|
302
342
|
/**
|
|
@@ -306,7 +346,7 @@ export class LocalPeers extends TypedEmitter {
|
|
|
306
346
|
async sendProjectJoinDetails(deviceId, details) {
|
|
307
347
|
await this.#waitForPendingConnections()
|
|
308
348
|
const peer = await this.#getPeerByDeviceId(deviceId)
|
|
309
|
-
peer.sendProjectJoinDetails(details)
|
|
349
|
+
await peer.sendProjectJoinDetails(details)
|
|
310
350
|
}
|
|
311
351
|
|
|
312
352
|
/**
|
|
@@ -317,7 +357,7 @@ export class LocalPeers extends TypedEmitter {
|
|
|
317
357
|
async sendDeviceInfo(deviceId, deviceInfo) {
|
|
318
358
|
await this.#waitForPendingConnections()
|
|
319
359
|
const peer = await this.#getPeerByDeviceId(deviceId)
|
|
320
|
-
peer.sendDeviceInfo(deviceInfo)
|
|
360
|
+
await peer.sendDeviceInfo(deviceInfo)
|
|
321
361
|
}
|
|
322
362
|
|
|
323
363
|
/**
|
|
@@ -449,6 +489,9 @@ export class LocalPeers extends TypedEmitter {
|
|
|
449
489
|
this.#emitPeers()
|
|
450
490
|
done()
|
|
451
491
|
},
|
|
492
|
+
ondrain: () => {
|
|
493
|
+
peer.drained()
|
|
494
|
+
},
|
|
452
495
|
})
|
|
453
496
|
channel.open()
|
|
454
497
|
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reduce multiple states into one. Factored out for unit testing because I
|
|
3
|
-
* don't trust my coding. Probably a smarter way to do this, but this works.
|
|
4
|
-
*
|
|
5
|
-
* @param {Iterable<{ state: BlobDownloadState | BlobDownloadStateError }>} liveDownloads
|
|
6
|
-
* @param {{ signal?: AbortSignal }} options
|
|
7
|
-
* @returns {BlobDownloadState | BlobDownloadStateError}
|
|
8
|
-
*/
|
|
9
|
-
export function combineStates(liveDownloads: Iterable<{
|
|
10
|
-
state: BlobDownloadState | BlobDownloadStateError;
|
|
11
|
-
}>, { signal }?: {
|
|
12
|
-
signal?: AbortSignal;
|
|
13
|
-
}): BlobDownloadState | BlobDownloadStateError;
|
|
14
|
-
/**
|
|
15
|
-
* @typedef {object} BlobDownloadState
|
|
16
|
-
* @property {number} haveCount The number of files already downloaded
|
|
17
|
-
* @property {number} haveBytes The bytes already downloaded
|
|
18
|
-
* @property {number} wantCount The number of files pending download
|
|
19
|
-
* @property {number} wantBytes The bytes pending download
|
|
20
|
-
* @property {null} error If status = 'error' then this will be an Error object
|
|
21
|
-
* @property {'checking' | 'downloading' | 'downloaded' | 'aborted'} status
|
|
22
|
-
*/
|
|
23
|
-
/** @typedef {Omit<BlobDownloadState, 'error' | 'status'> & { status: 'error', error: Error }} BlobDownloadStateError */
|
|
24
|
-
/**
|
|
25
|
-
* @typedef {object} BlobDownloadEvents
|
|
26
|
-
* @property {(state: BlobDownloadState | BlobDownloadStateError ) => void} state Emitted with the current download state whenever it changes (not emitted during initial 'checking' status)
|
|
27
|
-
*/
|
|
28
|
-
/**
|
|
29
|
-
* LiveDownload class
|
|
30
|
-
* @extends {TypedEmitter<BlobDownloadEvents>}
|
|
31
|
-
*/
|
|
32
|
-
export class LiveDownload extends TypedEmitter<BlobDownloadEvents> {
|
|
33
|
-
/**
|
|
34
|
-
* Like drive.download() but 'live', and for multiple drives
|
|
35
|
-
* @param {Iterable<import('hyperdrive')>} drives
|
|
36
|
-
* @param {import('./index.js').InternalDriveEmitter} emitter
|
|
37
|
-
* @param {object} options
|
|
38
|
-
* @param {import('../types.js').BlobFilter} [options.filter] Filter blobs of specific types and/or sizes to download
|
|
39
|
-
* @param {AbortSignal} [options.signal]
|
|
40
|
-
*/
|
|
41
|
-
constructor(drives: Iterable<import("hyperdrive")>, emitter: import("./index.js").InternalDriveEmitter, { filter, signal }: {
|
|
42
|
-
filter?: import("../types.js").BlobFilter | undefined;
|
|
43
|
-
signal?: AbortSignal | undefined;
|
|
44
|
-
});
|
|
45
|
-
/**
|
|
46
|
-
* @returns {BlobDownloadState | BlobDownloadStateError}
|
|
47
|
-
*/
|
|
48
|
-
get state(): BlobDownloadState | BlobDownloadStateError;
|
|
49
|
-
#private;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* LiveDownload class
|
|
53
|
-
* @extends {TypedEmitter<BlobDownloadEvents>}
|
|
54
|
-
*/
|
|
55
|
-
export class DriveLiveDownload extends TypedEmitter<BlobDownloadEvents> {
|
|
56
|
-
/**
|
|
57
|
-
* Like drive.download() but 'live',
|
|
58
|
-
* @param {import('hyperdrive')} drive
|
|
59
|
-
* @param {object} options
|
|
60
|
-
* @param {import('../types.js').BlobFilter} [options.filter] Filter blobs of specific types and/or sizes to download
|
|
61
|
-
* @param {AbortSignal} [options.signal]
|
|
62
|
-
*/
|
|
63
|
-
constructor(drive: import("hyperdrive"), { filter, signal }?: {
|
|
64
|
-
filter?: import("../types.js").BlobFilter | undefined;
|
|
65
|
-
signal?: AbortSignal | undefined;
|
|
66
|
-
});
|
|
67
|
-
/**
|
|
68
|
-
* @returns {BlobDownloadState | BlobDownloadStateError}
|
|
69
|
-
*/
|
|
70
|
-
get state(): BlobDownloadState | BlobDownloadStateError;
|
|
71
|
-
#private;
|
|
72
|
-
}
|
|
73
|
-
export type BlobDownloadState = {
|
|
74
|
-
/**
|
|
75
|
-
* The number of files already downloaded
|
|
76
|
-
*/
|
|
77
|
-
haveCount: number;
|
|
78
|
-
/**
|
|
79
|
-
* The bytes already downloaded
|
|
80
|
-
*/
|
|
81
|
-
haveBytes: number;
|
|
82
|
-
/**
|
|
83
|
-
* The number of files pending download
|
|
84
|
-
*/
|
|
85
|
-
wantCount: number;
|
|
86
|
-
/**
|
|
87
|
-
* The bytes pending download
|
|
88
|
-
*/
|
|
89
|
-
wantBytes: number;
|
|
90
|
-
/**
|
|
91
|
-
* If status = 'error' then this will be an Error object
|
|
92
|
-
*/
|
|
93
|
-
error: null;
|
|
94
|
-
status: "checking" | "downloading" | "downloaded" | "aborted";
|
|
95
|
-
};
|
|
96
|
-
export type BlobDownloadStateError = Omit<BlobDownloadState, "error" | "status"> & {
|
|
97
|
-
status: "error";
|
|
98
|
-
error: Error;
|
|
99
|
-
};
|
|
100
|
-
export type BlobDownloadEvents = {
|
|
101
|
-
/**
|
|
102
|
-
* Emitted with the current download state whenever it changes (not emitted during initial 'checking' status)
|
|
103
|
-
*/
|
|
104
|
-
state: (state: BlobDownloadState | BlobDownloadStateError) => void;
|
|
105
|
-
};
|
|
106
|
-
import { TypedEmitter } from 'tiny-typed-emitter';
|
|
107
|
-
//# sourceMappingURL=live-download.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"live-download.d.ts","sourceRoot":"","sources":["../../src/blob-store/live-download.js"],"names":[],"mappings":"AA+RA;;;;;;;GAOG;AACH,6CAJW,QAAQ,CAAC;IAAE,KAAK,EAAE,iBAAiB,GAAG,sBAAsB,CAAA;CAAE,CAAC,eAC/D;IAAE,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,GACtB,iBAAiB,GAAG,sBAAsB,CAqCtD;AApUD;;;;;;;;GAQG;AAEH,wHAAwH;AAExH;;;GAGG;AAEH;;;GAGG;AACH;IAKE;;;;;;;OAOG;IACH,oBANW,QAAQ,CAAC,OAAO,YAAY,CAAC,CAAC,WAC9B,OAAO,YAAY,EAAE,oBAAoB,sBAEjD;QAAmD,MAAM;QAC3B,MAAM;KAAC,EAiCvC;IAED;;OAEG;IACH,wDAEC;;CACF;AAED;;;GAGG;AACH;IAaE;;;;;;OAMG;IACH,mBALW,OAAO,YAAY,CAAC,uBAE5B;QAAmD,MAAM;QAC3B,MAAM;KAAC,EAmBvC;IAED;;OAEG;IACH,wDAyBC;;CAqIF;;;;;eArRa,MAAM;;;;eACN,MAAM;;;;eACN,MAAM;;;;eACN,MAAM;;;;WACN,IAAI;YACJ,UAAU,GAAG,aAAa,GAAG,YAAY,GAAG,SAAS;;qCAGrD,IAAI,CAAC,iBAAiB,EAAE,OAAO,GAAG,QAAQ,CAAC,GAAG;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE;;;;;WAI/E,CAAC,KAAK,EAAE,iBAAiB,GAAG,sBAAsB,KAAM,IAAI;;6BApB7C,oBAAoB"}
|
package/dist/capabilities.d.ts
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
export const COORDINATOR_ROLE_ID: "f7c150f5a3a9a855";
|
|
2
|
-
export const MEMBER_ROLE_ID: "012fd2d431c0bf60";
|
|
3
|
-
export const BLOCKED_ROLE_ID: "9e6d29263cba36c9";
|
|
4
|
-
export const LEFT_ROLE_ID: "8ced989b1904606b";
|
|
5
|
-
/**
|
|
6
|
-
* @typedef {object} DocCapability
|
|
7
|
-
* @property {boolean} readOwn - can read own data
|
|
8
|
-
* @property {boolean} writeOwn - can write own data
|
|
9
|
-
* @property {boolean} readOthers - can read other's data
|
|
10
|
-
* @property {boolean} writeOthers - can edit or delete other's data
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* @typedef {object} Capability
|
|
14
|
-
* @property {string} name
|
|
15
|
-
* @property {Record<import('@mapeo/schema').MapeoDoc['schemaName'], DocCapability>} docs
|
|
16
|
-
* @property {RoleId[]} roleAssignment
|
|
17
|
-
* @property {Record<import('./core-manager/core-index.js').Namespace, 'allowed' | 'blocked'>} sync
|
|
18
|
-
*/
|
|
19
|
-
/**
|
|
20
|
-
* @typedef {typeof COORDINATOR_ROLE_ID | typeof MEMBER_ROLE_ID | typeof BLOCKED_ROLE_ID | typeof LEFT_ROLE_ID} RoleId
|
|
21
|
-
*/
|
|
22
|
-
/**
|
|
23
|
-
* This is currently the same as 'Coordinator' capabilities, but defined
|
|
24
|
-
* separately because the creator should always have ALL capabilities, but we
|
|
25
|
-
* could edit 'Coordinator' capabilities in the future
|
|
26
|
-
*
|
|
27
|
-
* @type {Capability}
|
|
28
|
-
*/
|
|
29
|
-
export const CREATOR_CAPABILITIES: Capability;
|
|
30
|
-
/**
|
|
31
|
-
* These are the capabilities assumed for a device when no capability record can
|
|
32
|
-
* be found. This can happen when an invited device did not manage to sync with
|
|
33
|
-
* the device that invited them, and they then try to sync with someone else. We
|
|
34
|
-
* want them to be able to sync the auth and config store, because that way they
|
|
35
|
-
* may be able to receive their role record, and they can get the project config
|
|
36
|
-
* so that they can start collecting data.
|
|
37
|
-
*
|
|
38
|
-
* @type {Capability}
|
|
39
|
-
*/
|
|
40
|
-
export const NO_ROLE_CAPABILITIES: Capability;
|
|
41
|
-
/** @type {Record<RoleId, Capability>} */
|
|
42
|
-
export const DEFAULT_CAPABILITIES: Record<RoleId, Capability>;
|
|
43
|
-
export class Capabilities {
|
|
44
|
-
static NO_ROLE_CAPABILITIES: Capability;
|
|
45
|
-
/**
|
|
46
|
-
*
|
|
47
|
-
* @param {object} opts
|
|
48
|
-
* @param {import('./datatype/index.js').DataType<
|
|
49
|
-
* import('./datastore/index.js').DataStore<'auth'>,
|
|
50
|
-
* typeof import('./schema/project.js').roleTable,
|
|
51
|
-
* 'role',
|
|
52
|
-
* import('@mapeo/schema').Role,
|
|
53
|
-
* import('@mapeo/schema').RoleValue
|
|
54
|
-
* >} opts.dataType
|
|
55
|
-
* @param {import('./core-ownership.js').CoreOwnership} opts.coreOwnership
|
|
56
|
-
* @param {import('./core-manager/index.js').CoreManager} opts.coreManager
|
|
57
|
-
* @param {Buffer} opts.projectKey
|
|
58
|
-
* @param {Buffer} opts.deviceKey public key of this device
|
|
59
|
-
*/
|
|
60
|
-
constructor({ dataType, coreOwnership, coreManager, projectKey, deviceKey }: {
|
|
61
|
-
dataType: import('./datatype/index.js').DataType<import('./datastore/index.js').DataStore<'auth'>, typeof import('./schema/project.js').roleTable, 'role', import('@mapeo/schema').Role, import('@mapeo/schema').RoleValue>;
|
|
62
|
-
coreOwnership: import('./core-ownership.js').CoreOwnership;
|
|
63
|
-
coreManager: import('./core-manager/index.js').CoreManager;
|
|
64
|
-
projectKey: Buffer;
|
|
65
|
-
deviceKey: Buffer;
|
|
66
|
-
});
|
|
67
|
-
/**
|
|
68
|
-
* Get the capabilities for device `deviceId`.
|
|
69
|
-
*
|
|
70
|
-
* @param {string} deviceId
|
|
71
|
-
* @returns {Promise<Capability>}
|
|
72
|
-
*/
|
|
73
|
-
getCapabilities(deviceId: string): Promise<Capability>;
|
|
74
|
-
/**
|
|
75
|
-
* Get capabilities of all devices in the project. For your own device, if you
|
|
76
|
-
* have not yet synced your own role record, the "no role" capabilties is
|
|
77
|
-
* returned. The project creator will have `CREATOR_CAPABILITIES` unless a
|
|
78
|
-
* different role has been assigned.
|
|
79
|
-
*
|
|
80
|
-
* @returns {Promise<Record<string, Capability>>} Map of deviceId to Capability
|
|
81
|
-
*/
|
|
82
|
-
getAll(): Promise<Record<string, Capability>>;
|
|
83
|
-
/**
|
|
84
|
-
* Assign a role to the specified `deviceId`. Devices without an assigned role
|
|
85
|
-
* are unable to sync, except the project creator that defaults to having all
|
|
86
|
-
* capabilities. Only the project creator can assign their own role. Will
|
|
87
|
-
* throw if the device trying to assign the role lacks the `roleAssignment`
|
|
88
|
-
* capability for the given roleId
|
|
89
|
-
*
|
|
90
|
-
* @param {string} deviceId
|
|
91
|
-
* @param {keyof typeof DEFAULT_CAPABILITIES} roleId
|
|
92
|
-
*/
|
|
93
|
-
assignRole(deviceId: string, roleId: keyof typeof DEFAULT_CAPABILITIES): Promise<void>;
|
|
94
|
-
#private;
|
|
95
|
-
}
|
|
96
|
-
export type DocCapability = {
|
|
97
|
-
/**
|
|
98
|
-
* - can read own data
|
|
99
|
-
*/
|
|
100
|
-
readOwn: boolean;
|
|
101
|
-
/**
|
|
102
|
-
* - can write own data
|
|
103
|
-
*/
|
|
104
|
-
writeOwn: boolean;
|
|
105
|
-
/**
|
|
106
|
-
* - can read other's data
|
|
107
|
-
*/
|
|
108
|
-
readOthers: boolean;
|
|
109
|
-
/**
|
|
110
|
-
* - can edit or delete other's data
|
|
111
|
-
*/
|
|
112
|
-
writeOthers: boolean;
|
|
113
|
-
};
|
|
114
|
-
export type Capability = {
|
|
115
|
-
name: string;
|
|
116
|
-
docs: Record<import('@mapeo/schema').MapeoDoc['schemaName'], DocCapability>;
|
|
117
|
-
roleAssignment: RoleId[];
|
|
118
|
-
sync: Record<import('./core-manager/core-index.js').Namespace, 'allowed' | 'blocked'>;
|
|
119
|
-
};
|
|
120
|
-
export type RoleId = typeof COORDINATOR_ROLE_ID | typeof MEMBER_ROLE_ID | typeof BLOCKED_ROLE_ID | typeof LEFT_ROLE_ID;
|
|
121
|
-
//# sourceMappingURL=capabilities.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../src/capabilities.js"],"names":[],"mappings":"AAKA,qDAAqD;AACrD,gDAAgD;AAChD,iDAAiD;AACjD,8CAA8C;AAE9C;;;;;;GAMG;AAEH;;;;;;GAMG;AAEH;;GAEG;AAEH;;;;;;GAMG;AACH,mCAFU,UAAU,CAkBnB;AAED;;;;;;;;;GASG;AACH,mCAFU,UAAU,CAkBnB;AAED,yCAAyC;AACzC,mCADW,OAAO,MAAM,EAAE,UAAU,CAAC,CAgFpC;AAED;IAOE,wCAAkD;IAElD;;;;;;;;;;;;;;OAcG;IACH;QANW,QAAQ,EANR,OAAO,qBAAqB,EAAE,QAAQ,CAChD,OAAW,sBAAsB,EAAE,SAAS,CAAC,MAAM,CAAC,EACpD,cAAkB,qBAAqB,EAAE,SAAS,EAClD,MAAU,EACV,OAAW,eAAe,EAAE,IAAI,EAChC,OAAW,eAAe,EAAE,SAAS,CAClC;QACyD,aAAa,EAA/D,OAAO,qBAAqB,EAAE,aAAa;QACS,WAAW,EAA/D,OAAO,yBAAyB,EAAE,WAAW;QAChC,UAAU,EAAvB,MAAM;QACO,SAAS,EAAtB,MAAM;OAQhB;IAED;;;;;OAKG;IACH,0BAHW,MAAM,GACJ,QAAQ,UAAU,CAAC,CAuB/B;IAED;;;;;;;OAOG;IACH,UAFa,QAAQ,OAAO,MAAM,EAAE,UAAU,CAAC,CAAC,CAkC/C;IAED;;;;;;;;;OASG;IACH,qBAHW,MAAM,UACN,MAAM,2BAA2B,iBAyD3C;;CAQF;;;;;aAzUa,OAAO;;;;cACP,OAAO;;;;gBACP,OAAO;;;;iBACP,OAAO;;;UAKP,MAAM;UACN,OAAO,OAAO,eAAe,EAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,aAAa,CAAC;oBACrE,MAAM,EAAE;UACR,OAAO,OAAO,8BAA8B,EAAE,SAAS,EAAE,SAAS,GAAG,SAAS,CAAC;;qBAIhF,0BAA0B,GAAG,qBAAqB,GAAG,sBAAsB,GAAG,mBAAmB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compat.d.ts","sourceRoot":"","sources":["../../src/core-manager/compat.js"],"names":[],"mappings":";AAOA,sCAAwB"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {object} MapeoService
|
|
3
|
-
* @property {string} address IPv4 address of service
|
|
4
|
-
* @property {number} port
|
|
5
|
-
* @property {string} name Instance name
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* @typedef {object} DnsSdEvents
|
|
9
|
-
* @property {(service: MapeoService) => void} up
|
|
10
|
-
* @property {(service: MapeoService) => void} down
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* @extends {TypedEmitter<DnsSdEvents>}
|
|
14
|
-
*/
|
|
15
|
-
export class DnsSd extends TypedEmitter<DnsSdEvents> {
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
* @param {object} [opts]
|
|
19
|
-
* @param {string} [opts.name]
|
|
20
|
-
* @param {boolean} [opts.disableIpv6]
|
|
21
|
-
* @param {Logger} [opts.logger]
|
|
22
|
-
*/
|
|
23
|
-
constructor({ name, disableIpv6, logger }?: {
|
|
24
|
-
name?: string | undefined;
|
|
25
|
-
disableIpv6?: boolean | undefined;
|
|
26
|
-
logger?: Logger | undefined;
|
|
27
|
-
} | undefined);
|
|
28
|
-
get name(): string;
|
|
29
|
-
/** @param {number} port */
|
|
30
|
-
advertise(port: number): Promise<void>;
|
|
31
|
-
browse(): void;
|
|
32
|
-
stopAdvertising(): Promise<void>;
|
|
33
|
-
stopBrowsing(): void;
|
|
34
|
-
destroy(): Promise<void>;
|
|
35
|
-
#private;
|
|
36
|
-
}
|
|
37
|
-
export type MapeoService = {
|
|
38
|
-
/**
|
|
39
|
-
* IPv4 address of service
|
|
40
|
-
*/
|
|
41
|
-
address: string;
|
|
42
|
-
port: number;
|
|
43
|
-
/**
|
|
44
|
-
* Instance name
|
|
45
|
-
*/
|
|
46
|
-
name: string;
|
|
47
|
-
};
|
|
48
|
-
export type DnsSdEvents = {
|
|
49
|
-
up: (service: MapeoService) => void;
|
|
50
|
-
down: (service: MapeoService) => void;
|
|
51
|
-
};
|
|
52
|
-
import { TypedEmitter } from 'tiny-typed-emitter';
|
|
53
|
-
import { Logger } from '../logger.js';
|
|
54
|
-
//# sourceMappingURL=dns-sd.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dns-sd.d.ts","sourceRoot":"","sources":["../../src/discovery/dns-sd.js"],"names":[],"mappings":"AAUA;;;;;GAKG;AAEH;;;;GAIG;AAEH;;GAEG;AACH;IAoDE;;;;;;OAMG;IACH;;;;mBAMC;IAED,mBAEC;IAED,2BAA2B;IAC3B,gBADY,MAAM,iBA+BjB;IAED,eAiBC;IAED,iCAeC;IAED,qBAKC;IAED,yBA0BC;;CA+BF;;;;;aA1Na,MAAM;UACN,MAAM;;;;UACN,MAAM;;;kBAKI,YAAY,KAAK,IAAI;oBACrB,YAAY,KAAK,IAAI;;6BApBhB,oBAAoB;uBAM1B,cAAc"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export const PLUGIN_NAME: "mapeo-maps";
|
|
2
|
-
export const DEFAULT_MAPBOX_STYLE_URL: "https://api.mapbox.com/styles/v1/mapbox/outdoors-v12";
|
|
3
|
-
export function plugin(instance: import("fastify").FastifyInstance<import("fastify").RawServerDefault, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, import("fastify").FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault>, opts: MapsPluginOpts): Promise<void>;
|
|
4
|
-
export type MapsPluginOpts = {
|
|
5
|
-
prefix?: string | undefined;
|
|
6
|
-
defaultOnlineStyleUrl?: string | undefined;
|
|
7
|
-
};
|
|
8
|
-
export type MapsPluginContext = {
|
|
9
|
-
getStyleJsonUrl: () => Promise<string>;
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fastify-plugins/maps/index.js"],"names":[],"mappings":"AAYA,uCAAuC;AACvC,8FACwD;;;;;;;qBA8B1C,MAAM,OAAO,CAAC,MAAM,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export const PLUGIN_NAME: "mapeo-static-maps";
|
|
2
|
-
export function plugin(instance: import("fastify").FastifyInstance<import("fastify").RawServerDefault, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, import("fastify").FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault>, opts: OfflineFallbackMapPluginOpts): Promise<void>;
|
|
3
|
-
export type OfflineFallbackMapPluginOpts = {
|
|
4
|
-
prefix?: string | undefined;
|
|
5
|
-
styleJsonPath: string;
|
|
6
|
-
sourcesDir: string;
|
|
7
|
-
};
|
|
8
|
-
export type FallbackMapPluginDecorator = {
|
|
9
|
-
getResolvedStyleJson: (serverAddress: string) => Promise<any>;
|
|
10
|
-
getStyleJsonStats: () => Promise<import("node:fs").Stats>;
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=offline-fallback-map.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"offline-fallback-map.d.ts","sourceRoot":"","sources":["../../../src/fastify-plugins/maps/offline-fallback-map.js"],"names":[],"mappings":"AAWA,8CAA8C;;;;mBAUhC,MAAM;gBACN,MAAM;;;0BAKN,CAAC,aAAa,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC;uBACvC,MAAM,OAAO,CAAC,OAAO,SAAS,EAAE,KAAK,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export const PLUGIN_NAME: "mapeo-static-maps";
|
|
2
|
-
export function plugin(instance: import("fastify").FastifyInstance<import("fastify").RawServerDefault, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, import("fastify").FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault>, opts: StaticMapsPluginOpts): Promise<void>;
|
|
3
|
-
export type StaticMapsPluginOpts = {
|
|
4
|
-
prefix?: string | undefined;
|
|
5
|
-
staticRootDir: string;
|
|
6
|
-
};
|
|
7
|
-
export type StaticMapsPluginDecorator = {
|
|
8
|
-
getResolvedStyleJson: (styleId: string, serverAddress: string) => Promise<string>;
|
|
9
|
-
getStyleJsonStats: (styleId: string) => Promise<import("node:fs").Stats>;
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=static-maps.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"static-maps.d.ts","sourceRoot":"","sources":["../../../src/fastify-plugins/maps/static-maps.js"],"names":[],"mappings":"AAeA,8CAA8C;;;;mBAUhC,MAAM;;;0BAKN,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC;uBAC3D,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,SAAS,EAAE,KAAK,CAAC"}
|
package/dist/invite-api.d.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {Object} InviteApiEvents
|
|
3
|
-
* @property {(invite: Invite) => void} invite-received
|
|
4
|
-
* @property {(invite: Invite, removalReason: InviteRemovalReason) => void} invite-removed
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* @extends {TypedEmitter<InviteApiEvents>}
|
|
8
|
-
*/
|
|
9
|
-
export class InviteApi extends TypedEmitter<InviteApiEvents> {
|
|
10
|
-
/**
|
|
11
|
-
* @param {Object} options
|
|
12
|
-
* @param {import('./local-peers.js').LocalPeers} options.rpc
|
|
13
|
-
* @param {object} options.queries
|
|
14
|
-
* @param {(projectInviteId: Readonly<Buffer>) => undefined | { projectPublicId: string }} options.queries.getProjectByInviteId
|
|
15
|
-
* @param {(projectDetails: Pick<ProjectJoinDetails, 'projectKey' | 'encryptionKeys'> & { projectName: string }) => Promise<string>} options.queries.addProject
|
|
16
|
-
* @param {Logger} [options.logger]
|
|
17
|
-
*/
|
|
18
|
-
constructor({ rpc, queries, logger }: {
|
|
19
|
-
rpc: import("./local-peers.js").LocalPeers;
|
|
20
|
-
queries: {
|
|
21
|
-
getProjectByInviteId: (projectInviteId: Readonly<Buffer>) => undefined | {
|
|
22
|
-
projectPublicId: string;
|
|
23
|
-
};
|
|
24
|
-
addProject: (projectDetails: Pick<ProjectJoinDetails, "projectKey" | "encryptionKeys"> & {
|
|
25
|
-
projectName: string;
|
|
26
|
-
}) => Promise<string>;
|
|
27
|
-
};
|
|
28
|
-
logger?: Logger | undefined;
|
|
29
|
-
});
|
|
30
|
-
rpc: import("./local-peers.js").LocalPeers;
|
|
31
|
-
/**
|
|
32
|
-
* @returns {Array<Invite>}
|
|
33
|
-
*/
|
|
34
|
-
getPending(): Array<Invite>;
|
|
35
|
-
/**
|
|
36
|
-
* Attempt to accept the invite.
|
|
37
|
-
*
|
|
38
|
-
* This can fail if the invitor has canceled the invite or if you cannot
|
|
39
|
-
* connect to the invitor's device.
|
|
40
|
-
*
|
|
41
|
-
* If the invite is accepted and you had other invites to the same project,
|
|
42
|
-
* those invites are removed, and the invitors are told that you're already
|
|
43
|
-
* part of this project.
|
|
44
|
-
*
|
|
45
|
-
* @param {Pick<Invite, 'inviteId'>} invite
|
|
46
|
-
* @returns {Promise<string>}
|
|
47
|
-
*/
|
|
48
|
-
accept({ inviteId: inviteIdString }: Pick<Invite, "inviteId">): Promise<string>;
|
|
49
|
-
/**
|
|
50
|
-
* @param {Pick<Invite, 'inviteId'>} invite
|
|
51
|
-
* @returns {void}
|
|
52
|
-
*/
|
|
53
|
-
reject({ inviteId: inviteIdString }: Pick<Invite, "inviteId">): void;
|
|
54
|
-
#private;
|
|
55
|
-
}
|
|
56
|
-
export type InviteInternal = InviteRpcMessage & {
|
|
57
|
-
receivedAt: number;
|
|
58
|
-
};
|
|
59
|
-
export type Invite = MapBuffers<InviteInternal>;
|
|
60
|
-
export type InviteRemovalReason = ("accepted" | "rejected" | "canceled" | "accepted other" | "connection error" | "internal error");
|
|
61
|
-
export type InviteApiEvents = {
|
|
62
|
-
"invite-received": (invite: Invite) => void;
|
|
63
|
-
"invite-removed": (invite: Invite, removalReason: InviteRemovalReason) => void;
|
|
64
|
-
};
|
|
65
|
-
import { TypedEmitter } from 'tiny-typed-emitter';
|
|
66
|
-
import type { ProjectJoinDetails } from './generated/rpc.js';
|
|
67
|
-
import { Logger } from './logger.js';
|
|
68
|
-
import type { Invite as InviteRpcMessage } from './generated/rpc.js';
|
|
69
|
-
import type { MapBuffers } from './types.js';
|
|
70
|
-
//# sourceMappingURL=invite-api.d.ts.map
|
package/dist/invite-api.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invite-api.d.ts","sourceRoot":"","sources":["../src/invite-api.js"],"names":[],"mappings":"AAiJA;;;;GAIG;AAEH;;GAEG;AACH;IAME;;;;;;;OAOG;IACH,sCANG;QAAuD,GAAG,EAAlD,OAAO,kBAAkB,EAAE,UAAU;QACrB,OAAO,EAC/B;YAAwG,oBAAoB,EAApH,CAAC,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,KAAK,SAAS,GAAG;gBAAE,eAAe,EAAE,MAAM,CAAA;aAAE;YAC4D,UAAU,EAApJ,CAAC,cAAc,EAAE,IAAI,CAAC,kBAAkB,EAAE,YAAY,GAAG,gBAAgB,CAAC,GAAG;gBAAE,WAAW,EAAE,MAAM,CAAA;aAAE,KAAK,OAAO,CAAC,MAAM,CAAC;SAChI;QAAyB,MAAM;KAAC,EA0BlC;IAnBC,2CAAc;IAsFhB;;OAEG;IACH,cAFa,KAAK,CAAC,MAAM,CAAC,CAMzB;IAED;;;;;;;;;;;;OAYG;IACH,qCAHW,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,GACtB,OAAO,CAAC,MAAM,CAAC,CAkI3B;IAED;;;OAGG;IACH,qCAHW,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,GACtB,IAAI,CAuBhB;;CACF;6BA7ZY,gBAAgB,GAAG;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE;qBAGxC,WAAW,cAAc,CAAC;kCAG3B,CACZ,UAAa,GACb,UAAa,GACb,UAAa,GACb,gBAAmB,GACnB,kBAAqB,GACrB,gBAAmB,CAChB;;uBA8GU,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI;sBACxB,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,mBAAmB,KAAK,IAAI;;6BApJ7C,oBAAoB;wCAavC,oBAAoB;uBAPP,aAAa;gDAO1B,oBAAoB;gCANE,YAAY"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compare two values in constant time.
|
|
3
|
-
*
|
|
4
|
-
* Useful when you want to avoid leaking data.
|
|
5
|
-
*
|
|
6
|
-
* Like `crypto.timingSafeEqual`, but works with strings and doesn't throw if
|
|
7
|
-
* lengths differ.
|
|
8
|
-
*
|
|
9
|
-
* @template {string | Uint8Array} T
|
|
10
|
-
* @param {T} a
|
|
11
|
-
* @param {T} b
|
|
12
|
-
* @returns {boolean}
|
|
13
|
-
*/
|
|
14
|
-
export default function timingSafeEqual<T extends string | Uint8Array>(a: T, b: T): boolean;
|
|
15
|
-
//# sourceMappingURL=timing-safe-equal.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"timing-safe-equal.d.ts","sourceRoot":"","sources":["../../src/lib/timing-safe-equal.js"],"names":[],"mappings":"AAaA;;;;;;;;;;;;GAYG;AACH,wCALmC,CAAC,SAAtB,MAAM,GAAG,UAAW,KACvB,CAAC,KACD,CAAC,GACC,OAAO,CASnB"}
|
package/dist/media-server.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
export const BLOBS_PREFIX: "blobs";
|
|
2
|
-
export const ICONS_PREFIX: "icons";
|
|
3
|
-
/**
|
|
4
|
-
* @typedef {Object} StartOpts
|
|
5
|
-
*
|
|
6
|
-
* @property {string} [host]
|
|
7
|
-
* @property {number} [port]
|
|
8
|
-
*/
|
|
9
|
-
export class MediaServer {
|
|
10
|
-
/**
|
|
11
|
-
* @param {object} params
|
|
12
|
-
* @param {(projectPublicId: string) => Promise<import('./mapeo-project.js').MapeoProject>} params.getProject
|
|
13
|
-
* @param {import('fastify').FastifyServerOptions['logger']} [params.logger]
|
|
14
|
-
*/
|
|
15
|
-
constructor({ getProject, logger }: {
|
|
16
|
-
getProject: (projectPublicId: string) => Promise<import('./mapeo-project.js').MapeoProject>;
|
|
17
|
-
logger?: import('fastify').FastifyServerOptions['logger'];
|
|
18
|
-
});
|
|
19
|
-
/**
|
|
20
|
-
* @param {StartOpts} [opts]
|
|
21
|
-
*/
|
|
22
|
-
start(opts?: StartOpts | undefined): Promise<void>;
|
|
23
|
-
started(): Promise<void>;
|
|
24
|
-
stop(): Promise<void>;
|
|
25
|
-
/**
|
|
26
|
-
* @param {'blobs' | 'icons'} mediaType
|
|
27
|
-
* @returns {Promise<string>}
|
|
28
|
-
*/
|
|
29
|
-
getMediaAddress(mediaType: 'blobs' | 'icons'): Promise<string>;
|
|
30
|
-
#private;
|
|
31
|
-
}
|
|
32
|
-
export type StartOpts = {
|
|
33
|
-
host?: string | undefined;
|
|
34
|
-
port?: number | undefined;
|
|
35
|
-
};
|
|
36
|
-
//# sourceMappingURL=media-server.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"media-server.d.ts","sourceRoot":"","sources":["../src/media-server.js"],"names":[],"mappings":"AAWA,mCAAmC;AACnC,mCAAmC;AAEnC;;;;;GAKG;AAEH;IAOE;;;;OAIG;IACH;sCAH6B,MAAM,KAAK,QAAQ,OAAO,oBAAoB,EAAE,YAAY,CAAC;iBAC/E,OAAO,SAAS,EAAE,oBAAoB,CAAC,QAAQ,CAAC;OA0B1D;IAoDD;;OAEG;IACH,mDAEC;IAED,yBAEC;IAED,sBAEC;IAED;;;OAGG;IACH,2BAHW,OAAO,GAAG,OAAO,GACf,QAAQ,MAAM,CAAC,CAuB3B;;CACF"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {import('ws').WebSocket} ws
|
|
3
|
-
* @param {import('../types.js').ReplicationStream} replicationStream
|
|
4
|
-
*/
|
|
5
|
-
export function wsCoreReplicator(ws: import("ws").WebSocket, replicationStream: import("../types.js").ReplicationStream): Promise<void>;
|
|
6
|
-
//# sourceMappingURL=ws-core-replicator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ws-core-replicator.d.ts","sourceRoot":"","sources":["../../src/server/ws-core-replicator.js"],"names":[],"mappings":"AAIA;;;GAGG;AACH,qCAHW,OAAO,IAAI,EAAE,SAAS,qBACtB,OAAO,aAAa,EAAE,iBAAiB,iBAmBjD"}
|