@powersync/service-module-postgres 0.12.2 → 0.13.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/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # @powersync/service-module-postgres
2
2
 
3
+ ## 0.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 9dc4e01: Improve authentication error messages and logs
8
+
9
+ ### Patch Changes
10
+
11
+ - 94f657d: Add additional log metadata to sync requests.
12
+ - Updated dependencies [ca0a566]
13
+ - Updated dependencies [9dc4e01]
14
+ - Updated dependencies [94f657d]
15
+ - Updated dependencies [05c24d2]
16
+ - Updated dependencies [d154682]
17
+ - Updated dependencies [c672380]
18
+ - Updated dependencies [ca0a566]
19
+ - Updated dependencies [ca0a566]
20
+ - Updated dependencies [d869876]
21
+ - @powersync/service-core@1.12.0
22
+ - @powersync/lib-services-framework@0.6.0
23
+ - @powersync/service-sync-rules@0.26.1
24
+ - @powersync/lib-service-postgres@0.4.3
25
+ - @powersync/service-types@0.11.0
26
+
27
+ ## 0.12.3
28
+
29
+ ### Patch Changes
30
+
31
+ - Updated dependencies [08f6ae8]
32
+ - Updated dependencies [23ec406]
33
+ - Updated dependencies [64e51d1]
34
+ - @powersync/service-core@1.11.3
35
+ - @powersync/lib-services-framework@0.5.4
36
+ - @powersync/lib-service-postgres@0.4.2
37
+
3
38
  ## 0.12.2
4
39
 
5
40
  ### Patch Changes
@@ -1,5 +1,4 @@
1
- import { auth } from '@powersync/service-core';
2
- import * as jose from 'jose';
1
+ import { auth, KeyResult } from '@powersync/service-core';
3
2
  import * as types from '../types/types.js';
4
3
  /**
5
4
  * Fetches key from the Supabase database.
@@ -7,18 +6,12 @@ import * as types from '../types/types.js';
7
6
  * Unfortunately, despite the JWTs containing a kid, we have no way to lookup that kid
8
7
  * before receiving a valid token.
9
8
  *
10
- * @deprecated Supabase is removing support for "app.settings.jwt_secret".
9
+ * @deprecated Supabase is removing support for "app.settings.jwt_secret". This is likely to not function anymore, except in some self-hosted setups.
11
10
  */
12
11
  export declare class SupabaseKeyCollector implements auth.KeyCollector {
13
12
  private pool;
14
13
  private keyOptions;
15
14
  constructor(connectionConfig: types.ResolvedConnectionConfig);
16
15
  shutdown(): Promise<void>;
17
- getKeys(): Promise<{
18
- keys: never[];
19
- errors: jose.errors.JWKSNoMatchingKey[];
20
- } | {
21
- keys: auth.KeySpec[];
22
- errors: never[];
23
- }>;
16
+ getKeys(): Promise<KeyResult>;
24
17
  }
@@ -1,14 +1,14 @@
1
1
  import * as lib_postgres from '@powersync/lib-service-postgres';
2
2
  import { auth } from '@powersync/service-core';
3
3
  import * as pgwire from '@powersync/service-jpgwire';
4
- import * as jose from 'jose';
4
+ import { AuthorizationError, ErrorCode } from '@powersync/lib-services-framework';
5
5
  /**
6
6
  * Fetches key from the Supabase database.
7
7
  *
8
8
  * Unfortunately, despite the JWTs containing a kid, we have no way to lookup that kid
9
9
  * before receiving a valid token.
10
10
  *
11
- * @deprecated Supabase is removing support for "app.settings.jwt_secret".
11
+ * @deprecated Supabase is removing support for "app.settings.jwt_secret". This is likely to not function anymore, except in some self-hosted setups.
12
12
  */
