Skip to content

Commit 7fe2de1

Browse files
authored
Add --unsafely-ignore-certificate-errors flag (#52)
* Add --unsafely-ignore-certificate-errors flag * Update changelog and version
1 parent 04e5c5f commit 7fe2de1

File tree

4 files changed

+61
-1
lines changed

4 files changed

+61
-1
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## v0.12.0
4+
5+
### Date: 4/12/2024
6+
7+
### Changes:
8+
9+
- Added `unsafelyIgnoreCertificateErrors` option to DenoWorker to let users skip
10+
SSL verification.
11+
312
## v0.11.0
413

514
### Date: 4/01/2024

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "deno-vm",
3-
"version": "0.11.0",
3+
"version": "0.12.0",
44
"description": "A VM module that provides a secure runtime environment via Deno.",
55
"main": "./dist/cjs/index.js",
66
"types": "./dist/typings/index.d.ts",

src/DenoWorker.spec.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,45 @@ describe('DenoWorker', () => {
307307
});
308308
});
309309

310+
describe('unsafelyIgnoreCertificateErrors', async () => {
311+
afterEach(() => {
312+
jest.clearAllMocks();
313+
});
314+
315+
it('supports the --unsafely-ignore-certificate-errors flag', async () => {
316+
const spawnSpy = jest.spyOn(child_process, 'spawn');
317+
318+
worker = new DenoWorker(
319+
`self.onmessage = (e) => {
320+
if (e.data.type === 'echo') {
321+
self.postMessage('hi');
322+
}
323+
};`,
324+
{
325+
unsafelyIgnoreCertificateErrors: true,
326+
}
327+
);
328+
329+
let resolve: any;
330+
let promise = new Promise((res, rej) => {
331+
resolve = res;
332+
});
333+
worker.onmessage = (e) => {
334+
resolve(e);
335+
};
336+
337+
worker.postMessage({
338+
type: 'echo',
339+
});
340+
341+
expect(await promise).toEqual({ data: 'hi' });
342+
343+
const call = spawnSpy.mock.calls[0];
344+
const [_deno, args] = call;
345+
expect(args).toContain(`--unsafely-ignore-certificate-errors`);
346+
});
347+
});
348+
310349
describe('location', async () => {
311350
afterEach(() => {
312351
jest.clearAllMocks();

src/DenoWorker.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ export interface DenoWorkerOptions {
159159
*/
160160
denoNoCheck: boolean;
161161

162+
/**
163+
* Allow Deno to make requests to hosts with certificate
164+
* errors.
165+
*/
166+
unsafelyIgnoreCertificateErrors: boolean;
167+
162168
/**
163169
* Specify the --location flag, which defines location.href.
164170
* This must be a valid URL if provided.
@@ -287,6 +293,7 @@ export class DenoWorker {
287293
denoLockFilePath: '',
288294
denoCachedOnly: false,
289295
denoNoCheck: false,
296+
unsafelyIgnoreCertificateErrors: false,
290297
spawnOptions: {},
291298
},
292299
options || {}
@@ -398,6 +405,11 @@ export class DenoWorker {
398405
}
399406
addOption(runArgs, '--cached-only', this._options.denoCachedOnly);
400407
addOption(runArgs, '--no-check', this._options.denoNoCheck);
408+
addOption(
409+
runArgs,
410+
'--unsafely-ignore-certificate-errors',
411+
this._options.unsafelyIgnoreCertificateErrors
412+
);
401413
if (this._options.location) {
402414
addOption(runArgs, '--location', [this._options.location]);
403415
}

0 commit comments

Comments
 (0)