@powersync/lib-services-framework 0.9.4 → 0.9.5
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/ip/lookup.d.ts
CHANGED
|
@@ -9,6 +9,9 @@ export interface LookupOptions {
|
|
|
9
9
|
*
|
|
10
10
|
* If one of the hostnames is an IP, this synchronously validates it.
|
|
11
11
|
*
|
|
12
|
+
* Each entry must be a normalized hostname (no port, no IPv6 brackets); pass
|
|
13
|
+
* socket-address inputs through {@link hostnameFromSocketAddress} first.
|
|
14
|
+
*
|
|
12
15
|
* @returns a function to use as the `lookup` option in `net.connect`.
|
|
13
16
|
*/
|
|
14
17
|
export declare function makeMultiHostnameLookupFunction(hostnames: string[], lookupOptions: LookupOptions): net.LookupFunction | undefined;
|
|
@@ -17,6 +20,9 @@ export declare function makeMultiHostnameLookupFunction(hostnames: string[], loo
|
|
|
17
20
|
*
|
|
18
21
|
* If hostname is an IP, this synchronously validates it.
|
|
19
22
|
*
|
|
23
|
+
* `hostname` must be normalized (no port, no IPv6 brackets); pass socket-address
|
|
24
|
+
* inputs through {@link hostnameFromSocketAddress} first.
|
|
25
|
+
*
|
|
20
26
|
* @returns a function to use as the `lookup` option in `net.connect`.
|
|
21
27
|
*/
|
|
22
28
|
export declare function makeHostnameLookupFunction(hostname: string, lookupOptions: LookupOptions): net.LookupFunction | undefined;
|
|
@@ -31,14 +37,20 @@ export declare function makeHostnameLookupFunction(hostname: string, lookupOptio
|
|
|
31
37
|
*/
|
|
32
38
|
export declare function makeLookupFunction(lookupOptions: LookupOptions): net.LookupFunction | undefined;
|
|
33
39
|
/**
|
|
34
|
-
* Validate IPs synchronously.
|
|
35
|
-
*
|
|
36
|
-
* If the hostname is not an ip, this does nothing.
|
|
40
|
+
* Validate IPs synchronously. If the hostname is not an IP, this does nothing.
|
|
37
41
|
*
|
|
38
|
-
*
|
|
39
|
-
* @
|
|
42
|
+
* `hostname` must be normalized (no port, no IPv6 brackets); pass socket-address
|
|
43
|
+
* inputs through {@link hostnameFromSocketAddress} first, otherwise `[::1]` or
|
|
44
|
+
* `host:port` will fail `ip.isValid` and silently fall through to the DNS path.
|
|
40
45
|
*/
|
|
41
46
|
export declare function validateIpHostname(hostname: string, options: LookupOptions): void;
|
|
47
|
+
/**
|
|
48
|
+
* Normalize a socket address (`host[:port]`, with IPv6 hosts optionally bracketed)
|
|
49
|
+
* to a bare hostname. Used for `URL.host`/`URL.hostname` and
|
|
50
|
+
* `mongodb-connection-string-url`'s `uri.hosts` entries. Non-IP input is returned
|
|
51
|
+
* unchanged (downstream falls through to the DNS path).
|
|
52
|
+
*/
|
|
53
|
+
export declare function hostnameFromSocketAddress(socketAddress: string): string;
|
|
42
54
|
/**
|
|
43
55
|
* Resolve IP, and check that it is in an allowed range.
|
|
44
56
|
*/
|
package/dist/ip/lookup.js
CHANGED
|
@@ -7,10 +7,12 @@ import * as net from 'node:net';
|
|
|
7
7
|
*
|
|
8
8
|
* If one of the hostnames is an IP, this synchronously validates it.
|
|
9
9
|
*
|
|
10
|
+
* Each entry must be a normalized hostname (no port, no IPv6 brackets); pass
|
|
11
|
+
* socket-address inputs through {@link hostnameFromSocketAddress} first.
|
|
12
|
+
*
|
|
10
13
|
* @returns a function to use as the `lookup` option in `net.connect`.
|
|
11
14
|
*/
|
|
12
15
|
export function makeMultiHostnameLookupFunction(hostnames, lookupOptions) {
|
|
13
|
-
// If any of the hostnames are IPs, validate them synchronously
|
|
14
16
|
for (let host of hostnames) {
|
|
15
17
|
validateIpHostname(host, lookupOptions);
|
|
16
18
|
}
|
|
@@ -21,6 +23,9 @@ export function makeMultiHostnameLookupFunction(hostnames, lookupOptions) {
|
|
|
21
23
|
*
|
|
22
24
|
* If hostname is an IP, this synchronously validates it.
|
|
23
25
|
*
|
|
26
|
+
* `hostname` must be normalized (no port, no IPv6 brackets); pass socket-address
|
|
27
|
+
* inputs through {@link hostnameFromSocketAddress} first.
|
|
28
|
+
*
|
|
24
29
|
* @returns a function to use as the `lookup` option in `net.connect`.
|
|
25
30
|
*/
|
|
26
31
|
export function makeHostnameLookupFunction(hostname, lookupOptions) {
|
|
@@ -57,12 +62,11 @@ export function makeLookupFunction(lookupOptions) {
|
|
|
57
62
|
};
|
|
58
63
|
}
|
|
59
64
|
/**
|
|
60
|
-
* Validate IPs synchronously.
|
|
65
|
+
* Validate IPs synchronously. If the hostname is not an IP, this does nothing.
|
|
61
66
|
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* @param options
|
|
67
|
+
* `hostname` must be normalized (no port, no IPv6 brackets); pass socket-address
|
|
68
|
+
* inputs through {@link hostnameFromSocketAddress} first, otherwise `[::1]` or
|
|
69
|
+
* `host:port` will fail `ip.isValid` and silently fall through to the DNS path.
|
|
66
70
|
*/
|
|
67
71
|
export function validateIpHostname(hostname, options) {
|
|
68
72
|
const { reject_ip_ranges: reject_ranges } = options;
|
|
@@ -70,8 +74,7 @@ export function validateIpHostname(hostname, options) {
|
|
|
70
74
|
// Treat as a DNS name.
|
|
71
75
|
return;
|
|
72
76
|
}
|
|
73
|
-
const
|
|
74
|
-
const parsed = ip.parse(ipaddr);
|
|
77
|
+
const parsed = ip.parse(hostname);
|
|
75
78
|
const rejectLocal = reject_ranges.includes('local');
|
|
76
79
|
const rejectSubnets = reject_ranges.filter((range) => range != 'local');
|
|
77
80
|
const reject = { blocked: (rejectSubnets ?? []).map((r) => ip.parseCIDR(r)) };
|
|
@@ -80,7 +83,7 @@ export function validateIpHostname(hostname, options) {
|
|
|
80
83
|
}
|
|
81
84
|
if (ip.subnetMatch(parsed, reject) == 'blocked') {
|
|
82
85
|
// Ranges explicitly blocked, e.g. private IPv6 ranges
|
|
83
|
-
throw new ServiceError(ErrorCode.PSYNC_S2203, `IPs in this range are not supported: ${
|
|
86
|
+
throw new ServiceError(ErrorCode.PSYNC_S2203, `IPs in this range are not supported: ${hostname}`);
|
|
84
87
|
}
|
|
85
88
|
if (!rejectLocal) {
|
|
86
89
|
return;
|
|
@@ -95,8 +98,21 @@ export function validateIpHostname(hostname, options) {
|
|
|
95
98
|
}
|
|
96
99
|
else {
|
|
97
100
|
// Do not connect to any reserved IPs, including loopback and private ranges
|
|
98
|
-
throw new ServiceError(ErrorCode.PSYNC_S2203, `IPs in this range are not supported: ${
|
|
101
|
+
throw new ServiceError(ErrorCode.PSYNC_S2203, `IPs in this range are not supported: ${hostname}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Normalize a socket address (`host[:port]`, with IPv6 hosts optionally bracketed)
|
|
106
|
+
* to a bare hostname. Used for `URL.host`/`URL.hostname` and
|
|
107
|
+
* `mongodb-connection-string-url`'s `uri.hosts` entries. Non-IP input is returned
|
|
108
|
+
* unchanged (downstream falls through to the DNS path).
|
|
109
|
+
*/
|
|
110
|
+
export function hostnameFromSocketAddress(socketAddress) {
|
|
111
|
+
const parsed = net.SocketAddress.parse(socketAddress);
|
|
112
|
+
if (parsed != null) {
|
|
113
|
+
return parsed.address;
|
|
99
114
|
}
|
|
115
|
+
return socketAddress;
|
|
100
116
|
}
|
|
101
117
|
/**
|
|
102
118
|
* Resolve IP, and check that it is in an allowed range.
|
package/dist/ip/lookup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lookup.js","sourceRoot":"","sources":["../../src/ip/lookup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE3B,OAAO,KAAK,IAAI,MAAM,mBAAmB,CAAC;AAC1C,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAOhC
|
|
1
|
+
{"version":3,"file":"lookup.js","sourceRoot":"","sources":["../../src/ip/lookup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,MA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OAAO,eAAe,CAAC;AACzB,CAAC"}
|
|
@@ -3,7 +3,7 @@ export const BufferNodeType = {
|
|
|
3
3
|
keyword: 'nodeType',
|
|
4
4
|
metaSchema: {
|
|
5
5
|
type: 'string',
|
|
6
|
-
enum: ['buffer', 'date']
|
|
6
|
+
enum: ['bigint', 'buffer', 'date']
|
|
7
7
|
},
|
|
8
8
|
error: {
|
|
9
9
|
message: ({ schemaCode }) => {
|
|
@@ -12,6 +12,9 @@ export const BufferNodeType = {
|
|
|
12
12
|
},
|
|
13
13
|
code(context) {
|
|
14
14
|
switch (context.schema) {
|
|
15
|
+
case 'bigint': {
|
|
16
|
+
return context.fail(ajv._ `typeof ${context.data} != 'bigint'`);
|
|
17
|
+
}
|
|
15
18
|
case 'buffer': {
|
|
16
19
|
return context.fail(ajv._ `!Buffer.isBuffer(${context.data})`);
|
|
17
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keywords.js","sourceRoot":"","sources":["../../../src/schema/json-schema/keywords.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAE3B,MAAM,CAAC,MAAM,cAAc,GAA0B;IACnD,OAAO,EAAE,UAAU;IACnB,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"keywords.js","sourceRoot":"","sources":["../../../src/schema/json-schema/keywords.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAE3B,MAAM,CAAC,MAAM,cAAc,GAA0B;IACnD,OAAO,EAAE,UAAU;IACnB,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC;KACnC;IACD,KAAK,EAAE;QACL,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE;YAC1B,OAAO,GAAG,CAAC,GAAG,CAAA,eAAe,UAAU,EAAE,CAAC;QAC5C,CAAC;KACF;IACD,IAAI,CAAC,OAAO;QACV,QAAQ,OAAO,CAAC,MAAM,EAAE,CAAC;YACvB,KAAK,QAAQ,CAAC,CAAC,CAAC;gBACd,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA,UAAU,OAAO,CAAC,IAAI,cAAc,CAAC,CAAC;YACjE,CAAC;YACD,KAAK,QAAQ,CAAC,CAAC,CAAC;gBACd,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA,oBAAoB,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC;YAChE,CAAC;YACD,KAAK,MAAM,CAAC,CAAC,CAAC;gBACZ,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA,KAAK,OAAO,CAAC,IAAI,mBAAmB,CAAC,CAAC;YACjE,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACR,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA,MAAM,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powersync/lib-services-framework",
|
|
3
3
|
"repository": "https://github.com/powersync-ja/powersync-service",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.5",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"winston": "^3.13.0",
|
|
27
27
|
"zod": "^3.23.8",
|
|
28
28
|
"@powersync/service-errors": "0.4.3",
|
|
29
|
-
"@powersync/service-sync-rules": "0.
|
|
29
|
+
"@powersync/service-sync-rules": "0.37.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/lodash": "^4.17.5",
|