@powersync/service-errors 0.2.2 → 0.3.1

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/codes.d.ts CHANGED
@@ -129,6 +129,17 @@ export declare enum ErrorCode {
129
129
  * Either upgrade the Postgres server to version 14 or above, or use a different Postgres server for sync bucket storage.
130
130
  */
131
131
  PSYNC_S1144 = "PSYNC_S1144",
132
+ /**
133
+ * Table has RLS enabled, but the replication role does not have the BYPASSRLS attribute.
134
+ *
135
+ * We recommend using a dedicated replication role with the BYPASSRLS attribute for replication:
136
+ *
137
+ * ALTER ROLE powersync_role BYPASSRLS
138
+ *
139
+ * An alternative is to create explicit policies for the replication role. If you have done that,
140
+ * you may ignore this warning.
141
+ */
142
+ PSYNC_S1145 = "PSYNC_S1145",
132
143
  /**
133
144
  * Generic MongoServerError.
134
145
  */
@@ -140,7 +151,7 @@ export declare enum ErrorCode {
140
151
  /**
141
152
  * MongoDB internal TLS error.
142
153
  *
143
- * If connection to a shared cluster on MongoDB Atlas, this could be an IP Acccess List issue.
154
+ * If connection to a shared cluster on MongoDB Atlas, this could be an IP Access List issue.
144
155
  * Check that the service IP is allowed to connect to the cluster.
145
156
  */
146
157
  PSYNC_S1303 = "PSYNC_S1303",
@@ -165,7 +176,7 @@ export declare enum ErrorCode {
165
176
  /**
166
177
  * MongoDB authorization error.
167
178
  *
168
- * Check that the user has the required priviledges.
179
+ * Check that the user has the required privileges.
169
180
  */
170
181
  PSYNC_S1307 = "PSYNC_S1307",
171
182
  /**
@@ -173,7 +184,7 @@ export declare enum ErrorCode {
173
184
  */
174
185
  PSYNC_S1341 = "PSYNC_S1341",
175
186
  /**
176
- * Standalone MongoDB instances are not supported - use a replicaset.
187
+ * Standalone MongoDB instances are not supported - use a replica-set.
177
188
  */
178
189
  PSYNC_S1342 = "PSYNC_S1342",
179
190
  /**
@@ -213,6 +224,12 @@ export declare enum ErrorCode {
213
224
  * See the error cause for more details.
214
225
  */
215
226
  PSYNC_S1346 = "PSYNC_S1346",
227
+ /**
228
+ * Timeout while getting a resume token for an initial snapshot.
229
+ *
230
+ * This may happen if there is very high load on the source database.
231
+ */
232
+ PSYNC_S1347 = "PSYNC_S1347",
216
233
  /**
217
234
  * Max transaction tries exceeded.
218
235
  */
@@ -233,10 +250,48 @@ export declare enum ErrorCode {
233
250
  * Wait a while then retry the request.
234
251
  */
235
252
  PSYNC_S2003 = "PSYNC_S2003",
253
+ /**
254
+ * 415 unsupported media type.
255
+ *
256
+ * This code always indicates an issue with the client.
257
+ */
258
+ PSYNC_S2004 = "PSYNC_S2004",
236
259
  /**
237
260
  * Generic authentication error.
238
261
  */
239
262
  PSYNC_S2101 = "PSYNC_S2101",
263
+ /**
264
+ * Could not verify the auth token signature.
265
+ *
266
+ * Typical causes include:
267
+ * 1. Token kid is not found in the keystore.
268
+ * 2. Signature does not match the kid in the keystore.
269
+ */
270
+ PSYNC_S2102 = "PSYNC_S2102",
271
+ /**
272
+ * Token has expired. Check the expiry date on the token.
273
+ */
274
+ PSYNC_S2103 = "PSYNC_S2103",
275
+ /**
276
+ * Token expiration period is too long. Issue shorter-lived tokens.
277
+ */
278
+ PSYNC_S2104 = "PSYNC_S2104",
279
+ /**
280
+ * Token audience does not match expected values.
281
+ *
282
+ * Check the aud value on the token, compared to the audience values allowed in the service config.
283
+ */
284
+ PSYNC_S2105 = "PSYNC_S2105",
285
+ /**
286
+ * No token provided. An auth token is required for every request.
287
+ *
288
+ * The Authorization header must start with "Token" or "Bearer", followed by the JWT.
289
+ */
290
+ PSYNC_S2106 = "PSYNC_S2106",
291
+ /**
292
+ * Generic auth configuration error. See the message for details.
293
+ */
294
+ PSYNC_S2201 = "PSYNC_S2201",
240
295
  /**
241
296
  * IPv6 support is not enabled for the JWKS URI.
242
297
  *
@@ -246,9 +301,13 @@ export declare enum ErrorCode {
246
301
  /**
247
302
  * IPs in this range are not supported.
248
303
  *
249
- * Make sure to use a publically-accessible JWKS URI.
304
+ * Make sure to use a publicly-accessible JWKS URI.
250
305
  */
251
306
  PSYNC_S2203 = "PSYNC_S2203",
307
+ /**
308
+ * JWKS request failed.
309
+ */
310
+ PSYNC_S2204 = "PSYNC_S2204",
252
311
  /**
253
312
  * No sync rules available.
254
313
  *
@@ -273,6 +332,10 @@ export declare enum ErrorCode {
273
332
  * Could not get clusterTime.
274
333
  */
275
334
  PSYNC_S2401 = "PSYNC_S2401",
335
+ /**
336
+ * Failed to connect to the MongoDB storage database.
337
+ */
338
+ PSYNC_S2402 = "PSYNC_S2402",
276
339
  /**
277
340
  * Invalid jwks_uri.
278
341
  */
package/dist/codes.js CHANGED
@@ -140,6 +140,17 @@ export var ErrorCode;
140
140
  * Either upgrade the Postgres server to version 14 or above, or use a different Postgres server for sync bucket storage.
141
141
  */
142
142
  ErrorCode["PSYNC_S1144"] = "PSYNC_S1144";
143
+ /**
144
+ * Table has RLS enabled, but the replication role does not have the BYPASSRLS attribute.
145
+ *
146
+ * We recommend using a dedicated replication role with the BYPASSRLS attribute for replication:
147
+ *
148
+ * ALTER ROLE powersync_role BYPASSRLS
149
+ *
150
+ * An alternative is to create explicit policies for the replication role. If you have done that,
151
+ * you may ignore this warning.
152
+ */
153
+ ErrorCode["PSYNC_S1145"] = "PSYNC_S1145";
143
154
  // ## PSYNC_S12xx: MySQL replication issues
144
155
  // ## PSYNC_S13xx: MongoDB replication issues
145
156
  /**
@@ -153,7 +164,7 @@ export var ErrorCode;
153
164
  /**
154
165
  * MongoDB internal TLS error.
155
166
  *
156
- * If connection to a shared cluster on MongoDB Atlas, this could be an IP Acccess List issue.
167
+ * If connection to a shared cluster on MongoDB Atlas, this could be an IP Access List issue.
157
168
  * Check that the service IP is allowed to connect to the cluster.
158
169
  */
159
170
  ErrorCode["PSYNC_S1303"] = "PSYNC_S1303";
@@ -178,7 +189,7 @@ export var ErrorCode;
178
189
  /**
179
190
  * MongoDB authorization error.
180
191
  *
181
- * Check that the user has the required priviledges.
192
+ * Check that the user has the required privileges.
182
193
  */
183
194
  ErrorCode["PSYNC_S1307"] = "PSYNC_S1307";
184
195
  /**
@@ -186,7 +197,7 @@ export var ErrorCode;
186
197
  */
187
198
  ErrorCode["PSYNC_S1341"] = "PSYNC_S1341";
188
199
  /**
189
- * Standalone MongoDB instances are not supported - use a replicaset.
200
+ * Standalone MongoDB instances are not supported - use a replica-set.
190
201
  */
191
202
  ErrorCode["PSYNC_S1342"] = "PSYNC_S1342";
192
203
  /**
@@ -226,6 +237,12 @@ export var ErrorCode;
226
237
  * See the error cause for more details.
227
238
  */
228
239
  ErrorCode["PSYNC_S1346"] = "PSYNC_S1346";
240
+ /**
241
+ * Timeout while getting a resume token for an initial snapshot.
242
+ *
243
+ * This may happen if there is very high load on the source database.
244
+ */
245
+ ErrorCode["PSYNC_S1347"] = "PSYNC_S1347";
229
246
  // ## PSYNC_S14xx: MongoDB storage replication issues
230
247
  /**
231
248
  * Max transaction tries exceeded.
@@ -248,6 +265,12 @@ export var ErrorCode;
248
265
  * Wait a while then retry the request.
249
266
  */
250
267
  ErrorCode["PSYNC_S2003"] = "PSYNC_S2003";
268
+ /**
269
+ * 415 unsupported media type.
270
+ *
271
+ * This code always indicates an issue with the client.
272
+ */
273
+ ErrorCode["PSYNC_S2004"] = "PSYNC_S2004";
251
274
  // ## PSYNC_S21xx: Auth errors originating on the client.
252
275
  //
253
276
  // This does not include auth configuration errors on the service.
@@ -255,7 +278,39 @@ export var ErrorCode;
255
278
  * Generic authentication error.
256
279
  */
257
280
  ErrorCode["PSYNC_S2101"] = "PSYNC_S2101";
281
+ /**
282
+ * Could not verify the auth token signature.
283
+ *
284
+ * Typical causes include:
285
+ * 1. Token kid is not found in the keystore.
286
+ * 2. Signature does not match the kid in the keystore.
287
+ */
288
+ ErrorCode["PSYNC_S2102"] = "PSYNC_S2102";
289
+ /**
290
+ * Token has expired. Check the expiry date on the token.
291
+ */
292
+ ErrorCode["PSYNC_S2103"] = "PSYNC_S2103";
293
+ /**
294
+ * Token expiration period is too long. Issue shorter-lived tokens.
295
+ */
296
+ ErrorCode["PSYNC_S2104"] = "PSYNC_S2104";
297
+ /**
298
+ * Token audience does not match expected values.
299
+ *
300
+ * Check the aud value on the token, compared to the audience values allowed in the service config.
301
+ */
302
+ ErrorCode["PSYNC_S2105"] = "PSYNC_S2105";
303
+ /**
304
+ * No token provided. An auth token is required for every request.
305
+ *
306
+ * The Authorization header must start with "Token" or "Bearer", followed by the JWT.
307
+ */
308
+ ErrorCode["PSYNC_S2106"] = "PSYNC_S2106";
258
309
  // ## PSYNC_S22xx: Auth integration errors
310
+ /**
311
+ * Generic auth configuration error. See the message for details.
312
+ */
313
+ ErrorCode["PSYNC_S2201"] = "PSYNC_S2201";
259
314
  /**
260
315
  * IPv6 support is not enabled for the JWKS URI.
261
316
  *
@@ -265,9 +320,13 @@ export var ErrorCode;
265
320
  /**
266
321
  * IPs in this range are not supported.
267
322
  *
268
- * Make sure to use a publically-accessible JWKS URI.
323
+ * Make sure to use a publicly-accessible JWKS URI.
269
324
  */
270
325
  ErrorCode["PSYNC_S2203"] = "PSYNC_S2203";
326
+ /**
327
+ * JWKS request failed.
328
+ */
329
+ ErrorCode["PSYNC_S2204"] = "PSYNC_S2204";
271
330
  // ## PSYNC_S23xx: Sync API errors
272
331
  /**
273
332
  * No sync rules available.
@@ -294,6 +353,10 @@ export var ErrorCode;
294
353
  * Could not get clusterTime.
295
354
  */
296
355
  ErrorCode["PSYNC_S2401"] = "PSYNC_S2401";
356
+ /**
357
+ * Failed to connect to the MongoDB storage database.
358
+ */
359
+ ErrorCode["PSYNC_S2402"] = "PSYNC_S2402";
297
360
  // ## PSYNC_S23xx: Sync API errors - Postgres Storage
298
361
  // ## PSYNC_S3xxx: Service configuration issues
299
362
  // ## PSYNC_S31xx: Auth configuration issues
@@ -310,7 +373,7 @@ export var ErrorCode;
310
373
  * Failed to validate module configuration.
311
374
  */
312
375
  ErrorCode["PSYNC_S3201"] = "PSYNC_S3201";
313
- // ## PSYNC_S4000: management / dev apis
376
+ // ## PSYNC_S4000: Management / Dev APIs
314
377
  /**
315
378
  * Internal assertion error.
316
379
  *
package/dist/codes.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"codes.js","sourceRoot":"","sources":["../src/codes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAN,IAAY,SAyYX;AAzYD,WAAY,SAAS;IACnB,mCAAmC;IAEnC;;OAEG;IACH,wCAA2B,CAAA;IAE3B,qCAAqC;IAErC,iDAAiD;IAEjD,oCAAoC;IAEpC,+CAA+C;IAE/C,6CAA6C;IAE7C,wCAAwC;IAExC,gCAAgC;IAEhC;;;;OAIG;IACH,wCAA2B,CAAA;IAE3B;;;;;;;;OAQG;IACH,wCAA2B,CAAA;IAE3B,qCAAqC;IAErC;;;;;OAKG;IACH,wCAA2B,CAAA;IAE3B;;;;;;;;;OASG;IACH,wCAA2B,CAAA;IAE3B;;;;OAIG;IACH,wCAA2B,CAAA;IAE3B,8CAA8C;IAE9C;;;;OAIG;IACH,wCAA2B,CAAA;IAE3B;;;;;OAKG;IACH,wCAA2B,CAAA;IAE3B;;;;OAIG;IACH,wCAA2B,CAAA;IAE3B;;;;OAIG;IACH,wCAA2B,CAAA;IAE3B;;;;OAIG;IACH,wCAA2B,CAAA;IAE3B;;;;OAIG;IACH,wCAA2B,CAAA;IAE3B;;;;OAIG;IACH,wCAA2B,CAAA;IAE3B;;;;OAIG;IACH,wCAA2B,CAAA;IAE3B;;;;OAIG;IACH,wCAA2B,CAAA;IAE3B;;;;OAIG;IACH,wCAA2B,CAAA;IAE3B;;;;OAIG;IACH,wCAA2B,CAAA;IAE3B;;OAEG;IACH,wCAA2B,CAAA;IAE3B;;;;;;;OAOG;IACH,wCAA2B,CAAA;IAE3B,2CAA2C;IAE3C,6CAA6C;IAE7C;;OAEG;IACH,wCAA2B,CAAA;IAE3B;;OAEG;IACH,wCAA2B,CAAA;IAE3B;;;;;OAKG;IACH,wCAA2B,CAAA;IAE3B;;;;OAIG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AAmD;IAEnD;;OAEG;IACH,wCAA2B,CAAA;IAE3B,wCAAwC;IAExC;;;;OAIG;IACH,wCAA2B,CAAA;IAE3B;;OAEG;IACH,wCAA2B,CAAA;IAE3B;;;;OAIG;IACH,wCAA2B,CAAA;AAC7B,CAAC,EAndW,SAAS,KAAT,SAAS,QAmdpB"}
package/dist/errors.d.ts CHANGED
@@ -65,10 +65,27 @@ export declare class ReplicationAbortedError extends ServiceError {
65
65
  static readonly CODE = ErrorCode.PSYNC_S1103;
66
66
  constructor(description?: string);
67
67
  }
68
- export declare class AuthorizationError extends ServiceError {
69
- static readonly CODE = ErrorCode.PSYNC_S2101;
68
+ export declare class UnsupportedMediaType extends ServiceError {
69
+ static readonly CODE = ErrorCode.PSYNC_S2004;
70
70
  constructor(errors: any);
71
71
  }
72
+ export declare class AuthorizationError extends ServiceError {
73
+ /**
74
+ * String describing the token. Does not contain the full token, but may help with debugging.
75
+ * Safe for logs.
76
+ */
77
+ tokenDetails: string | undefined;
78
+ /**
79
+ * String describing related configuration. Should never be returned to the client.
80
+ * Safe for logs.
81
+ */
82
+ configurationDetails: string | undefined;
83
+ constructor(code: ErrorCode, description: string, options?: {
84
+ tokenDetails?: string;
85
+ configurationDetails?: string;
86
+ cause?: any;
87
+ });
88
+ }
72
89
  export declare class InternalServerError extends ServiceError {
73
90
  static readonly CODE = ErrorCode.PSYNC_S2001;
74
91
  constructor(err: Error);
package/dist/errors.js CHANGED
@@ -124,17 +124,39 @@ export class ReplicationAbortedError extends ServiceError {
124
124
  });
125
125
  }
126
126
  }
127
- export class AuthorizationError extends ServiceError {
128
- static CODE = ErrorCode.PSYNC_S2101;
127
+ export class UnsupportedMediaType extends ServiceError {
128
+ static CODE = ErrorCode.PSYNC_S2004;
129
129
  constructor(errors) {
130
130
  super({
131
- code: AuthorizationError.CODE,
132
- status: 401,
133
- description: 'Authorization failed',
131
+ code: UnsupportedMediaType.CODE,
132
+ status: 415,
133
+ description: 'Unsupported Media Type',
134
134
  details: errors
135
135
  });
136
136
  }
137
137
  }
138
+ export class AuthorizationError extends ServiceError {
139
+ /**
140
+ * String describing the token. Does not contain the full token, but may help with debugging.
141
+ * Safe for logs.
142
+ */
143
+ tokenDetails;
144
+ /**
145
+ * String describing related configuration. Should never be returned to the client.
146
+ * Safe for logs.
147
+ */
148
+ configurationDetails;
149
+ constructor(code, description, options) {
150
+ super({
151
+ code,
152
+ status: 401,
153
+ description
154
+ });
155
+ this.cause = options?.cause;
156
+ this.tokenDetails = options?.tokenDetails;
157
+ this.configurationDetails = options?.configurationDetails;
158
+ }
159
+ }
138
160
  export class InternalServerError extends ServiceError {
139
161
  static CODE = ErrorCode.PSYNC_S2001;
140
162
  constructor(err) {
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,8BAAa,CAAA;IACb,oCAAmB,CAAA;IACnB,gCAAe,CAAA;AACjB,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB;AAkBD,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC,gBAAgB,GAAG,IAAI,CAAC;IAExB,SAAS,CAAY;IAErB,MAAM,CAAC,cAAc,CAAC,KAAU;QAC9B,OAAO,KAAK,YAAY,YAAY,IAAI,KAAK,EAAE,gBAAgB,IAAI,IAAI,CAAC;IAC1E,CAAC;IAEO,MAAM,CAAC,YAAY,CAAC,IAA2B,EAAE,WAAoB;QAC3E,IAAI,OAAO,IAAI,IAAI,QAAQ,EAAE,CAAC;YAC5B,IAAI,GAAG;gBACL,IAAI,EAAE,IAAI;gBACV,WAAW,EAAE,WAAY;aAC1B,CAAC;QACJ,CAAC;QACD,IAAI,OAAO,GAAG,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,WAAW,EAAE,CAAC;QACnD,IAAI,IAAI,CAAC,OAA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W,EAAE,wCAAwC;YACrD,OAAO,EAAE,YAAY,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,gCAAgC;YACzE,QAAQ,EAAE,aAAa,CAAC,IAAI;SAC7B,CAAC,CAAC;IACL,CAAC;;AAGH,MAAM,OAAO,uBAAwB,SAAQ,YAAY;IAChD,KAAK,CAAM;IAElB,YAAY,IAAe,EAAE,OAAe,EAAE,KAAU;QACtD,KAAK,CAAC;YACJ,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,GAAG;YACX,WAAW,EAAE,OAAO;YACpB,OAAO,EAAE,UAAU,KAAK,CAAC,OAAO,EAAE;YAClC,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;SACvE,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@powersync/service-errors",
3
3
  "repository": "https://github.com/powersync-ja/powersync-service",
4
- "version": "0.2.2",
4
+ "version": "0.3.1",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "FSL-1.1-Apache-2.0",