graphql-http 1.5.0 → 1.6.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/lib/audits/server.js +40 -0
- package/lib/audits/server.mjs +40 -0
- package/package.json +8 -5
- package/umd/graphql-http.min.js.gz +0 -0
package/lib/audits/server.js
CHANGED
|
@@ -322,6 +322,17 @@ function serverAudits(opts) {
|
|
|
322
322
|
});
|
|
323
323
|
(0, utils_1.assert)('Status code', res.status).toBe(400);
|
|
324
324
|
}),
|
|
325
|
+
(0, utils_1.audit)('SHOULD not contain the data entry on JSON parsing failure when accepting application/graphql-response+json', async () => {
|
|
326
|
+
const res = await fetchFn(opts.url, {
|
|
327
|
+
method: 'POST',
|
|
328
|
+
headers: {
|
|
329
|
+
'content-type': 'application/json',
|
|
330
|
+
accept: 'application/graphql-response+json',
|
|
331
|
+
},
|
|
332
|
+
body: '{ "not a JSON',
|
|
333
|
+
});
|
|
334
|
+
(0, utils_1.assert)('Data entry', (await res.json()).data).toBe(undefined);
|
|
335
|
+
}),
|
|
325
336
|
(0, utils_1.audit)('MUST use 4xx or 5xx status codes if parameters are invalid when accepting application/graphql-response+json', async () => {
|
|
326
337
|
const url = new URL(opts.url);
|
|
327
338
|
url.searchParams.set('qeury' /* typo */, '{ __typename }');
|
|
@@ -341,6 +352,15 @@ function serverAudits(opts) {
|
|
|
341
352
|
});
|
|
342
353
|
(0, utils_1.assert)('Status code', res.status).toBe(400);
|
|
343
354
|
}),
|
|
355
|
+
(0, utils_1.audit)('SHOULD not contain the data entry if parameters are invalid when accepting application/graphql-response+json', async () => {
|
|
356
|
+
const url = new URL(opts.url);
|
|
357
|
+
url.searchParams.set('qeury' /* typo */, '{ __typename }');
|
|
358
|
+
const res = await fetchFn(url.toString(), {
|
|
359
|
+
method: 'GET',
|
|
360
|
+
headers: { accept: 'application/graphql-response+json' },
|
|
361
|
+
});
|
|
362
|
+
(0, utils_1.assert)('Data entry', (await res.json()).data).toBe(undefined);
|
|
363
|
+
}),
|
|
344
364
|
(0, utils_1.audit)('MUST use 4xx or 5xx status codes on document parsing failure when accepting application/graphql-response+json', async () => {
|
|
345
365
|
const url = new URL(opts.url);
|
|
346
366
|
url.searchParams.set('query', '{');
|
|
@@ -360,6 +380,15 @@ function serverAudits(opts) {
|
|
|
360
380
|
});
|
|
361
381
|
(0, utils_1.assert)('Status code', res.status).toBe(400);
|
|
362
382
|
}),
|
|
383
|
+
(0, utils_1.audit)('SHOULD not contain the data entry on document parsing failure when accepting application/graphql-response+json', async () => {
|
|
384
|
+
const url = new URL(opts.url);
|
|
385
|
+
url.searchParams.set('query', '{');
|
|
386
|
+
const res = await fetchFn(url.toString(), {
|
|
387
|
+
method: 'GET',
|
|
388
|
+
headers: { accept: 'application/graphql-response+json' },
|
|
389
|
+
});
|
|
390
|
+
(0, utils_1.assert)('Data entry', (await res.json()).data).toBe(undefined);
|
|
391
|
+
}),
|
|
363
392
|
(0, utils_1.audit)('MUST use 4xx or 5xx status codes on document validation failure when accepting application/graphql-response+json', async () => {
|
|
364
393
|
const url = new URL(opts.url);
|
|
365
394
|
url.searchParams.set('query', '{ 8f31403dfe404bccbb0e835f2629c6a7 }'); // making sure the field doesnt exist
|
|
@@ -379,6 +408,17 @@ function serverAudits(opts) {
|
|
|
379
408
|
});
|
|
380
409
|
(0, utils_1.assert)('Status code', res.status).toBe(400);
|
|
381
410
|
}),
|
|
411
|
+
(0, utils_1.audit)('SHOULD not contain the data entry on document validation failure when accepting application/graphql-response+json', async () => {
|
|
412
|
+
const url = new URL(opts.url);
|
|
413
|
+
url.searchParams.set('query', '{ 8f31403dfe404bccbb0e835f2629c6a7 }'); // making sure the field doesnt exist
|
|
414
|
+
const res = await fetchFn(url.toString(), {
|
|
415
|
+
method: 'GET',
|
|
416
|
+
headers: { accept: 'application/graphql-response+json' },
|
|
417
|
+
});
|
|
418
|
+
(0, utils_1.assert)('Data entry', (await res.json()).data).toBe(undefined);
|
|
419
|
+
}),
|
|
420
|
+
// TODO: how to fail and have the data entry?
|
|
421
|
+
// audit('MUST use 2xx status code if response contains the data entry and it is not null when accepting application/graphql-response+json'),
|
|
382
422
|
// TODO: how to make an unauthorized request?
|
|
383
423
|
// https://graphql.github.io/graphql-over-http/draft/#sel-EANNNDTAAEVBAAqqc
|
|
384
424
|
// audit('SHOULD use 401 or 403 status codes when the request is not permitted')
|
package/lib/audits/server.mjs
CHANGED
|
@@ -319,6 +319,17 @@ export function serverAudits(opts) {
|
|
|
319
319
|
});
|
|
320
320
|
assert('Status code', res.status).toBe(400);
|
|
321
321
|
}),
|
|
322
|
+
audit('SHOULD not contain the data entry on JSON parsing failure when accepting application/graphql-response+json', async () => {
|
|
323
|
+
const res = await fetchFn(opts.url, {
|
|
324
|
+
method: 'POST',
|
|
325
|
+
headers: {
|
|
326
|
+
'content-type': 'application/json',
|
|
327
|
+
accept: 'application/graphql-response+json',
|
|
328
|
+
},
|
|
329
|
+
body: '{ "not a JSON',
|
|
330
|
+
});
|
|
331
|
+
assert('Data entry', (await res.json()).data).toBe(undefined);
|
|
332
|
+
}),
|
|
322
333
|
audit('MUST use 4xx or 5xx status codes if parameters are invalid when accepting application/graphql-response+json', async () => {
|
|
323
334
|
const url = new URL(opts.url);
|
|
324
335
|
url.searchParams.set('qeury' /* typo */, '{ __typename }');
|
|
@@ -338,6 +349,15 @@ export function serverAudits(opts) {
|
|
|
338
349
|
});
|
|
339
350
|
assert('Status code', res.status).toBe(400);
|
|
340
351
|
}),
|
|
352
|
+
audit('SHOULD not contain the data entry if parameters are invalid when accepting application/graphql-response+json', async () => {
|
|
353
|
+
const url = new URL(opts.url);
|
|
354
|
+
url.searchParams.set('qeury' /* typo */, '{ __typename }');
|
|
355
|
+
const res = await fetchFn(url.toString(), {
|
|
356
|
+
method: 'GET',
|
|
357
|
+
headers: { accept: 'application/graphql-response+json' },
|
|
358
|
+
});
|
|
359
|
+
assert('Data entry', (await res.json()).data).toBe(undefined);
|
|
360
|
+
}),
|
|
341
361
|
audit('MUST use 4xx or 5xx status codes on document parsing failure when accepting application/graphql-response+json', async () => {
|
|
342
362
|
const url = new URL(opts.url);
|
|
343
363
|
url.searchParams.set('query', '{');
|
|
@@ -357,6 +377,15 @@ export function serverAudits(opts) {
|
|
|
357
377
|
});
|
|
358
378
|
assert('Status code', res.status).toBe(400);
|
|
359
379
|
}),
|
|
380
|
+
audit('SHOULD not contain the data entry on document parsing failure when accepting application/graphql-response+json', async () => {
|
|
381
|
+
const url = new URL(opts.url);
|
|
382
|
+
url.searchParams.set('query', '{');
|
|
383
|
+
const res = await fetchFn(url.toString(), {
|
|
384
|
+
method: 'GET',
|
|
385
|
+
headers: { accept: 'application/graphql-response+json' },
|
|
386
|
+
});
|
|
387
|
+
assert('Data entry', (await res.json()).data).toBe(undefined);
|
|
388
|
+
}),
|
|
360
389
|
audit('MUST use 4xx or 5xx status codes on document validation failure when accepting application/graphql-response+json', async () => {
|
|
361
390
|
const url = new URL(opts.url);
|
|
362
391
|
url.searchParams.set('query', '{ 8f31403dfe404bccbb0e835f2629c6a7 }'); // making sure the field doesnt exist
|
|
@@ -376,6 +405,17 @@ export function serverAudits(opts) {
|
|
|
376
405
|
});
|
|
377
406
|
assert('Status code', res.status).toBe(400);
|
|
378
407
|
}),
|
|
408
|
+
audit('SHOULD not contain the data entry on document validation failure when accepting application/graphql-response+json', async () => {
|
|
409
|
+
const url = new URL(opts.url);
|
|
410
|
+
url.searchParams.set('query', '{ 8f31403dfe404bccbb0e835f2629c6a7 }'); // making sure the field doesnt exist
|
|
411
|
+
const res = await fetchFn(url.toString(), {
|
|
412
|
+
method: 'GET',
|
|
413
|
+
headers: { accept: 'application/graphql-response+json' },
|
|
414
|
+
});
|
|
415
|
+
assert('Data entry', (await res.json()).data).toBe(undefined);
|
|
416
|
+
}),
|
|
417
|
+
// TODO: how to fail and have the data entry?
|
|
418
|
+
// audit('MUST use 2xx status code if response contains the data entry and it is not null when accepting application/graphql-response+json'),
|
|
379
419
|
// TODO: how to make an unauthorized request?
|
|
380
420
|
// https://graphql.github.io/graphql-over-http/draft/#sel-EANNNDTAAEVBAAqqc
|
|
381
421
|
// audit('SHOULD use 401 or 403 status codes when the request is not permitted')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graphql-http",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Simple, pluggable, zero-dependency, GraphQL over HTTP Protocol compliant server and client",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"graphql",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"engines": {
|
|
25
25
|
"node": ">=12"
|
|
26
26
|
},
|
|
27
|
-
"packageManager": "yarn@3.2.
|
|
27
|
+
"packageManager": "yarn@3.2.3",
|
|
28
28
|
"main": "lib/index.js",
|
|
29
29
|
"module": "lib/index.mjs",
|
|
30
30
|
"browser": "umd/graphql-http.js",
|
|
@@ -88,12 +88,15 @@
|
|
|
88
88
|
"node-fetch": "^3.2.10",
|
|
89
89
|
"prettier": "^2.7.1",
|
|
90
90
|
"replacestream": "^4.0.3",
|
|
91
|
-
"rollup": "^2.
|
|
91
|
+
"rollup": "^2.79.0",
|
|
92
92
|
"rollup-plugin-terser": "^7.0.2",
|
|
93
93
|
"semantic-release": "^19.0.5",
|
|
94
94
|
"tslib": "^2.4.0",
|
|
95
|
-
"typedoc": "^0.23.
|
|
96
|
-
"typedoc-plugin-markdown": "^3.13.
|
|
95
|
+
"typedoc": "^0.23.13",
|
|
96
|
+
"typedoc-plugin-markdown": "^3.13.5",
|
|
97
97
|
"typescript": "^4.8.2"
|
|
98
|
+
},
|
|
99
|
+
"resolutions": {
|
|
100
|
+
"npm/libnpmversion": "^3.0.6"
|
|
98
101
|
}
|
|
99
102
|
}
|
|
Binary file
|