@element-hq/element-web-playwright-common 1.4.4 → 1.4.6

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.
@@ -18,6 +18,13 @@ import * as YAML from "yaml";
18
18
  import { getFreePort } from "../utils/port.js";
19
19
  import { deepCopy } from "../utils/object.js";
20
20
  import { type Credentials } from "../utils/api.js";
21
+ // This file can be updated by running:
22
+ //
23
+ // curl -sL https://element-hq.github.io/matrix-authentication-service/config.schema.json \
24
+ // | npx json-schema-to-typescript -o packages/element-web-playwright-common/src/testconainers/mas-config.ts
25
+ import type { RootConfig as MasConfig } from "./mas-config.js";
26
+
27
+ export { type MasConfig };
21
28
 
22
29
  const DEFAULT_CONFIG = {
23
30
  http: {
@@ -29,14 +36,8 @@ const DEFAULT_CONFIG = {
29
36
  { name: "human" },
30
37
  { name: "oauth" },
31
38
  { name: "compat" },
32
- {
33
- name: "graphql",
34
- playground: true,
35
- },
36
- {
37
- name: "assets",
38
- path: "/usr/local/share/mas-cli/assets/",
39
- },
39
+ { name: "graphql" },
40
+ { name: "assets" },
40
41
  ],
41
42
  binds: [
42
43
  {
@@ -60,7 +61,6 @@ const DEFAULT_CONFIG = {
60
61
  proxy_protocol: false,
61
62
  },
62
63
  ],
63
- trusted_proxies: ["192.128.0.0/16", "172.16.0.0/12", "10.0.0.0/10", "127.0.0.1/8", "fd00::/8", "::1/128"],
64
64
  public_base: "", // Needs to be set
65
65
  issuer: "", // Needs to be set
66
66
  },
@@ -70,28 +70,6 @@ const DEFAULT_CONFIG = {
70
70
  database: "postgres",
71
71
  username: "postgres",
72
72
  password: "p4S5w0rD",
73
- max_connections: 10,
74
- min_connections: 0,
75
- connect_timeout: 30,
76
- idle_timeout: 600,
77
- max_lifetime: 1800,
78
- },
79
- telemetry: {
80
- tracing: {
81
- exporter: "none",
82
- propagators: [],
83
- },
84
- metrics: {
85
- exporter: "none",
86
- },
87
- sentry: {
88
- dsn: null,
89
- },
90
- },
91
- templates: {
92
- path: "/usr/local/share/mas-cli/templates/",
93
- assets_manifest: "/usr/local/share/mas-cli/manifest.json",
94
- translations_path: "/usr/local/share/mas-cli/translations/",
95
73
  },
96
74
  email: {
97
75
  from: '"Authentication Service" <root@localhost>',
@@ -135,37 +113,19 @@ const DEFAULT_CONFIG = {
135
113
  minimum_complexity: 0,
136
114
  },
137
115
  policy: {
138
- wasm_module: "/usr/local/share/mas-cli/policy.wasm",
139
- client_registration_entrypoint: "client_registration/violation",
140
- register_entrypoint: "register/violation",
141
- authorization_grant_entrypoint: "authorization_grant/violation",
142
- password_entrypoint: "password/violation",
143
- email_entrypoint: "email/violation",
144
116
  data: {
145
117
  client_registration: {
146
118
  // allow non-SSL and localhost URIs
147
119
  allow_insecure_uris: true,
148
- // EW doesn't have contacts at this time
149
- allow_missing_contacts: true,
150
120
  },
151
121
  },
152
122
  },
153
- upstream_oauth2: {
154
- providers: [],
155
- },
156
- branding: {
157
- service_name: null,
158
- policy_uri: null,
159
- tos_uri: null,
160
- imprint: null,
161
- logo_uri: null,
162
- },
163
123
  account: {
164
124
  password_registration_enabled: true,
165
125
  },
166
- experimental: {
167
- access_token_ttl: 300,
168
- compat_token_ttl: 300,
126
+ matrix: {
127
+ kind: "synapse",
128
+ secret: "", // Needs to be set
169
129
  },
170
130
  rate_limiting: {
171
131
  login: {
@@ -177,12 +137,7 @@ const DEFAULT_CONFIG = {
177
137
  per_second: 1,
178
138
  },
179
139
  },
180
- };
181
-
182
- /**
183
- * Incomplete type for the MAS configuration.
184
- */
185
- export type MasConfig = typeof DEFAULT_CONFIG;
140
+ } satisfies MasConfig;
186
141
 
187
142
  /**
188
143
  * A container running the Matrix Authentication Service.
@@ -194,13 +149,17 @@ export class MatrixAuthenticationServiceContainer extends GenericContainer {
194
149
  private config: MasConfig;
195
150
  private readonly args = ["-c", "/config/config.yaml"];
196
151
 
197
- public constructor(db: StartedPostgreSqlContainer) {
198
- // We rely on https://github.com/element-hq/matrix-authentication-service/pull/4563 which isn't in a release yet
199
- super("ghcr.io/element-hq/matrix-authentication-service:sha-3207d23");
152
+ public constructor(
153
+ db: StartedPostgreSqlContainer,
154
+ image: string = "ghcr.io/element-hq/matrix-authentication-service:latest",
155
+ ) {
156
+ super(image);
200
157
 
201
- this.config = deepCopy(DEFAULT_CONFIG);
202
- this.config.database.username = db.getUsername();
203
- this.config.database.password = db.getPassword();
158
+ const initialConfig = deepCopy(DEFAULT_CONFIG);
159
+ initialConfig.database.username = db.getUsername();
160
+ initialConfig.database.password = db.getPassword();
161
+
162
+ this.config = initialConfig;
204
163
 
205
164
  this.withExposedPorts(8080, 8081)
206
165
  .withWaitStrategy(Wait.forHttp("/health", 8081))
@@ -211,7 +170,7 @@ export class MatrixAuthenticationServiceContainer extends GenericContainer {
211
170
  * Adds additional configuration to the MAS config.
212
171
  * @param config - additional config fields to add
213
172
  */
214
- public withConfig(config: object): this {
173
+ public withConfig(config: Partial<MasConfig>): this {
215
174
  this.config = {
216
175
  ...this.config,
217
176
  ...config,
@@ -226,8 +185,11 @@ export class MatrixAuthenticationServiceContainer extends GenericContainer {
226
185
  // MAS config issuer needs to know what URL it'll be accessed from, so we have to map the port manually
227
186
  const port = await getFreePort();
228
187
 
229
- this.config.http.public_base = `http://localhost:${port}/`;
230
- this.config.http.issuer = `http://localhost:${port}/`;
188
+ this.config.http = {
189
+ ...this.config.http,
190
+ public_base: `http://localhost:${port}/`,
191
+ issuer: `http://localhost:${port}/`,
192
+ };
231
193
 
232
194
  this.withExposedPorts({
233
195
  container: 8080,