svix 2.2.0 → 2.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svix",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "Svix webhooks API client and webhook verification library",
5
5
  "author": "svix",
6
6
  "repository": "https://github.com/svix/svix-webhooks",
@@ -42,7 +42,13 @@ test("AutoConfig rejects wrong prefix", () => {
42
42
  tok: "t",
43
43
  });
44
44
  const token = `wrong_${Buffer.from(json, "utf8").toString("base64")}`;
45
- assert.throws(() => new AutoConfig(token, { url: "https://x" }), AutoConfigError);
45
+ assert.throws(
46
+ () => new AutoConfig(token, { url: "https://x" }),
47
+ (err: unknown) =>
48
+ err instanceof AutoConfigError &&
49
+ err.message ===
50
+ "Unsupported token version. You might need to update the Svix SDK to use this token"
51
+ );
46
52
  });
47
53
 
48
54
  test("AutoConfig rejects invalid JSON payload", () => {
package/src/autoconfig.ts CHANGED
@@ -10,6 +10,8 @@ import {
10
10
  } from "./webhook";
11
11
 
12
12
  const AUTOCONFIG_TOKEN_PREFIX_V1 = "auto_v1_";
13
+ const UNSUPPORTED_TOKEN_VERSION =
14
+ "Unsupported token version. You might need to update the Svix SDK to use this token";
13
15
 
14
16
  export interface AutoConfigTokenContentV1 {
15
17
  aid: string;
@@ -45,7 +47,7 @@ export function isAutoConfigTokenContentV1(
45
47
 
46
48
  export function decodeAutoconfigTokenV1(token: string): AutoConfigTokenContentV1 {
47
49
  if (!token.startsWith(AUTOCONFIG_TOKEN_PREFIX_V1)) {
48
- throw new AutoConfigError();
50
+ throw new AutoConfigError(UNSUPPORTED_TOKEN_VERSION);
49
51
  }
50
52
  const b64 = token.slice(AUTOCONFIG_TOKEN_PREFIX_V1.length);
51
53
  let json: string;
@@ -157,6 +157,9 @@ export { type PollingEndpointMessageOut } from "./pollingEndpointMessageOut";
157
157
  export { type PollingEndpointOut } from "./pollingEndpointOut";
158
158
  export { type PortIoConfig } from "./portIoConfig";
159
159
  export { type PortIoConfigOut } from "./portIoConfigOut";
160
+ export { type PostgresConfigIn } from "./postgresConfigIn";
161
+ export { type PostgresConfigOut } from "./postgresConfigOut";
162
+ export { type PostgresConfigPatch } from "./postgresConfigPatch";
160
163
  export { type RabbitMqConfigIn } from "./rabbitMqConfigIn";
161
164
  export { type RabbitMqConfigOut } from "./rabbitMqConfigOut";
162
165
  export { type RabbitMqConfigPatch } from "./rabbitMqConfigPatch";
@@ -0,0 +1,44 @@
1
+ // this file is @generated
2
+
3
+ export interface PostgresConfigIn {
4
+ /**
5
+ * PostgreSQL connection URL, e.g. `postgres://user@host:5432/dbname?sslmode=require`.
6
+ *
7
+ * Do NOT embed a password here; use the `password` field instead.
8
+ */
9
+ url: string;
10
+ /** Password for the connection. */
11
+ password?: string | null;
12
+ /**
13
+ * Table to insert into. May be schema-qualified (e.g. `public.events`).
14
+ *
15
+ * Quote characters are not supported. Each dot-separated segment is automatically double-quoted when the query is built, so `public.events` becomes `"public"."events"`.
16
+ */
17
+ tableName: string;
18
+ /**
19
+ * PEM-encoded CA certificate used to verify the Postgres server's TLS certificate.
20
+ *
21
+ * Supply this to trust a private or self-signed CA when connecting with `sslmode=verify-ca` or `sslmode=verify-full`. Without it, only the built-in public roots are trusted.
22
+ */
23
+ sslRootCert?: string | null;
24
+ }
25
+
26
+ export const PostgresConfigInSerializer = {
27
+ _fromJsonObject(object: any): PostgresConfigIn {
28
+ return {
29
+ url: object["url"],
30
+ password: object["password"],
31
+ tableName: object["tableName"],
32
+ sslRootCert: object["sslRootCert"],
33
+ };
34
+ },
35
+
36
+ _toJsonObject(self: PostgresConfigIn): any {
37
+ return {
38
+ url: self.url,
39
+ password: self.password,
40
+ tableName: self.tableName,
41
+ sslRootCert: self.sslRootCert,
42
+ };
43
+ },
44
+ };
@@ -0,0 +1,25 @@
1
+ // this file is @generated
2
+
3
+ export interface PostgresConfigOut {
4
+ url: string;
5
+ tableName: string;
6
+ sslRootCert?: string | null;
7
+ }
8
+
9
+ export const PostgresConfigOutSerializer = {
10
+ _fromJsonObject(object: any): PostgresConfigOut {
11
+ return {
12
+ url: object["url"],
13
+ tableName: object["tableName"],
14
+ sslRootCert: object["sslRootCert"],
15
+ };
16
+ },
17
+
18
+ _toJsonObject(self: PostgresConfigOut): any {
19
+ return {
20
+ url: self.url,
21
+ tableName: self.tableName,
22
+ sslRootCert: self.sslRootCert,
23
+ };
24
+ },
25
+ };
@@ -0,0 +1,28 @@
1
+ // this file is @generated
2
+
3
+ export interface PostgresConfigPatch {
4
+ url?: string;
5
+ password?: string;
6
+ tableName?: string;
7
+ sslRootCert?: string;
8
+ }
9
+
10
+ export const PostgresConfigPatchSerializer = {
11
+ _fromJsonObject(object: any): PostgresConfigPatch {
12
+ return {
13
+ url: object["url"],
14
+ password: object["password"],
15
+ tableName: object["tableName"],
16
+ sslRootCert: object["sslRootCert"],
17
+ };
18
+ },
19
+
20
+ _toJsonObject(self: PostgresConfigPatch): any {
21
+ return {
22
+ url: self.url,
23
+ password: self.password,
24
+ tableName: self.tableName,
25
+ sslRootCert: self.sslRootCert,
26
+ };
27
+ },
28
+ };
@@ -5,22 +5,30 @@ export interface S3ConfigIn {
5
5
  /**
6
6
  * Access key ID.
7
7
  *
8
- * Currently a required field, but marked as optional because we may add different authentication in the future.
8
+ * Required (along with `secret_access_key`) if `role_arn` is null
9
9
  */
10
10
  accessKeyId?: string | null;
11
11
  /**
12
12
  * Secret access key.
13
13
  *
14
- * Currently a required field, but marked as optional because we may add different authentication in the future.
14
+ * Required (along with `access_key_id`) if `role_arn` is null
15
15
  */
16
16
  secretAccessKey?: string | null;
17
17
  /**
18
- * The region of the EventBridge bus.
18
+ * The region of the S3 bucket
19
19
  *
20
20
  * Currently a required field, but marked as optional because we may infer it from other fields in the future.
21
21
  */
22
22
  region?: string | null;
23
23
  endpointUrl?: string | null;
24
+ /** Role ARN for delegated authentication */
25
+ roleArn?: string | null;
26
+ /**
27
+ * Shared secret passed as the STS ExternalId.
28
+ *
29
+ * Required if `role_arn` is not null.
30
+ */
31
+ externalId?: string | null;
24
32
  }
25
33
 
26
34
  export const S3ConfigInSerializer = {
@@ -31,6 +39,8 @@ export const S3ConfigInSerializer = {
31
39
  secretAccessKey: object["secretAccessKey"],
32
40
  region: object["region"],
33
41
  endpointUrl: object["endpointUrl"],
42
+ roleArn: object["roleArn"],
43
+ externalId: object["externalId"],
34
44
  };
35
45
  },
36
46
 
@@ -41,6 +51,8 @@ export const S3ConfigInSerializer = {
41
51
  secretAccessKey: self.secretAccessKey,
42
52
  region: self.region,
43
53
  endpointUrl: self.endpointUrl,
54
+ roleArn: self.roleArn,
55
+ externalId: self.externalId,
44
56
  };
45
57
  },
46
58
  };
@@ -2,9 +2,11 @@
2
2
 
3
3
  export interface S3ConfigOut {
4
4
  bucket: string;
5
- accessKeyId: string;
5
+ accessKeyId?: string | null;
6
6
  region: string;
7
7
  endpointUrl?: string | null;
8
+ roleArn?: string | null;
9
+ externalId?: string | null;
8
10
  }
9
11
 
10
12
  export const S3ConfigOutSerializer = {
@@ -14,6 +16,8 @@ export const S3ConfigOutSerializer = {
14
16
  accessKeyId: object["accessKeyId"],
15
17
  region: object["region"],
16
18
  endpointUrl: object["endpointUrl"],
19
+ roleArn: object["roleArn"],
20
+ externalId: object["externalId"],
17
21
  };
18
22
  },
19
23
 
@@ -23,6 +27,8 @@ export const S3ConfigOutSerializer = {
23
27
  accessKeyId: self.accessKeyId,
24
28
  region: self.region,
25
29
  endpointUrl: self.endpointUrl,
30
+ roleArn: self.roleArn,
31
+ externalId: self.externalId,
26
32
  };
27
33
  },
28
34
  };
@@ -4,6 +4,8 @@ export interface S3ConfigPatch {
4
4
  bucket?: string;
5
5
  accessKeyId?: string;
6
6
  secretAccessKey?: string;
7
+ roleArn?: string;
8
+ externalId?: string;
7
9
  region?: string;
8
10
  endpointUrl?: string;
9
11
  }
@@ -14,6 +16,8 @@ export const S3ConfigPatchSerializer = {
14
16
  bucket: object["bucket"],
15
17
  accessKeyId: object["accessKeyId"],
16
18
  secretAccessKey: object["secretAccessKey"],
19
+ roleArn: object["roleArn"],
20
+ externalId: object["externalId"],
17
21
  region: object["region"],
18
22
  endpointUrl: object["endpointUrl"],
19
23
  };
@@ -24,6 +28,8 @@ export const S3ConfigPatchSerializer = {
24
28
  bucket: self.bucket,
25
29
  accessKeyId: self.accessKeyId,
26
30
  secretAccessKey: self.secretAccessKey,
31
+ roleArn: self.roleArn,
32
+ externalId: self.externalId,
27
33
  region: self.region,
28
34
  endpointUrl: self.endpointUrl,
29
35
  };
@@ -24,6 +24,7 @@ import {
24
24
  type OtelTracingConfigIn,
25
25
  OtelTracingConfigInSerializer,
26
26
  } from "./otelTracingConfigIn";
27
+ import { type PostgresConfigIn, PostgresConfigInSerializer } from "./postgresConfigIn";
27
28
  import { type RabbitMqConfigIn, RabbitMqConfigInSerializer } from "./rabbitMqConfigIn";
28
29
  import { type RedshiftConfigIn, RedshiftConfigInSerializer } from "./redshiftConfigIn";
29
30
  import { type S3ConfigIn, S3ConfigInSerializer } from "./s3ConfigIn";
@@ -138,6 +139,11 @@ interface StreamSinkInRedshift {
138
139
  config: RedshiftConfigIn;
139
140
  }
140
141
 
142
+ interface StreamSinkInPostgres {
143
+ type: "postgres";
144
+ config: PostgresConfigIn;
145
+ }
146
+
141
147
  export type StreamSinkIn = _StreamSinkInFields &
142
148
  (
143
149
  | StreamSinkInPoller
@@ -155,6 +161,7 @@ export type StreamSinkIn = _StreamSinkInFields &
155
161
  | StreamSinkInSnowflake
156
162
  | StreamSinkInRabbitMq
157
163
  | StreamSinkInRedshift
164
+ | StreamSinkInPostgres
158
165
  );
159
166
 
160
167
  export const StreamSinkInSerializer = {
@@ -193,6 +200,8 @@ export const StreamSinkInSerializer = {
193
200
  return RabbitMqConfigInSerializer._fromJsonObject(object["config"]);
194
201
  case "redshift":
195
202
  return RedshiftConfigInSerializer._fromJsonObject(object["config"]);
203
+ case "postgres":
204
+ return PostgresConfigInSerializer._fromJsonObject(object["config"]);
196
205
  default:
197
206
  throw new Error(`Unexpected type: ${type}`);
198
207
  }
@@ -263,6 +272,9 @@ export const StreamSinkInSerializer = {
263
272
  case "redshift":
264
273
  config = RedshiftConfigInSerializer._toJsonObject(self.config);
265
274
  break;
275
+ case "postgres":
276
+ config = PostgresConfigInSerializer._toJsonObject(self.config);
277
+ break;
266
278
  }
267
279
 
268
280
  return {
@@ -24,6 +24,7 @@ import {
24
24
  type OtelTracingConfigOut,
25
25
  OtelTracingConfigOutSerializer,
26
26
  } from "./otelTracingConfigOut";
27
+ import { type PostgresConfigOut, PostgresConfigOutSerializer } from "./postgresConfigOut";
27
28
  import { type RabbitMqConfigOut, RabbitMqConfigOutSerializer } from "./rabbitMqConfigOut";
28
29
  import { type RedshiftConfigOut, RedshiftConfigOutSerializer } from "./redshiftConfigOut";
29
30
  import { type S3ConfigOut, S3ConfigOutSerializer } from "./s3ConfigOut";
@@ -132,6 +133,11 @@ interface StreamSinkOutSns {
132
133
  config: SnsConfigOut;
133
134
  }
134
135
 
136
+ interface StreamSinkOutPostgres {
137
+ type: "postgres";
138
+ config: PostgresConfigOut;
139
+ }
140
+
135
141
  export type StreamSinkOut = _StreamSinkOutFields &
136
142
  (
137
143
  | StreamSinkOutPoller
@@ -149,6 +155,7 @@ export type StreamSinkOut = _StreamSinkOutFields &
149
155
  | StreamSinkOutSqs
150
156
  | StreamSinkOutEventBridge
151
157
  | StreamSinkOutSns
158
+ | StreamSinkOutPostgres
152
159
  );
153
160
 
154
161
  export const StreamSinkOutSerializer = {
@@ -187,6 +194,8 @@ export const StreamSinkOutSerializer = {
187
194
  return EventBridgeConfigOutSerializer._fromJsonObject(object["config"]);
188
195
  case "sns":
189
196
  return SnsConfigOutSerializer._fromJsonObject(object["config"]);
197
+ case "postgres":
198
+ return PostgresConfigOutSerializer._fromJsonObject(object["config"]);
190
199
  default:
191
200
  throw new Error(`Unexpected type: ${type}`);
192
201
  }
@@ -260,6 +269,9 @@ export const StreamSinkOutSerializer = {
260
269
  case "sns":
261
270
  config = SnsConfigOutSerializer._toJsonObject(self.config);
262
271
  break;
272
+ case "postgres":
273
+ config = PostgresConfigOutSerializer._toJsonObject(self.config);
274
+ break;
263
275
  }
264
276
 
265
277
  return {
@@ -27,6 +27,10 @@ import {
27
27
  type OtelTracingConfigPatch,
28
28
  OtelTracingConfigPatchSerializer,
29
29
  } from "./otelTracingConfigPatch";
30
+ import {
31
+ type PostgresConfigPatch,
32
+ PostgresConfigPatchSerializer,
33
+ } from "./postgresConfigPatch";
30
34
  import {
31
35
  type RabbitMqConfigPatch,
32
36
  RabbitMqConfigPatchSerializer,
@@ -137,6 +141,11 @@ interface StreamSinkPatchRedshift {
137
141
  config: RedshiftConfigPatch;
138
142
  }
139
143
 
144
+ interface StreamSinkPatchPostgres {
145
+ type: "postgres";
146
+ config: PostgresConfigPatch;
147
+ }
148
+
140
149
  export type StreamSinkPatch = _StreamSinkPatchFields &
141
150
  (
142
151
  | StreamSinkPatchPoller
@@ -154,6 +163,7 @@ export type StreamSinkPatch = _StreamSinkPatchFields &
154
163
  | StreamSinkPatchSnowflake
155
164
  | StreamSinkPatchRabbitMq
156
165
  | StreamSinkPatchRedshift
166
+ | StreamSinkPatchPostgres
157
167
  );
158
168
 
159
169
  export const StreamSinkPatchSerializer = {
@@ -194,6 +204,8 @@ export const StreamSinkPatchSerializer = {
194
204
  return RabbitMqConfigPatchSerializer._fromJsonObject(object["config"]);
195
205
  case "redshift":
196
206
  return RedshiftConfigPatchSerializer._fromJsonObject(object["config"]);
207
+ case "postgres":
208
+ return PostgresConfigPatchSerializer._fromJsonObject(object["config"]);
197
209
  default:
198
210
  throw new Error(`Unexpected type: ${type}`);
199
211
  }
@@ -264,6 +276,9 @@ export const StreamSinkPatchSerializer = {
264
276
  case "redshift":
265
277
  config = RedshiftConfigPatchSerializer._toJsonObject(self.config);
266
278
  break;
279
+ case "postgres":
280
+ config = PostgresConfigPatchSerializer._toJsonObject(self.config);
281
+ break;
267
282
  }
268
283
 
269
284
  return {
package/src/request.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ApiException, type XOR } from "./util";
2
2
  import type { HttpErrorOut, HTTPValidationError } from "./HttpErrors";
3
3
 
4
- export const LIB_VERSION = "2.2.0";
4
+ export const LIB_VERSION = "2.3.0";
5
5
 
6
6
  function getUserAgent() {
7
7
  var fields = [`svix-libs/${LIB_VERSION}/javascript`];