@sebspark/test-iap 1.0.26 → 1.0.28
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 +253 -0
- package/dist/index.d.mts +6 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +6 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -6
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
# @sebspark/test-iap
|
|
2
|
+
|
|
3
|
+
## 1.0.28
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9f44fbd: Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 1.0.27
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 66ac832: * Upgraded to TypeScript 7
|
|
14
|
+
- Replaced tsup with tsdown for package builds
|
|
15
|
+
- Fixed cli-tester stdout parsing, resolving flaky e2e tests across the repo
|
|
16
|
+
- Patched vulnerable transitive dependencies (uuid, socket.io-parser, and others)
|
|
17
|
+
|
|
18
|
+
## 1.0.26
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- eefb531: Updated dependencies
|
|
23
|
+
|
|
24
|
+
## 1.0.25
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- 5e9fc45: Bump dependencies. Security fixes:
|
|
29
|
+
|
|
30
|
+
- **form-data** 2.5.6 / 4.0.6 — CRLF injection via unescaped multipart field names and filenames (High)
|
|
31
|
+
- **vite** 8.1.2 — `server.fs.deny` bypass on Windows alternate paths; NTLMv2 hash disclosure via launch-editor (High/Moderate)
|
|
32
|
+
- **ws** 8.21.0 — Memory exhaustion DoS from tiny fragments; uninitialized memory disclosure (High/Moderate)
|
|
33
|
+
- **undici** 8.5.0 — Multiple DoS and information disclosure CVEs (High/Moderate/Low)
|
|
34
|
+
- **tar** 7.5.19 — PAX size override causes tar parser differential / file smuggling (Moderate)
|
|
35
|
+
- **qs** 6.15.3 — DoS via `qs.stringify` crash on null/undefined entries (Moderate)
|
|
36
|
+
- **@opentelemetry/core** 2.8.0 — Unbounded memory allocation in W3C Baggage propagation (Moderate)
|
|
37
|
+
- **@babel/core** 7.29.7 — Arbitrary file read via sourceMappingURL comment (Low)
|
|
38
|
+
- **protobufjs** 8.6.5
|
|
39
|
+
|
|
40
|
+
Other dependency updates:
|
|
41
|
+
|
|
42
|
+
- `@google-cloud/spanner` 8.8.0
|
|
43
|
+
- `@testcontainers/*` 12.0.4
|
|
44
|
+
- `google-auth-library` 10.9.0
|
|
45
|
+
- `mockserver-client` 7.3.0
|
|
46
|
+
- `nock` 14.0.16
|
|
47
|
+
- `prettier` 3.9.4
|
|
48
|
+
- `redis` 6.1.0
|
|
49
|
+
- `webpack` 5.108.3 / `webpack-cli` 7.1.0
|
|
50
|
+
|
|
51
|
+
## 1.0.24
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- 3111112: Openapi client args are now PartiallySerialized
|
|
56
|
+
|
|
57
|
+
Also: dependency updates
|
|
58
|
+
|
|
59
|
+
## 1.0.23
|
|
60
|
+
|
|
61
|
+
### Patch Changes
|
|
62
|
+
|
|
63
|
+
- e0eda57: Updated dependencies
|
|
64
|
+
|
|
65
|
+
## 1.0.22
|
|
66
|
+
|
|
67
|
+
### Patch Changes
|
|
68
|
+
|
|
69
|
+
- 26d55f0: Fix `@sebspark/memredis` so Redis clients are assignable to `IPersistor` by widening the pub/sub subscription return types to accept both MemRedis and node-redis implementations.
|
|
70
|
+
|
|
71
|
+
Also update supporting dependencies across the affected packages.
|
|
72
|
+
|
|
73
|
+
## 1.0.21
|
|
74
|
+
|
|
75
|
+
### Patch Changes
|
|
76
|
+
|
|
77
|
+
- a6c27f3: Updated dependencies
|
|
78
|
+
|
|
79
|
+
## 1.0.20
|
|
80
|
+
|
|
81
|
+
### Patch Changes
|
|
82
|
+
|
|
83
|
+
- 264e665: Upgrade `redis` to v6 in `@sebspark/promise-cache` and bump minor dependencies across the workspace.
|
|
84
|
+
|
|
85
|
+
**Breaking change (`@sebspark/promise-cache`):**
|
|
86
|
+
`redis` upgraded from `5.12.1` → `6.0.0`. Redis v6 contains breaking changes in its API — see the [redis v6 migration guide](https://github.com/redis/node-redis/blob/master/docs/v4-to-v6.md) if your code uses the client directly.
|
|
87
|
+
|
|
88
|
+
**Dependency updates across packages:**
|
|
89
|
+
- `testcontainers` / `@testcontainers/*`: `12.0.0` → `12.0.1` (health-check, opensearch, opentelemetry-instrumentation-opensearch, otel, promise-cache, socket.io-gcp-pubsub-emitter, spanner-migrate, test-iap)
|
|
90
|
+
- `redis`: `5.12.1` → `6.0.0` (otel, promise-cache)
|
|
91
|
+
- `tsdown`: `0.22.0` → `0.22.1` (tsconfig)
|
|
92
|
+
- `turbo` / `@turbo/gen`: `2.9.15` → `2.9.16`
|
|
93
|
+
- `webpack-cli`: `7.0.2` → `7.0.3` (avsc-isometric)
|
|
94
|
+
|
|
95
|
+
**Test fix (`@sebspark/promise-cache`):**
|
|
96
|
+
Pinned Redis container image tag to `redis:8.8-alpine` (was `redis:8-alpine`) to prevent floating-tag drift in e2e tests.
|
|
97
|
+
|
|
98
|
+
## 1.0.19
|
|
99
|
+
|
|
100
|
+
### Patch Changes
|
|
101
|
+
|
|
102
|
+
- 242eb33: This release primarily updates dependencies across the listed packages, including:
|
|
103
|
+
- Testcontainers v12 upgrades in packages that run integration/e2e tests.
|
|
104
|
+
- Vitest/Biome/Turbo and related tooling updates.
|
|
105
|
+
- Runtime dependency updates such as `date-fns`, `@inquirer/*`, `socket.io-adapter`, and `ws`.
|
|
106
|
+
|
|
107
|
+
It also includes two targeted fixes:
|
|
108
|
+
- `@sebspark/opensearch`: fixed TypeScript compatibility so strict `SearchRequest<T>` / `SearchRequestBody<T>` can be assigned to OpenSearch API request types, and added a compile-time compatibility test.
|
|
109
|
+
- `@sebspark/health-check`: updated the e2e readiness payload assertions and type-only import usage to match current runtime output and TypeScript expectations.
|
|
110
|
+
|
|
111
|
+
## 1.0.18
|
|
112
|
+
|
|
113
|
+
### Patch Changes
|
|
114
|
+
|
|
115
|
+
- c5e9c99: Resolve protobufjs CVE by pinning to `8.3.0` across all affected packages via root resolutions. Upgraded OpenTelemetry packages to `0.218.0` (which also eliminates the previous hardpin on `protobufjs@8.0.1`), `axios` to `1.16.1`, `ws` to `8.20.1`, `qs` to `6.15.2`, and `@opentelemetry/semantic-conventions` to `1.41.1`.
|
|
116
|
+
|
|
117
|
+
## 1.0.17
|
|
118
|
+
|
|
119
|
+
### Patch Changes
|
|
120
|
+
|
|
121
|
+
- 7d8cc98: Dependabot dependency updates
|
|
122
|
+
|
|
123
|
+
## 1.0.16
|
|
124
|
+
|
|
125
|
+
### Patch Changes
|
|
126
|
+
|
|
127
|
+
- e9a7a28: Updated dependencies
|
|
128
|
+
|
|
129
|
+
## 1.0.15
|
|
130
|
+
|
|
131
|
+
### Patch Changes
|
|
132
|
+
|
|
133
|
+
- 4e12590: Updated dependencies
|
|
134
|
+
|
|
135
|
+
## 1.0.14
|
|
136
|
+
|
|
137
|
+
### Patch Changes
|
|
138
|
+
|
|
139
|
+
- 67871de: Otel now warns on stdout. Also dependency updates.
|
|
140
|
+
|
|
141
|
+
## 1.0.13
|
|
142
|
+
|
|
143
|
+
### Patch Changes
|
|
144
|
+
|
|
145
|
+
- 6d72f97: Updated dependencies
|
|
146
|
+
|
|
147
|
+
## 1.0.12
|
|
148
|
+
|
|
149
|
+
### Patch Changes
|
|
150
|
+
|
|
151
|
+
- 736a0b3: No bundling of packages in packages
|
|
152
|
+
|
|
153
|
+
## 1.0.11
|
|
154
|
+
|
|
155
|
+
### Patch Changes
|
|
156
|
+
|
|
157
|
+
- 2241dc7: Updated dependencies
|
|
158
|
+
|
|
159
|
+
## 1.0.10
|
|
160
|
+
|
|
161
|
+
### Patch Changes
|
|
162
|
+
|
|
163
|
+
- 35ec1a0: Updated dependencies
|
|
164
|
+
|
|
165
|
+
## 1.0.8
|
|
166
|
+
|
|
167
|
+
### Patch Changes
|
|
168
|
+
|
|
169
|
+
- 48ab717: Updated dependencies
|
|
170
|
+
|
|
171
|
+
## 1.0.7
|
|
172
|
+
|
|
173
|
+
### Patch Changes
|
|
174
|
+
|
|
175
|
+
- b40eb86: Updated dependencies
|
|
176
|
+
|
|
177
|
+
## 1.0.6
|
|
178
|
+
|
|
179
|
+
### Patch Changes
|
|
180
|
+
|
|
181
|
+
- e0cb5ee: Updated build from tsup to tsdown
|
|
182
|
+
|
|
183
|
+
## 1.0.5
|
|
184
|
+
|
|
185
|
+
### Patch Changes
|
|
186
|
+
|
|
187
|
+
- cc28876: Updated dependencies
|
|
188
|
+
|
|
189
|
+
## 1.0.4
|
|
190
|
+
|
|
191
|
+
### Patch Changes
|
|
192
|
+
|
|
193
|
+
- 7df8217: Updated dependencies
|
|
194
|
+
|
|
195
|
+
## 1.0.3
|
|
196
|
+
|
|
197
|
+
### Patch Changes
|
|
198
|
+
|
|
199
|
+
- 4b210c2: Standardized on a common build script
|
|
200
|
+
|
|
201
|
+
## 1.0.2
|
|
202
|
+
|
|
203
|
+
### Patch Changes
|
|
204
|
+
|
|
205
|
+
- 7e5c2e9: Switched to new tsconfig with moduleResolution=bundler
|
|
206
|
+
|
|
207
|
+
## 1.0.1
|
|
208
|
+
|
|
209
|
+
### Patch Changes
|
|
210
|
+
|
|
211
|
+
- d801e1e: Updated dependencies and fixed some exports
|
|
212
|
+
|
|
213
|
+
## 1.0.0
|
|
214
|
+
|
|
215
|
+
### Major Changes
|
|
216
|
+
|
|
217
|
+
- 0864ec2: ESM only. Minimum node version 22
|
|
218
|
+
|
|
219
|
+
## 0.1.5
|
|
220
|
+
|
|
221
|
+
### Patch Changes
|
|
222
|
+
|
|
223
|
+
- 3a40e49: Cleaned up dependencies
|
|
224
|
+
|
|
225
|
+
## 0.1.4
|
|
226
|
+
|
|
227
|
+
### Patch Changes
|
|
228
|
+
|
|
229
|
+
- 604c94a: Updated dependencies
|
|
230
|
+
|
|
231
|
+
## 0.1.3
|
|
232
|
+
|
|
233
|
+
### Patch Changes
|
|
234
|
+
|
|
235
|
+
- 29b9b20: Updated dependencies
|
|
236
|
+
|
|
237
|
+
## 0.1.2
|
|
238
|
+
|
|
239
|
+
### Patch Changes
|
|
240
|
+
|
|
241
|
+
- 5c6e183: Updated dependencies
|
|
242
|
+
|
|
243
|
+
## 0.1.1
|
|
244
|
+
|
|
245
|
+
### Patch Changes
|
|
246
|
+
|
|
247
|
+
- 9268050: Fixed documentation
|
|
248
|
+
|
|
249
|
+
## 0.1.0
|
|
250
|
+
|
|
251
|
+
### Minor Changes
|
|
252
|
+
|
|
253
|
+
- 3f1cd1a: A test IAP for e2e testing
|
package/dist/index.d.mts
CHANGED
|
@@ -9,29 +9,31 @@ interface ProxyConfig {
|
|
|
9
9
|
}
|
|
10
10
|
//#endregion
|
|
11
11
|
//#region src/server.d.ts
|
|
12
|
-
declare const createProxyServer: (config: ProxyConfig) => http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
12
|
+
export declare const createProxyServer: (config: ProxyConfig) => http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
13
13
|
//#endregion
|
|
14
14
|
//#region src/test-iap-container.d.ts
|
|
15
|
-
declare class TestIapContainer {
|
|
15
|
+
export declare class TestIapContainer {
|
|
16
16
|
private baseImage;
|
|
17
17
|
private port;
|
|
18
18
|
private target?;
|
|
19
19
|
private mode?;
|
|
20
20
|
private downstream?;
|
|
21
21
|
private network?;
|
|
22
|
+
private labels;
|
|
22
23
|
withBaseImage(image: string): this;
|
|
23
24
|
withPort(port: number): this;
|
|
24
25
|
withTarget(url: string): this;
|
|
25
26
|
withMode(mode: Mode): this;
|
|
26
27
|
withDownstream(url: string): this;
|
|
27
28
|
withNetwork(network: StartedNetwork): this;
|
|
29
|
+
withLabels(labels: Record<string, string>): this;
|
|
28
30
|
start(): Promise<StartedTestIapContainer>;
|
|
29
31
|
}
|
|
30
|
-
declare class StartedTestIapContainer extends AbstractStartedContainer {
|
|
32
|
+
export declare class StartedTestIapContainer extends AbstractStartedContainer {
|
|
31
33
|
private readonly internalPort;
|
|
32
34
|
constructor(started: StartedTestContainer, internalPort: number);
|
|
33
35
|
getEndpoint(): string;
|
|
34
36
|
}
|
|
35
37
|
//#endregion
|
|
36
|
-
export {
|
|
38
|
+
export type { Mode, ProxyConfig };
|
|
37
39
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/server.ts","../src/test-iap-container.ts"],"mappings":";;;KAOY;UACK;EACf;EACA,OAAO;EACP;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/server.ts","../src/test-iap-container.ts"],"mappings":";;;KAOY;UACK;EACf;EACA,OAAO;EACP;;;;qBCGW,oBAAiB,QAAY,gBAAW,KAAA,cAAA,KAAA,wBAAA,KAAA;;;qBCDxC;UACH;UACA;UACA;UACA;UACA;UACA;UACA;EAED,cAAc;EAId,SAAS;EAKT,WAAW;EAUX,SAAS,MAAM;EAKf,eAAe;EAUf,YAAY,SAAS;EAKrB,WAAW,QAAQ;EAKb,SAAS,QAAQ;;qBAoEnB,gCAAgC;mBAGxB;EAFnB,YACE,SAAS,sBACQ;EAIZ"}
|
package/dist/index.mjs
CHANGED
|
@@ -46,6 +46,7 @@ var TestIapContainer = class {
|
|
|
46
46
|
mode;
|
|
47
47
|
downstream;
|
|
48
48
|
network;
|
|
49
|
+
labels = {};
|
|
49
50
|
withBaseImage(image) {
|
|
50
51
|
this.baseImage = image;
|
|
51
52
|
return this;
|
|
@@ -79,6 +80,10 @@ var TestIapContainer = class {
|
|
|
79
80
|
this.network = network;
|
|
80
81
|
return this;
|
|
81
82
|
}
|
|
83
|
+
withLabels(labels) {
|
|
84
|
+
this.labels = labels;
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
82
87
|
async start() {
|
|
83
88
|
assert(this.target, "withTarget(...) is required");
|
|
84
89
|
const resolvedMode = this.mode ?? (this.downstream ? "downstream" : "local");
|
|
@@ -107,7 +112,7 @@ var TestIapContainer = class {
|
|
|
107
112
|
PORT: String(this.port)
|
|
108
113
|
};
|
|
109
114
|
if (resolvedMode === "downstream" && this.downstream) env.DOWNSTREAM = this.downstream;
|
|
110
|
-
const gc = new GenericContainer(this.baseImage).withWorkingDir("/app").withBindMounts(binds).withExposedPorts(this.port).withEnvironment(env).withCommand(["node", entry]);
|
|
115
|
+
const gc = new GenericContainer(this.baseImage).withWorkingDir("/app").withBindMounts(binds).withExposedPorts(this.port).withEnvironment(env).withLabels(this.labels).withCommand(["node", entry]);
|
|
111
116
|
if (this.network) gc.withNetwork(this.network);
|
|
112
117
|
return new StartedTestIapContainer(await gc.start(), this.port);
|
|
113
118
|
}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/build-helpers.ts","../src/test-iap-container.ts"],"sourcesContent":["import { createRequire } from 'node:module'\nimport path from 'node:path'\nimport { fileURLToPath, pathToFileURL } from 'node:url'\n\n/**\n * Works in both CJS and ESM without tripping bundlers:\n * - CJS: derives from __filename\n * - ESM: evals import.meta.url so it's not statically analyzed\n */\nexport const getThisFileUrl = (): string => {\n if (typeof __filename !== 'undefined') {\n return pathToFileURL(__filename).href\n }\n // biome-ignore lint/security/noGlobalEval: needed for cjs/esm compatibility\n // biome-ignore lint/complexity/noCommaOperator: needed for cjs/esm compatibility\n return (0, eval)('import.meta.url') as string\n}\n\n/** Directory of the current compiled file (e.g., your package's dist dir) */\nexport const getThisDir = (): string =>\n path.dirname(fileURLToPath(getThisFileUrl()))\n\n/** A require() that works in both CJS and ESM builds */\nexport const getRequireCompat = (): ReturnType<typeof createRequire> =>\n typeof require === 'function' ? require : createRequire(getThisFileUrl())\n\n/**\n * Resolve a module specifier relative to this package’s installed location.\n * Example: resolveNearSelf('jose/package.json')\n */\nexport const resolveNearSelf = (specifier: string): string => {\n const req = getRequireCompat()\n return req.resolve(specifier, { paths: [getThisDir()] })\n}\n\n/** Safe resolve: returns undefined if not found */\nexport const tryResolveNearSelf = (specifier: string): string | undefined => {\n try {\n return resolveNearSelf(specifier)\n } catch {\n return undefined\n }\n}\n","import assert from 'node:assert'\nimport fs from 'node:fs'\n// src/test-iap-container.ts\nimport path from 'node:path'\nimport {\n AbstractStartedContainer,\n GenericContainer,\n type StartedNetwork,\n type StartedTestContainer,\n} from 'testcontainers'\nimport { getThisDir, tryResolveNearSelf } from './build-helpers'\nimport type { Mode } from './types'\n\nexport class TestIapContainer {\n private baseImage = 'node:22-alpine'\n private port = 3000\n private target?: string\n private mode?: Mode\n private downstream?: string\n private network?: StartedNetwork\n\n public withBaseImage(image: string) {\n this.baseImage = image\n return this\n }\n public withPort(port: number) {\n this.port = port\n return this\n }\n\n public withTarget(url: string) {\n const u = new URL(url)\n assert(\n ['http:', 'https:', 'ws:', 'wss:'].includes(u.protocol),\n 'target must be absolute http(s):// or ws(s)://'\n )\n this.target = u.toString()\n return this\n }\n\n public withMode(mode: Mode) {\n this.mode = mode\n return this\n }\n\n public withDownstream(url: string) {\n const u = new URL(url)\n assert(\n ['http:', 'https:'].includes(u.protocol),\n 'downstream must be absolute http(s)://'\n )\n this.downstream = u.toString()\n return this\n }\n\n public withNetwork(network: StartedNetwork) {\n this.network = network\n return this\n }\n\n public async start(): Promise<StartedTestIapContainer> {\n assert(this.target, 'withTarget(...) is required')\n\n const resolvedMode: Mode =\n this.mode ?? (this.downstream ? 'downstream' : 'local')\n if (resolvedMode === 'downstream') {\n assert(\n this.downstream,\n 'withDownstream(...) is required when mode=downstream'\n )\n }\n\n // directory of the installed package's compiled files (dist)\n const distDir = path.join(getThisDir(), '../dist')\n assert(fs.existsSync(distDir), `dist directory not found: ${distDir}`)\n\n // prefer start.mjs, then start.js\n const startMjs = path.join(distDir, 'start.mjs')\n const startJs = path.join(distDir, 'start.js')\n\n const hasStartMjs = fs.existsSync(startMjs)\n const hasStartJs = fs.existsSync(startJs)\n\n if (!hasStartMjs && !hasStartJs) {\n throw new Error(`Could not find ${startMjs} or ${startJs}`)\n }\n\n const entry = hasStartMjs ? '/app/dist/start.mjs' : '/app/dist/start.js'\n\n // mount dist + the installed 'jose' module so imports work inside the container\n const josePkgPath = tryResolveNearSelf('jose/package.json')\n if (!josePkgPath) {\n throw new Error(\n 'Could not resolve \"jose\" next to @sebspark/test-iap. ' +\n 'Ensure \"jose\" is installed as a dependency in the same project that installs @sebspark/test-iap.'\n )\n }\n const joseDir = path.dirname(josePkgPath)\n\n const binds = [\n { source: distDir, target: '/app/dist' },\n { source: joseDir, target: '/app/node_modules/jose' },\n ]\n\n const env: Record<string, string> = {\n TARGET: this.target as string,\n MODE: resolvedMode,\n PORT: String(this.port),\n }\n if (resolvedMode === 'downstream' && this.downstream) {\n env.DOWNSTREAM = this.downstream\n }\n\n const gc = new GenericContainer(this.baseImage)\n .withWorkingDir('/app')\n .withBindMounts(binds)\n .withExposedPorts(this.port)\n .withEnvironment(env)\n .withCommand(['node', entry])\n\n if (this.network) gc.withNetwork(this.network)\n\n const started = await gc.start()\n return new StartedTestIapContainer(started, this.port)\n }\n}\n\nexport class StartedTestIapContainer extends AbstractStartedContainer {\n constructor(\n started: StartedTestContainer,\n private readonly internalPort: number\n ) {\n super(started)\n }\n public getEndpoint() {\n return `${this.getHost()}:${this.getMappedPort(this.internalPort)}`\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AASA,MAAa,uBAA+B;CAC1C,IAAI,OAAO,eAAe,aACxB,OAAO,cAAc,UAAU,CAAC,CAAC;CAInC,QAAQ,GAAG,KAAA,CAAM,iBAAiB;AACpC;;AAGA,MAAa,mBACX,KAAK,QAAQ,cAAc,eAAe,CAAC,CAAC;;AAG9C,MAAa,yBACX,OAAA,cAAmB,aAAA,YAAuB,cAAc,eAAe,CAAC;;;;;AAM1E,MAAa,mBAAmB,cAA8B;CAE5D,OADY,iBACH,CAAC,CAAC,QAAQ,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;AACzD;;AAGA,MAAa,sBAAsB,cAA0C;CAC3E,IAAI;EACF,OAAO,gBAAgB,SAAS;CAClC,QAAQ;EACN;CACF;AACF;;;AC7BA,IAAa,mBAAb,MAA8B;CAC5B,YAAoB;CACpB,OAAe;CACf;CACA;CACA;CACA;
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/build-helpers.ts","../src/test-iap-container.ts"],"sourcesContent":["import { createRequire } from 'node:module'\nimport path from 'node:path'\nimport { fileURLToPath, pathToFileURL } from 'node:url'\n\n/**\n * Works in both CJS and ESM without tripping bundlers:\n * - CJS: derives from __filename\n * - ESM: evals import.meta.url so it's not statically analyzed\n */\nexport const getThisFileUrl = (): string => {\n if (typeof __filename !== 'undefined') {\n return pathToFileURL(__filename).href\n }\n // biome-ignore lint/security/noGlobalEval: needed for cjs/esm compatibility\n // biome-ignore lint/complexity/noCommaOperator: needed for cjs/esm compatibility\n return (0, eval)('import.meta.url') as string\n}\n\n/** Directory of the current compiled file (e.g., your package's dist dir) */\nexport const getThisDir = (): string =>\n path.dirname(fileURLToPath(getThisFileUrl()))\n\n/** A require() that works in both CJS and ESM builds */\nexport const getRequireCompat = (): ReturnType<typeof createRequire> =>\n typeof require === 'function' ? require : createRequire(getThisFileUrl())\n\n/**\n * Resolve a module specifier relative to this package’s installed location.\n * Example: resolveNearSelf('jose/package.json')\n */\nexport const resolveNearSelf = (specifier: string): string => {\n const req = getRequireCompat()\n return req.resolve(specifier, { paths: [getThisDir()] })\n}\n\n/** Safe resolve: returns undefined if not found */\nexport const tryResolveNearSelf = (specifier: string): string | undefined => {\n try {\n return resolveNearSelf(specifier)\n } catch {\n return undefined\n }\n}\n","import assert from 'node:assert'\nimport fs from 'node:fs'\n// src/test-iap-container.ts\nimport path from 'node:path'\nimport {\n AbstractStartedContainer,\n GenericContainer,\n type StartedNetwork,\n type StartedTestContainer,\n} from 'testcontainers'\nimport { getThisDir, tryResolveNearSelf } from './build-helpers'\nimport type { Mode } from './types'\n\nexport class TestIapContainer {\n private baseImage = 'node:22-alpine'\n private port = 3000\n private target?: string\n private mode?: Mode\n private downstream?: string\n private network?: StartedNetwork\n private labels: Record<string, string> = {}\n\n public withBaseImage(image: string) {\n this.baseImage = image\n return this\n }\n public withPort(port: number) {\n this.port = port\n return this\n }\n\n public withTarget(url: string) {\n const u = new URL(url)\n assert(\n ['http:', 'https:', 'ws:', 'wss:'].includes(u.protocol),\n 'target must be absolute http(s):// or ws(s)://'\n )\n this.target = u.toString()\n return this\n }\n\n public withMode(mode: Mode) {\n this.mode = mode\n return this\n }\n\n public withDownstream(url: string) {\n const u = new URL(url)\n assert(\n ['http:', 'https:'].includes(u.protocol),\n 'downstream must be absolute http(s)://'\n )\n this.downstream = u.toString()\n return this\n }\n\n public withNetwork(network: StartedNetwork) {\n this.network = network\n return this\n }\n\n public withLabels(labels: Record<string, string>) {\n this.labels = labels\n return this\n }\n\n public async start(): Promise<StartedTestIapContainer> {\n assert(this.target, 'withTarget(...) is required')\n\n const resolvedMode: Mode =\n this.mode ?? (this.downstream ? 'downstream' : 'local')\n if (resolvedMode === 'downstream') {\n assert(\n this.downstream,\n 'withDownstream(...) is required when mode=downstream'\n )\n }\n\n // directory of the installed package's compiled files (dist)\n const distDir = path.join(getThisDir(), '../dist')\n assert(fs.existsSync(distDir), `dist directory not found: ${distDir}`)\n\n // prefer start.mjs, then start.js\n const startMjs = path.join(distDir, 'start.mjs')\n const startJs = path.join(distDir, 'start.js')\n\n const hasStartMjs = fs.existsSync(startMjs)\n const hasStartJs = fs.existsSync(startJs)\n\n if (!hasStartMjs && !hasStartJs) {\n throw new Error(`Could not find ${startMjs} or ${startJs}`)\n }\n\n const entry = hasStartMjs ? '/app/dist/start.mjs' : '/app/dist/start.js'\n\n // mount dist + the installed 'jose' module so imports work inside the container\n const josePkgPath = tryResolveNearSelf('jose/package.json')\n if (!josePkgPath) {\n throw new Error(\n 'Could not resolve \"jose\" next to @sebspark/test-iap. ' +\n 'Ensure \"jose\" is installed as a dependency in the same project that installs @sebspark/test-iap.'\n )\n }\n const joseDir = path.dirname(josePkgPath)\n\n const binds = [\n { source: distDir, target: '/app/dist' },\n { source: joseDir, target: '/app/node_modules/jose' },\n ]\n\n const env: Record<string, string> = {\n TARGET: this.target as string,\n MODE: resolvedMode,\n PORT: String(this.port),\n }\n if (resolvedMode === 'downstream' && this.downstream) {\n env.DOWNSTREAM = this.downstream\n }\n\n const gc = new GenericContainer(this.baseImage)\n .withWorkingDir('/app')\n .withBindMounts(binds)\n .withExposedPorts(this.port)\n .withEnvironment(env)\n .withLabels(this.labels)\n .withCommand(['node', entry])\n\n if (this.network) gc.withNetwork(this.network)\n\n const started = await gc.start()\n return new StartedTestIapContainer(started, this.port)\n }\n}\n\nexport class StartedTestIapContainer extends AbstractStartedContainer {\n constructor(\n started: StartedTestContainer,\n private readonly internalPort: number\n ) {\n super(started)\n }\n public getEndpoint() {\n return `${this.getHost()}:${this.getMappedPort(this.internalPort)}`\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AASA,MAAa,uBAA+B;CAC1C,IAAI,OAAO,eAAe,aACxB,OAAO,cAAc,UAAU,CAAC,CAAC;CAInC,QAAQ,GAAG,KAAA,CAAM,iBAAiB;AACpC;;AAGA,MAAa,mBACX,KAAK,QAAQ,cAAc,eAAe,CAAC,CAAC;;AAG9C,MAAa,yBACX,OAAA,cAAmB,aAAA,YAAuB,cAAc,eAAe,CAAC;;;;;AAM1E,MAAa,mBAAmB,cAA8B;CAE5D,OADY,iBACH,CAAC,CAAC,QAAQ,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;AACzD;;AAGA,MAAa,sBAAsB,cAA0C;CAC3E,IAAI;EACF,OAAO,gBAAgB,SAAS;CAClC,QAAQ;EACN;CACF;AACF;;;AC7BA,IAAa,mBAAb,MAA8B;CAC5B,YAAoB;CACpB,OAAe;CACf;CACA;CACA;CACA;CACA,SAAyC,CAAC;CAE1C,cAAqB,OAAe;EAClC,KAAK,YAAY;EACjB,OAAO;CACT;CACA,SAAgB,MAAc;EAC5B,KAAK,OAAO;EACZ,OAAO;CACT;CAEA,WAAkB,KAAa;EAC7B,MAAM,IAAI,IAAI,IAAI,GAAG;EACrB,OACE;GAAC;GAAS;GAAU;GAAO;EAAM,CAAC,CAAC,SAAS,EAAE,QAAQ,GACtD,gDACF;EACA,KAAK,SAAS,EAAE,SAAS;EACzB,OAAO;CACT;CAEA,SAAgB,MAAY;EAC1B,KAAK,OAAO;EACZ,OAAO;CACT;CAEA,eAAsB,KAAa;EACjC,MAAM,IAAI,IAAI,IAAI,GAAG;EACrB,OACE,CAAC,SAAS,QAAQ,CAAC,CAAC,SAAS,EAAE,QAAQ,GACvC,wCACF;EACA,KAAK,aAAa,EAAE,SAAS;EAC7B,OAAO;CACT;CAEA,YAAmB,SAAyB;EAC1C,KAAK,UAAU;EACf,OAAO;CACT;CAEA,WAAkB,QAAgC;EAChD,KAAK,SAAS;EACd,OAAO;CACT;CAEA,MAAa,QAA0C;EACrD,OAAO,KAAK,QAAQ,6BAA6B;EAEjD,MAAM,eACJ,KAAK,SAAS,KAAK,aAAa,eAAe;EACjD,IAAI,iBAAiB,cACnB,OACE,KAAK,YACL,sDACF;EAIF,MAAM,UAAU,KAAK,KAAK,WAAW,GAAG,SAAS;EACjD,OAAO,GAAG,WAAW,OAAO,GAAG,6BAA6B,SAAS;EAGrE,MAAM,WAAW,KAAK,KAAK,SAAS,WAAW;EAC/C,MAAM,UAAU,KAAK,KAAK,SAAS,UAAU;EAE7C,MAAM,cAAc,GAAG,WAAW,QAAQ;EAC1C,MAAM,aAAa,GAAG,WAAW,OAAO;EAExC,IAAI,CAAC,eAAe,CAAC,YACnB,MAAM,IAAI,MAAM,kBAAkB,SAAS,MAAM,SAAS;EAG5D,MAAM,QAAQ,cAAc,wBAAwB;EAGpD,MAAM,cAAc,mBAAmB,mBAAmB;EAC1D,IAAI,CAAC,aACH,MAAM,IAAI,MACR,2JAEF;EAEF,MAAM,UAAU,KAAK,QAAQ,WAAW;EAExC,MAAM,QAAQ,CACZ;GAAE,QAAQ;GAAS,QAAQ;EAAY,GACvC;GAAE,QAAQ;GAAS,QAAQ;EAAyB,CACtD;EAEA,MAAM,MAA8B;GAClC,QAAQ,KAAK;GACb,MAAM;GACN,MAAM,OAAO,KAAK,IAAI;EACxB;EACA,IAAI,iBAAiB,gBAAgB,KAAK,YACxC,IAAI,aAAa,KAAK;EAGxB,MAAM,KAAK,IAAI,iBAAiB,KAAK,SAAS,CAAC,CAC5C,eAAe,MAAM,CAAC,CACtB,eAAe,KAAK,CAAC,CACrB,iBAAiB,KAAK,IAAI,CAAC,CAC3B,gBAAgB,GAAG,CAAC,CACpB,WAAW,KAAK,MAAM,CAAC,CACvB,YAAY,CAAC,QAAQ,KAAK,CAAC;EAE9B,IAAI,KAAK,SAAS,GAAG,YAAY,KAAK,OAAO;EAG7C,OAAO,IAAI,wBAAwB,MADb,GAAG,MAAM,GACa,KAAK,IAAI;CACvD;AACF;AAEA,IAAa,0BAAb,cAA6C,yBAAyB;CAGjD;CAFnB,YACE,SACA,cACA;EACA,MAAM,OAAO;EAFI,KAAA,eAAA;CAGnB;CACA,cAAqB;EACnB,OAAO,GAAG,KAAK,QAAQ,EAAE,GAAG,KAAK,cAAc,KAAK,YAAY;CAClE;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sebspark/test-iap",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.28",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.mjs",
|
|
@@ -21,22 +21,27 @@
|
|
|
21
21
|
"test": "vitest run --passWithNoTests --coverage",
|
|
22
22
|
"pretest:e2e": "yarn build",
|
|
23
23
|
"test:e2e": "vitest --config vitest.config.e2e.ts --run",
|
|
24
|
-
"typecheck": "vitest --typecheck.only --passWithNoTests"
|
|
24
|
+
"typecheck": "vitest --typecheck.only --passWithNoTests --run"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"jose": "6.2.
|
|
27
|
+
"jose": "6.2.12",
|
|
28
28
|
"testcontainers": "12.1.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
+
"@biomejs/biome": "2.5.14",
|
|
32
|
+
"@sebspark/tsconfig": "*",
|
|
31
33
|
"@types/ws": "8.18.1",
|
|
32
34
|
"nock": "14.0.17",
|
|
33
|
-
"
|
|
35
|
+
"typescript": "7.0.2",
|
|
36
|
+
"vite": "8.3.0",
|
|
37
|
+
"vitest": "5.0.1",
|
|
38
|
+
"ws": "8.21.3"
|
|
34
39
|
},
|
|
35
40
|
"resolutions": {
|
|
36
|
-
"protobufjs": "8.
|
|
41
|
+
"protobufjs": "8.8.0"
|
|
37
42
|
},
|
|
38
43
|
"repository": {
|
|
39
44
|
"type": "git",
|
|
40
45
|
"url": "https://github.com/seb-oss/Spark-packages.git"
|
|
41
46
|
}
|
|
42
|
-
}
|
|
47
|
+
}
|