@powersync/service-core 0.0.0-dev-20250122110924 → 0.0.0-dev-20250227082606
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/CHANGELOG.md +84 -9
- package/dist/api/RouteAPI.d.ts +9 -1
- package/dist/api/diagnostics.js +107 -169
- package/dist/api/diagnostics.js.map +1 -1
- package/dist/auth/CachedKeyCollector.js +26 -25
- package/dist/auth/CachedKeyCollector.js.map +1 -1
- package/dist/auth/CompoundKeyCollector.js +1 -0
- package/dist/auth/CompoundKeyCollector.js.map +1 -1
- package/dist/auth/KeySpec.js +3 -0
- package/dist/auth/KeySpec.js.map +1 -1
- package/dist/auth/KeyStore.js +4 -0
- package/dist/auth/KeyStore.js.map +1 -1
- package/dist/auth/LeakyBucket.js +5 -0
- package/dist/auth/LeakyBucket.js.map +1 -1
- package/dist/auth/RemoteJWKSCollector.js +4 -1
- package/dist/auth/RemoteJWKSCollector.js.map +1 -1
- package/dist/auth/StaticKeyCollector.js +1 -0
- package/dist/auth/StaticKeyCollector.js.map +1 -1
- package/dist/auth/StaticSupabaseKeyCollector.js +1 -0
- package/dist/auth/StaticSupabaseKeyCollector.js.map +1 -1
- package/dist/entry/commands/compact-action.js +10 -73
- package/dist/entry/commands/compact-action.js.map +1 -1
- package/dist/metrics/Metrics.js +35 -1
- package/dist/metrics/Metrics.js.map +1 -1
- package/dist/modules/AbstractModule.d.ts +1 -1
- package/dist/modules/AbstractModule.js +2 -0
- package/dist/modules/AbstractModule.js.map +1 -1
- package/dist/modules/ModuleManager.js +1 -3
- package/dist/modules/ModuleManager.js.map +1 -1
- package/dist/replication/AbstractReplicationJob.js +4 -2
- package/dist/replication/AbstractReplicationJob.js.map +1 -1
- package/dist/replication/AbstractReplicator.js +26 -88
- package/dist/replication/AbstractReplicator.js.map +1 -1
- package/dist/replication/ReplicationEngine.js +1 -3
- package/dist/replication/ReplicationEngine.js.map +1 -1
- package/dist/replication/ReplicationModule.js +3 -0
- package/dist/replication/ReplicationModule.js.map +1 -1
- package/dist/routes/RouterEngine.js +8 -0
- package/dist/routes/RouterEngine.js.map +1 -1
- package/dist/routes/configure-fastify.d.ts +3 -3
- package/dist/routes/endpoints/admin.d.ts +6 -6
- package/dist/routes/endpoints/admin.js +4 -1
- package/dist/routes/endpoints/admin.js.map +1 -1
- package/dist/routes/endpoints/checkpointing.js +17 -86
- package/dist/routes/endpoints/checkpointing.js.map +1 -1
- package/dist/routes/endpoints/socket-route.js +7 -6
- package/dist/routes/endpoints/socket-route.js.map +1 -1
- package/dist/routes/endpoints/sync-rules.js +7 -2
- package/dist/routes/endpoints/sync-rules.js.map +1 -1
- package/dist/routes/endpoints/sync-stream.js +7 -6
- package/dist/routes/endpoints/sync-stream.js.map +1 -1
- package/dist/runner/teardown.js +5 -67
- package/dist/runner/teardown.js.map +1 -1
- package/dist/storage/BucketStorage.d.ts +8 -414
- package/dist/storage/BucketStorage.js +9 -7
- package/dist/storage/BucketStorage.js.map +1 -1
- package/dist/storage/BucketStorageBatch.d.ts +130 -0
- package/dist/storage/BucketStorageBatch.js +10 -0
- package/dist/storage/BucketStorageBatch.js.map +1 -0
- package/dist/storage/BucketStorageFactory.d.ts +145 -0
- package/dist/storage/BucketStorageFactory.js +2 -0
- package/dist/storage/BucketStorageFactory.js.map +1 -0
- package/dist/storage/ChecksumCache.js +12 -7
- package/dist/storage/ChecksumCache.js.map +1 -1
- package/dist/storage/PersistedSyncRulesContent.d.ts +20 -0
- package/dist/storage/PersistedSyncRulesContent.js +2 -0
- package/dist/storage/PersistedSyncRulesContent.js.map +1 -0
- package/dist/storage/ReplicationEventPayload.d.ts +1 -1
- package/dist/storage/ReplicationLock.d.ts +4 -0
- package/dist/storage/ReplicationLock.js +2 -0
- package/dist/storage/ReplicationLock.js.map +1 -0
- package/dist/storage/SourceEntity.d.ts +6 -2
- package/dist/storage/SourceTable.d.ts +2 -2
- package/dist/storage/SourceTable.js +32 -25
- package/dist/storage/SourceTable.js.map +1 -1
- package/dist/storage/StorageEngine.d.ts +4 -4
- package/dist/storage/StorageEngine.js +6 -5
- package/dist/storage/StorageEngine.js.map +1 -1
- package/dist/storage/StorageProvider.d.ts +4 -1
- package/dist/storage/SyncRulesBucketStorage.d.ts +207 -0
- package/dist/storage/SyncRulesBucketStorage.js +7 -0
- package/dist/storage/SyncRulesBucketStorage.js.map +1 -0
- package/dist/storage/bson.d.ts +19 -6
- package/dist/storage/bson.js +18 -2
- package/dist/storage/bson.js.map +1 -1
- package/dist/storage/storage-index.d.ts +5 -0
- package/dist/storage/storage-index.js +5 -0
- package/dist/storage/storage-index.js.map +1 -1
- package/dist/sync/BroadcastIterable.js +4 -3
- package/dist/sync/BroadcastIterable.js.map +1 -1
- package/dist/sync/BucketChecksumState.d.ts +95 -0
- package/dist/sync/BucketChecksumState.js +321 -0
- package/dist/sync/BucketChecksumState.js.map +1 -0
- package/dist/sync/LastValueSink.js +2 -0
- package/dist/sync/LastValueSink.js.map +1 -1
- package/dist/sync/RequestTracker.js +2 -4
- package/dist/sync/RequestTracker.js.map +1 -1
- package/dist/sync/SyncContext.d.ts +17 -0
- package/dist/sync/SyncContext.js +23 -0
- package/dist/sync/SyncContext.js.map +1 -0
- package/dist/sync/merge.js +4 -0
- package/dist/sync/merge.js.map +1 -1
- package/dist/sync/sync-index.d.ts +2 -0
- package/dist/sync/sync-index.js +2 -0
- package/dist/sync/sync-index.js.map +1 -1
- package/dist/sync/sync.d.ts +10 -4
- package/dist/sync/sync.js +143 -149
- package/dist/sync/sync.js.map +1 -1
- package/dist/sync/util.d.ts +9 -0
- package/dist/sync/util.js +46 -2
- package/dist/sync/util.js.map +1 -1
- package/dist/system/ServiceContext.d.ts +3 -0
- package/dist/system/ServiceContext.js +10 -0
- package/dist/system/ServiceContext.js.map +1 -1
- package/dist/util/Mutex.js +5 -0
- package/dist/util/Mutex.js.map +1 -1
- package/dist/util/checkpointing.d.ts +13 -0
- package/dist/util/checkpointing.js +29 -0
- package/dist/util/checkpointing.js.map +1 -0
- package/dist/util/config/compound-config-collector.js +16 -2
- package/dist/util/config/compound-config-collector.js.map +1 -1
- package/dist/util/config/defaults.d.ts +5 -0
- package/dist/util/config/defaults.js +6 -0
- package/dist/util/config/defaults.js.map +1 -0
- package/dist/util/config/sync-rules/impl/base64-sync-rules-collector.js +1 -0
- package/dist/util/config/sync-rules/impl/base64-sync-rules-collector.js.map +1 -1
- package/dist/util/config/sync-rules/impl/filesystem-sync-rules-collector.js +1 -0
- package/dist/util/config/sync-rules/impl/filesystem-sync-rules-collector.js.map +1 -1
- package/dist/util/config/sync-rules/impl/inline-sync-rules-collector.js +1 -0
- package/dist/util/config/sync-rules/impl/inline-sync-rules-collector.js.map +1 -1
- package/dist/util/config/sync-rules/sync-rules-provider.d.ts +2 -0
- package/dist/util/config/sync-rules/sync-rules-provider.js +4 -0
- package/dist/util/config/sync-rules/sync-rules-provider.js.map +1 -1
- package/dist/util/config/types.d.ts +8 -2
- package/dist/util/config/types.js.map +1 -1
- package/dist/util/memory-tracking.js +1 -1
- package/dist/util/memory-tracking.js.map +1 -1
- package/dist/util/protocol-types.d.ts +13 -4
- package/dist/util/util-index.d.ts +1 -0
- package/dist/util/util-index.js +1 -0
- package/dist/util/util-index.js.map +1 -1
- package/dist/util/utils.d.ts +0 -1
- package/dist/util/utils.js +0 -9
- package/dist/util/utils.js.map +1 -1
- package/package.json +6 -6
- package/src/api/RouteAPI.ts +11 -1
- package/src/api/diagnostics.ts +1 -1
- package/src/entry/commands/compact-action.ts +2 -3
- package/src/modules/AbstractModule.ts +1 -1
- package/src/replication/AbstractReplicator.ts +16 -15
- package/src/routes/RouterEngine.ts +1 -0
- package/src/routes/endpoints/admin.ts +4 -1
- package/src/routes/endpoints/checkpointing.ts +11 -22
- package/src/routes/endpoints/socket-route.ts +9 -6
- package/src/routes/endpoints/sync-rules.ts +7 -2
- package/src/routes/endpoints/sync-stream.ts +10 -6
- package/src/runner/teardown.ts +1 -1
- package/src/storage/BucketStorage.ts +8 -515
- package/src/storage/BucketStorageBatch.ts +158 -0
- package/src/storage/BucketStorageFactory.ts +166 -0
- package/src/storage/ChecksumCache.ts +1 -0
- package/src/storage/PersistedSyncRulesContent.ts +26 -0
- package/src/storage/ReplicationEventPayload.ts +1 -1
- package/src/storage/ReplicationLock.ts +5 -0
- package/src/storage/SourceEntity.ts +6 -2
- package/src/storage/SourceTable.ts +1 -1
- package/src/storage/StorageEngine.ts +4 -4
- package/src/storage/StorageProvider.ts +4 -1
- package/src/storage/SyncRulesBucketStorage.ts +265 -0
- package/src/storage/bson.ts +31 -11
- package/src/storage/storage-index.ts +5 -0
- package/src/sync/BucketChecksumState.ts +418 -0
- package/src/sync/SyncContext.ts +36 -0
- package/src/sync/sync-index.ts +2 -0
- package/src/sync/sync.ts +199 -177
- package/src/sync/util.ts +54 -0
- package/src/system/ServiceContext.ts +9 -0
- package/src/util/checkpointing.ts +41 -0
- package/src/util/config/compound-config-collector.ts +26 -2
- package/src/util/config/defaults.ts +5 -0
- package/src/util/config/sync-rules/impl/base64-sync-rules-collector.ts +1 -0
- package/src/util/config/sync-rules/impl/filesystem-sync-rules-collector.ts +1 -0
- package/src/util/config/sync-rules/impl/inline-sync-rules-collector.ts +1 -0
- package/src/util/config/sync-rules/sync-rules-provider.ts +6 -0
- package/src/util/config/types.ts +9 -2
- package/src/util/memory-tracking.ts +2 -2
- package/src/util/protocol-types.ts +16 -4
- package/src/util/util-index.ts +1 -0
- package/src/util/utils.ts +0 -10
- package/test/src/auth.test.ts +5 -5
- package/test/src/sync/BucketChecksumState.test.ts +580 -0
- package/test/src/sync/util.test.ts +34 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -10,6 +10,13 @@ import { FileSystemSyncRulesCollector } from './sync-rules/impl/filesystem-sync-
|
|
|
10
10
|
import { InlineSyncRulesCollector } from './sync-rules/impl/inline-sync-rules-collector.js';
|
|
11
11
|
import { SyncRulesCollector } from './sync-rules/sync-collector.js';
|
|
12
12
|
import { ResolvedPowerSyncConfig, RunnerConfig, SyncRulesConfig } from './types.js';
|
|
13
|
+
import {
|
|
14
|
+
DEFAULT_MAX_BUCKETS_PER_CONNECTION,
|
|
15
|
+
DEFAULT_MAX_CONCURRENT_CONNECTIONS,
|
|
16
|
+
DEFAULT_MAX_DATA_FETCH_CONCURRENCY,
|
|
17
|
+
DEFAULT_MAX_PARAMETER_QUERY_RESULTS,
|
|
18
|
+
DEFAULT_MAX_POOL_SIZE
|
|
19
|
+
} from './defaults.js';
|
|
13
20
|
|
|
14
21
|
export type CompoundConfigCollectorOptions = {
|
|
15
22
|
/**
|
|
@@ -124,7 +131,12 @@ export class CompoundConfigCollector {
|
|
|
124
131
|
let config: ResolvedPowerSyncConfig = {
|
|
125
132
|
base_config: baseConfig,
|
|
126
133
|
connections: baseConfig.replication?.connections || [],
|
|
127
|
-
storage:
|
|
134
|
+
storage: {
|
|
135
|
+
...baseConfig.storage,
|
|
136
|
+
parameters: {
|
|
137
|
+
max_pool_size: baseConfig.storage?.parameters?.max_pool_size ?? DEFAULT_MAX_POOL_SIZE
|
|
138
|
+
}
|
|
139
|
+
},
|
|
128
140
|
client_keystore: keyStore,
|
|
129
141
|
// Dev tokens only use the static keys, no external key sources
|
|
130
142
|
// We may restrict this even further to only the powersync-dev key.
|
|
@@ -146,6 +158,17 @@ export class CompoundConfigCollector {
|
|
|
146
158
|
internal_service_endpoint:
|
|
147
159
|
baseConfig.telemetry?.internal_service_endpoint ?? 'https://pulse.journeyapps.com/v1/metrics'
|
|
148
160
|
},
|
|
161
|
+
api_parameters: {
|
|
162
|
+
max_buckets_per_connection:
|
|
163
|
+
baseConfig.api?.parameters?.max_buckets_per_connection ?? DEFAULT_MAX_BUCKETS_PER_CONNECTION,
|
|
164
|
+
|
|
165
|
+
max_parameter_query_results:
|
|
166
|
+
baseConfig.api?.parameters?.max_parameter_query_results ?? DEFAULT_MAX_PARAMETER_QUERY_RESULTS,
|
|
167
|
+
max_concurrent_connections:
|
|
168
|
+
baseConfig.api?.parameters?.max_concurrent_connections ?? DEFAULT_MAX_CONCURRENT_CONNECTIONS,
|
|
169
|
+
max_data_fetch_concurrency:
|
|
170
|
+
baseConfig.api?.parameters?.max_data_fetch_concurrency ?? DEFAULT_MAX_DATA_FETCH_CONCURRENCY
|
|
171
|
+
},
|
|
149
172
|
// TODO maybe move this out of the connection or something
|
|
150
173
|
// slot_name_prefix: connections[0]?.slot_name_prefix ?? 'powersync_'
|
|
151
174
|
slot_name_prefix: 'powersync_',
|
|
@@ -196,7 +219,8 @@ export class CompoundConfigCollector {
|
|
|
196
219
|
}
|
|
197
220
|
}
|
|
198
221
|
return {
|
|
199
|
-
present: false
|
|
222
|
+
present: false,
|
|
223
|
+
exit_on_error: true
|
|
200
224
|
};
|
|
201
225
|
}
|
|
202
226
|
}
|
|
@@ -20,6 +20,7 @@ export class FileSystemSyncRulesCollector extends SyncRulesCollector {
|
|
|
20
20
|
// Only persist the path here, and load on demand using `loadSyncRules()`.
|
|
21
21
|
return {
|
|
22
22
|
present: true,
|
|
23
|
+
exit_on_error: baseConfig.sync_rules?.exit_on_error ?? true,
|
|
23
24
|
path: config_path ? path.resolve(path.dirname(config_path), sync_path) : sync_path
|
|
24
25
|
};
|
|
25
26
|
}
|
|
@@ -3,6 +3,8 @@ import fs from 'fs/promises';
|
|
|
3
3
|
|
|
4
4
|
export interface SyncRulesProvider {
|
|
5
5
|
get(): Promise<string | undefined>;
|
|
6
|
+
|
|
7
|
+
readonly exitOnError: boolean;
|
|
6
8
|
}
|
|
7
9
|
|
|
8
10
|
export class ConfigurationFileSyncRulesProvider implements SyncRulesProvider {
|
|
@@ -15,4 +17,8 @@ export class ConfigurationFileSyncRulesProvider implements SyncRulesProvider {
|
|
|
15
17
|
return await fs.readFile(this.config.path, 'utf-8');
|
|
16
18
|
}
|
|
17
19
|
}
|
|
20
|
+
|
|
21
|
+
get exitOnError() {
|
|
22
|
+
return this.config.exit_on_error;
|
|
23
|
+
}
|
|
18
24
|
}
|
package/src/util/config/types.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { configFile } from '@powersync/service-types';
|
|
2
|
-
import { PowerSyncConfig } from '@powersync/service-types/src/config/PowerSyncConfig.js';
|
|
3
2
|
import { CompoundKeyCollector } from '../../auth/CompoundKeyCollector.js';
|
|
4
3
|
import { KeySpec } from '../../auth/KeySpec.js';
|
|
5
4
|
import { KeyStore } from '../../auth/KeyStore.js';
|
|
@@ -26,10 +25,11 @@ export type SyncRulesConfig = {
|
|
|
26
25
|
present: boolean;
|
|
27
26
|
content?: string;
|
|
28
27
|
path?: string;
|
|
28
|
+
exit_on_error: boolean;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
export type ResolvedPowerSyncConfig = {
|
|
32
|
-
base_config: PowerSyncConfig;
|
|
32
|
+
base_config: configFile.PowerSyncConfig;
|
|
33
33
|
connections?: configFile.GenericDataSourceConfig[];
|
|
34
34
|
storage: configFile.GenericStorageConfig;
|
|
35
35
|
dev: {
|
|
@@ -59,6 +59,13 @@ export type ResolvedPowerSyncConfig = {
|
|
|
59
59
|
internal_service_endpoint: string;
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
+
api_parameters: {
|
|
63
|
+
max_concurrent_connections: number;
|
|
64
|
+
max_data_fetch_concurrency: number;
|
|
65
|
+
max_buckets_per_connection: number;
|
|
66
|
+
max_parameter_query_results: number;
|
|
67
|
+
};
|
|
68
|
+
|
|
62
69
|
/** Prefix for postgres replication slot names. May eventually be connection-specific. */
|
|
63
70
|
slot_name_prefix: string;
|
|
64
71
|
parameters: Record<string, number | string | boolean | null>;
|
|
@@ -25,8 +25,8 @@ export function trackMemoryUsage() {
|
|
|
25
25
|
for (let key of Object.keys(bufferMemory)) {
|
|
26
26
|
const typedKey = key as keyof typeof bufferMemory;
|
|
27
27
|
const originalFunction = Buffer[typedKey] as (...args: any[]) => Buffer;
|
|
28
|
-
Buffer[typedKey] = function (...args: any[]) {
|
|
29
|
-
const buffer = originalFunction.apply(this, args)
|
|
28
|
+
Buffer[typedKey] = function <TArrayBuffer extends ArrayBufferLike = ArrayBufferLike>(...args: any[]) {
|
|
29
|
+
const buffer = originalFunction.apply(this, args) as Buffer<TArrayBuffer>;
|
|
30
30
|
bufferMemory[typedKey] += buffer.byteLength;
|
|
31
31
|
bufferRegistry.register(buffer, [typedKey, buffer.byteLength]);
|
|
32
32
|
return buffer;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as t from 'ts-codec';
|
|
2
|
-
import { SqliteJsonValue } from '@powersync/service-sync-rules';
|
|
2
|
+
import { BucketDescription, BucketPriority, SqliteJsonValue } from '@powersync/service-sync-rules';
|
|
3
3
|
|
|
4
4
|
export const BucketRequest = t.object({
|
|
5
5
|
name: t.string,
|
|
@@ -59,7 +59,7 @@ export interface StreamingSyncCheckpointDiff {
|
|
|
59
59
|
checkpoint_diff: {
|
|
60
60
|
last_op_id: OpId;
|
|
61
61
|
write_checkpoint?: OpId;
|
|
62
|
-
updated_buckets:
|
|
62
|
+
updated_buckets: BucketChecksumWithDescription[];
|
|
63
63
|
removed_buckets: string[];
|
|
64
64
|
};
|
|
65
65
|
}
|
|
@@ -74,13 +74,23 @@ export interface StreamingSyncCheckpointComplete {
|
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
export interface
|
|
77
|
+
export interface StreamingSyncCheckpointPartiallyComplete {
|
|
78
|
+
partial_checkpoint_complete: {
|
|
79
|
+
last_op_id: OpId;
|
|
80
|
+
priority: BucketPriority;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface StreamingSyncKeepalive {
|
|
85
|
+
token_expires_in: number;
|
|
86
|
+
}
|
|
78
87
|
|
|
79
88
|
export type StreamingSyncLine =
|
|
80
89
|
| StreamingSyncData
|
|
81
90
|
| StreamingSyncCheckpoint
|
|
82
91
|
| StreamingSyncCheckpointDiff
|
|
83
92
|
| StreamingSyncCheckpointComplete
|
|
93
|
+
| StreamingSyncCheckpointPartiallyComplete
|
|
84
94
|
| StreamingSyncKeepalive;
|
|
85
95
|
|
|
86
96
|
/**
|
|
@@ -91,7 +101,7 @@ export type OpId = string;
|
|
|
91
101
|
export interface Checkpoint {
|
|
92
102
|
last_op_id: OpId;
|
|
93
103
|
write_checkpoint?: OpId;
|
|
94
|
-
buckets:
|
|
104
|
+
buckets: BucketChecksumWithDescription[];
|
|
95
105
|
}
|
|
96
106
|
|
|
97
107
|
export interface BucketState {
|
|
@@ -142,3 +152,5 @@ export interface BucketChecksum {
|
|
|
142
152
|
*/
|
|
143
153
|
count: number;
|
|
144
154
|
}
|
|
155
|
+
|
|
156
|
+
export interface BucketChecksumWithDescription extends BucketChecksum, BucketDescription {}
|
package/src/util/util-index.ts
CHANGED
package/src/util/utils.ts
CHANGED
|
@@ -145,16 +145,6 @@ export function isCompleteRow(storeData: boolean, row: sync_rules.ToastableSqlit
|
|
|
145
145
|
return !hasToastedValues(row);
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
export function checkpointUserId(user_id: string | undefined, client_id: string | undefined) {
|
|
149
|
-
if (user_id == null) {
|
|
150
|
-
throw new Error('user_id is required');
|
|
151
|
-
}
|
|
152
|
-
if (client_id == null) {
|
|
153
|
-
return user_id;
|
|
154
|
-
}
|
|
155
|
-
return `${user_id}/${client_id}`;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
148
|
/**
|
|
159
149
|
* Reduce a bucket to the final state as stored on the client.
|
|
160
150
|
*
|
package/test/src/auth.test.ts
CHANGED
|
@@ -274,7 +274,7 @@ describe('JWT Auth', () => {
|
|
|
274
274
|
).rejects.toThrow('Token must expire in a maximum of');
|
|
275
275
|
});
|
|
276
276
|
|
|
277
|
-
test('http', async () => {
|
|
277
|
+
test('http', { timeout: 20_000 }, async () => {
|
|
278
278
|
// Not ideal to rely on an external endpoint for tests, but it is good to test that this
|
|
279
279
|
// one actually works.
|
|
280
280
|
const remote = new RemoteJWKSCollector(
|
|
@@ -290,9 +290,9 @@ describe('JWT Auth', () => {
|
|
|
290
290
|
reject_ip_ranges: ['local']
|
|
291
291
|
}
|
|
292
292
|
});
|
|
293
|
-
expect(invalid.getKeys()).rejects.toThrow('IPs in this range are not supported');
|
|
293
|
+
await expect(invalid.getKeys()).rejects.toThrow('IPs in this range are not supported');
|
|
294
294
|
|
|
295
|
-
//
|
|
295
|
+
// IPs throw an error immediately
|
|
296
296
|
expect(
|
|
297
297
|
() =>
|
|
298
298
|
new RemoteJWKSCollector('https://127.0.0.1/.well-known/jwks.json', {
|
|
@@ -315,11 +315,11 @@ describe('JWT Auth', () => {
|
|
|
315
315
|
|
|
316
316
|
const invalid = new RemoteJWKSCollector('https://127.0.0.1/.well-known/jwks.json');
|
|
317
317
|
// Should try and fetch
|
|
318
|
-
expect(invalid.getKeys()).rejects.toThrow();
|
|
318
|
+
await expect(invalid.getKeys()).rejects.toThrow();
|
|
319
319
|
|
|
320
320
|
const invalid2 = new RemoteJWKSCollector('https://localhost/.well-known/jwks.json');
|
|
321
321
|
// Should try and fetch
|
|
322
|
-
expect(invalid2.getKeys()).rejects.toThrow();
|
|
322
|
+
await expect(invalid2.getKeys()).rejects.toThrow();
|
|
323
323
|
});
|
|
324
324
|
|
|
325
325
|
test('caching', async () => {
|