@comapeo/core 2.0.0 → 2.1.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/blob-store/index.d.ts +23 -49
- package/dist/blob-store/index.d.ts.map +1 -1
- package/dist/constants.d.ts +2 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/core-manager/index.d.ts +10 -0
- package/dist/core-manager/index.d.ts.map +1 -1
- package/dist/core-ownership.d.ts.map +1 -1
- package/dist/datastore/index.d.ts +5 -4
- package/dist/datastore/index.d.ts.map +1 -1
- package/dist/generated/extensions.d.ts +31 -0
- package/dist/generated/extensions.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/drizzle-helpers.d.ts +6 -0
- package/dist/lib/drizzle-helpers.d.ts.map +1 -0
- package/dist/lib/error.d.ts +37 -0
- package/dist/lib/error.d.ts.map +1 -0
- package/dist/lib/get-own.d.ts +9 -0
- package/dist/lib/get-own.d.ts.map +1 -0
- package/dist/lib/is-hostname-ip-address.d.ts +17 -0
- package/dist/lib/is-hostname-ip-address.d.ts.map +1 -0
- package/dist/lib/omit.d.ts +17 -0
- package/dist/lib/omit.d.ts.map +1 -0
- package/dist/lib/ws-core-replicator.d.ts +11 -0
- package/dist/lib/ws-core-replicator.d.ts.map +1 -0
- package/dist/mapeo-manager.d.ts +18 -22
- package/dist/mapeo-manager.d.ts.map +1 -1
- package/dist/mapeo-project.d.ts +454 -37
- package/dist/mapeo-project.d.ts.map +1 -1
- package/dist/member-api.d.ts +40 -1
- package/dist/member-api.d.ts.map +1 -1
- package/dist/schema/client.d.ts +17 -5
- package/dist/schema/client.d.ts.map +1 -1
- package/dist/schema/project.d.ts +211 -1
- package/dist/schema/project.d.ts.map +1 -1
- package/dist/sync/peer-sync-controller.d.ts.map +1 -1
- package/dist/sync/sync-api.d.ts +28 -2
- package/dist/sync/sync-api.d.ts.map +1 -1
- package/dist/translation-api.d.ts.map +1 -1
- package/dist/types.d.ts +3 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/drizzle/client/0001_chubby_cargill.sql +12 -0
- package/drizzle/client/meta/0001_snapshot.json +208 -0
- package/drizzle/client/meta/_journal.json +7 -0
- package/drizzle/project/0001_medical_wendell_rand.sql +22 -0
- package/drizzle/project/meta/0001_snapshot.json +1267 -0
- package/drizzle/project/meta/_journal.json +7 -0
- package/package.json +10 -6
- package/src/blob-store/index.js +20 -4
- package/src/config-import.js +0 -1
- package/src/constants.js +4 -1
- package/src/core-manager/index.js +58 -2
- package/src/core-ownership.js +5 -2
- package/src/datastore/README.md +1 -2
- package/src/datastore/index.js +4 -5
- package/src/fastify-plugins/blobs.js +1 -0
- package/src/fastify-plugins/maps.js +11 -3
- package/src/generated/extensions.d.ts +31 -0
- package/src/generated/extensions.js +150 -0
- package/src/generated/extensions.ts +181 -0
- package/src/index.js +10 -0
- package/src/invite-api.js +1 -1
- package/src/lib/drizzle-helpers.js +79 -0
- package/src/lib/error.js +47 -0
- package/src/lib/get-own.js +10 -0
- package/src/lib/is-hostname-ip-address.js +26 -0
- package/src/lib/omit.js +28 -0
- package/src/lib/ws-core-replicator.js +47 -0
- package/src/mapeo-manager.js +76 -53
- package/src/mapeo-project.js +155 -46
- package/src/member-api.js +253 -2
- package/src/schema/client.js +4 -3
- package/src/schema/project.js +7 -0
- package/src/sync/peer-sync-controller.js +1 -0
- package/src/sync/sync-api.js +171 -3
- package/src/translation-api.js +2 -2
- package/src/types.ts +4 -3
- package/src/utils.js +11 -14
- package/dist/lib/timing-safe-equal.d.ts +0 -15
- package/dist/lib/timing-safe-equal.d.ts.map +0 -1
- package/src/lib/timing-safe-equal.js +0 -34
package/src/utils.js
CHANGED
|
@@ -2,6 +2,7 @@ import sodium from 'sodium-universal'
|
|
|
2
2
|
import { keyToPublicId } from '@mapeo/crypto'
|
|
3
3
|
import { createHash } from 'node:crypto'
|
|
4
4
|
import stableStringify from 'json-stable-stringify'
|
|
5
|
+
import { omit } from './lib/omit.js'
|
|
5
6
|
|
|
6
7
|
const PROJECT_INVITE_ID_SALT = Buffer.from('mapeo project invite id', 'ascii')
|
|
7
8
|
|
|
@@ -95,20 +96,16 @@ export function deNullify(obj) {
|
|
|
95
96
|
* @returns {Omit<T, 'docId' | 'versionId' | 'originalVersionId' | 'links' | 'forks' | 'createdAt' | 'updatedAt' | 'deleted'>}
|
|
96
97
|
*/
|
|
97
98
|
export function valueOf(doc) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
...rest
|
|
109
|
-
} = doc
|
|
110
|
-
/* eslint-enable no-unused-vars */
|
|
111
|
-
return rest
|
|
99
|
+
return omit(doc, [
|
|
100
|
+
'docId',
|
|
101
|
+
'versionId',
|
|
102
|
+
'originalVersionId',
|
|
103
|
+
'links',
|
|
104
|
+
'forks',
|
|
105
|
+
'createdAt',
|
|
106
|
+
'updatedAt',
|
|
107
|
+
'deleted',
|
|
108
|
+
])
|
|
112
109
|
}
|
|
113
110
|
|
|
114
111
|
/**
|
|
@@ -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 | NodeJS.ArrayBufferView} T
|
|
10
|
-
* @param {T} a
|
|
11
|
-
* @param {T} b
|
|
12
|
-
* @returns {boolean}
|
|
13
|
-
*/
|
|
14
|
-
export default function timingSafeEqual<T extends string | NodeJS.ArrayBufferView>(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,wCAL+C,CAAC,SAAlC,MAAM,GAAG,MAAM,CAAC,eAAgB,KACnC,CAAC,KACD,CAAC,GACC,OAAO,CASnB"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import * as crypto from 'node:crypto'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @param {string | NodeJS.ArrayBufferView} value
|
|
5
|
-
* @returns {NodeJS.ArrayBufferView}
|
|
6
|
-
*/
|
|
7
|
-
const bufferify = (value) =>
|
|
8
|
-
// We use UTF-16 because it's the only supported encoding that doesn't
|
|
9
|
-
// touch surrogate pairs. See [this post][0] for more details.
|
|
10
|
-
//
|
|
11
|
-
// [0]: https://evanhahn.com/crypto-timingsafeequal-with-strings/
|
|
12
|
-
typeof value === 'string' ? Buffer.from(value, 'utf16le') : value
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Compare two values in constant time.
|
|
16
|
-
*
|
|
17
|
-
* Useful when you want to avoid leaking data.
|
|
18
|
-
*
|
|
19
|
-
* Like `crypto.timingSafeEqual`, but works with strings and doesn't throw if
|
|
20
|
-
* lengths differ.
|
|
21
|
-
*
|
|
22
|
-
* @template {string | NodeJS.ArrayBufferView} T
|
|
23
|
-
* @param {T} a
|
|
24
|
-
* @param {T} b
|
|
25
|
-
* @returns {boolean}
|
|
26
|
-
*/
|
|
27
|
-
export default function timingSafeEqual(a, b) {
|
|
28
|
-
const bufferA = bufferify(a)
|
|
29
|
-
const bufferB = bufferify(b)
|
|
30
|
-
return (
|
|
31
|
-
bufferA.byteLength === bufferB.byteLength &&
|
|
32
|
-
crypto.timingSafeEqual(bufferA, bufferB)
|
|
33
|
-
)
|
|
34
|
-
}
|