13
13
  export class SupabaseKeyCollector {
14
14
  pool;
@@ -36,7 +36,7 @@ export class SupabaseKeyCollector {
36
36
  }
37
37
  catch (e) {
38
38
  if (e.message?.includes('unrecognized configuration parameter')) {
39
- throw new jose.errors.JOSEError(`Generate a new JWT secret on Supabase. Cause: ${e.message}`);
39
+ throw new AuthorizationError(ErrorCode.PSYNC_S2201, 'No JWT secret found in Supabase database. Manually configure the secret.');
40
40
  }
41
41
  else {
42
42
  throw e;
@@ -46,7 +46,9 @@ export class SupabaseKeyCollector {
46
46
  if (secret == null) {
47
47
  return {
48
48
  keys: [],
49
- errors: [new jose.errors.JWKSNoMatchingKey()]
49
+ errors: [
50
+ new AuthorizationError(ErrorCode.PSYNC_S2201, 'No JWT secret found in Supabase database. Manually configure the secret.')
51
+ ]
50
52
  };
51
53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,CAAC,WAAW,CAAC;aACrD,CAAC;YACF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;YACpE,OAAO;gBACL,IAAI,EAAE,CAAC,QAAQ,CAAC;gBAChB,MAAM,EAAE,EAAE;aACX,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
- "version": "0.12.2",
8
+ "version": "0.13.0",
9
9
  "main": "dist/index.js",
10
10
  "license": "FSL-1.1-Apache-2.0",
11
11
  "type": "module",
@@ -27,21 +27,20 @@
27
27
  "semver": "^7.5.4",
28
28
  "ts-codec": "^1.3.0",
29
29
  "uri-js": "^4.4.1",
30
- "uuid": "^9.0.1",
31
- "@powersync/lib-service-postgres": "0.4.1",
32
- "@powersync/lib-services-framework": "0.5.3",
33
- "@powersync/service-core": "1.11.2",
30
+ "uuid": "^11.1.0",
31
+ "@powersync/lib-service-postgres": "0.4.3",
32
+ "@powersync/lib-services-framework": "0.6.0",
33
+ "@powersync/service-core": "1.12.0",
34
34
  "@powersync/service-jpgwire": "0.19.0",
35
35
  "@powersync/service-jsonbig": "0.17.10",
36
- "@powersync/service-sync-rules": "0.26.0",
37
- "@powersync/service-types": "0.10.0"
36
+ "@powersync/service-sync-rules": "0.26.1",
37
+ "@powersync/service-types": "0.11.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/semver": "^7.5.4",
41
- "@types/uuid": "^9.0.4",
42
- "@powersync/service-core-tests": "0.9.2",
43
- "@powersync/service-module-mongodb-storage": "0.9.2",
44
- "@powersync/service-module-postgres-storage": "0.7.2"
41
+ "@powersync/service-core-tests": "0.9.4",
42
+ "@powersync/service-module-mongodb-storage": "0.9.4",
43
+ "@powersync/service-module-postgres-storage": "0.7.4"
45
44
  },
46
45
  "scripts": {
47
46
  "build": "tsc -b",
@@ -1,9 +1,10 @@
1
1
  import * as lib_postgres from '@powersync/lib-service-postgres';
2
- import { auth } from '@powersync/service-core';
2
+ import { auth, KeyResult } from '@powersync/service-core';
3
3
  import * as pgwire from '@powersync/service-jpgwire';
4
4
  import * as jose from 'jose';
5
5
 
6
6
  import * as types from '../types/types.js';
7
+ import { AuthorizationError, ErrorCode } from '@powersync/lib-services-framework';
7
8
 
8
9
  /**
9
10
  * Fetches key from the Supabase database.
@@ -11,7 +12,7 @@ import * as types from '../types/types.js';
11
12
  * Unfortunately, despite the JWTs containing a kid, we have no way to lookup that kid
12
13
  * before receiving a valid token.
13
14
  *
14
- * @deprecated Supabase is removing support for "app.settings.jwt_secret".
15
+ * @deprecated Supabase is removing support for "app.settings.jwt_secret". This is likely to not function anymore, except in some self-hosted setups.
15
16
  */
16
17
  export class SupabaseKeyCollector implements auth.KeyCollector {
17
18
  private pool: pgwire.PgClient;
@@ -35,7 +36,7 @@ export class SupabaseKeyCollector implements auth.KeyCollector {
35
36
  return this.pool.end();
36
37
  }
37
38
 
38
- async getKeys() {
39
+ async getKeys(): Promise<KeyResult> {
39
40
  let row: { jwt_secret: string };
40
41
  try {
41
42
  const rows = pgwire.pgwireRows(
@@ -44,7 +45,10 @@ export class SupabaseKeyCollector implements auth.KeyCollector {
44
45
  row = rows[0] as any;
45
46
  } catch (e) {
46
47
  if (e.message?.includes('unrecognized configuration parameter')) {
47
- throw new jose.errors.JOSEError(`Generate a new JWT secret on Supabase. Cause: ${e.message}`);
48
+ throw new AuthorizationError(
49
+ ErrorCode.PSYNC_S2201,
50
+ 'No JWT secret found in Supabase database. Manually configure the secret.'
51
+ );
48
52
  } else {
49
53
  throw e;
50
54
  }
@@ -53,7 +57,12 @@ export class SupabaseKeyCollector implements auth.KeyCollector {
53
57
  if (secret == null) {
54
58
  return {
55
59
  keys: [],
56
- errors: [new jose.errors.JWKSNoMatchingKey()]
60
+ errors: [
61
+ new AuthorizationError(
62
+ ErrorCode.PSYNC_S2201,
63
+ 'No JWT secret found in Supabase database. Manually configure the secret.'
64
+ )
65
+ ]
57
66
  };
58
67
  } else {
59
68
  const key: jose.JWK = {
@@ -161,11 +161,11 @@ export class WalStreamTestContext implements AsyncDisposable {
161
161
  const batch = this.storage!.getBucketDataBatch(checkpoint, map);
162
162
 
163
163
  const batches = await test_utils.fromAsync(batch);
164
- data = data.concat(batches[0]?.batch.data ?? []);
165
- if (batches.length == 0 || !batches[0]!.batch.has_more) {
164
+ data = data.concat(batches[0]?.chunkData.data ?? []);
165
+ if (batches.length == 0 || !batches[0]!.chunkData.has_more) {
166
166
  break;
167
167
  }
168
- map.set(bucket, BigInt(batches[0]!.batch.next_after));
168
+ map.set(bucket, BigInt(batches[0]!.chunkData.next_after));
169
169
  }
170
170
  return data;
171
171
  }
@@ -182,6 +182,6 @@ export class WalStreamTestContext implements AsyncDisposable {
182
182
  const map = new Map<string, InternalOpId>([[bucket, start]]);
183
183
  const batch = this.storage!.getBucketDataBatch(checkpoint, map);
184
184
  const batches = await test_utils.fromAsync(batch);
185
- return batches[0]?.batch.data ?? [];
185
+ return batches[0]?.chunkData.data ?? [];
186
186
  }
187
187
  }