@grafserv/persisted 0.0.0-beta.13 → 0.0.0-beta.14
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 +20 -0
- package/README.md +1 -2
- package/dist/index.d.ts +75 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +0 -74
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @grafserv/persisted
|
|
2
2
|
|
|
3
|
+
## 0.0.0-beta.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1877](https://github.com/graphile/crystal/pull/1877)
|
|
8
|
+
[`8a0cdb95f`](https://github.com/graphile/crystal/commit/8a0cdb95f200b28b0ea1ab5caa12b23dce5f374f)
|
|
9
|
+
Thanks [@benjie](https://github.com/benjie)! - Move 'declare global' out of
|
|
10
|
+
'interfaces.ts' and into 'index.ts' or equivalent. Should make TypeScript more
|
|
11
|
+
aware of these types.
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
[[`3fdc2bce4`](https://github.com/graphile/crystal/commit/3fdc2bce42418773f808c5b8309dfb361cd95ce9),
|
|
14
|
+
[`aeef362b5`](https://github.com/graphile/crystal/commit/aeef362b5744816f01e4a6f714bbd77f92332bc5),
|
|
15
|
+
[`8a76db07f`](https://github.com/graphile/crystal/commit/8a76db07f4c110cecc6225504f9a05ccbcbc7b92),
|
|
16
|
+
[`8a0cdb95f`](https://github.com/graphile/crystal/commit/8a0cdb95f200b28b0ea1ab5caa12b23dce5f374f),
|
|
17
|
+
[`995e25035`](https://github.com/graphile/crystal/commit/995e250352217fdf8f036b8ed6cad3fab520817f),
|
|
18
|
+
[`1c9f1c0ed`](https://github.com/graphile/crystal/commit/1c9f1c0edf4e621a5b6345d3a41527a18143c6ae)]:
|
|
19
|
+
- grafast@0.1.1-beta.2
|
|
20
|
+
- graphile-config@0.0.1-beta.5
|
|
21
|
+
- grafserv@0.1.1-beta.4
|
|
22
|
+
|
|
3
23
|
## 0.0.0-beta.13
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -33,9 +33,8 @@ And please give some love to our featured sponsors 🤩:
|
|
|
33
33
|
<td align="center"><a href="https://www.the-guild.dev/"><img src="https://graphile.org/images/sponsors/theguild.png" width="90" height="90" alt="The Guild" /><br />The Guild</a> *</td>
|
|
34
34
|
<td align="center"><a href="https://dovetailapp.com/"><img src="https://graphile.org/images/sponsors/dovetail.png" width="90" height="90" alt="Dovetail" /><br />Dovetail</a> *</td>
|
|
35
35
|
<td align="center"><a href="https://www.netflix.com/"><img src="https://graphile.org/images/sponsors/Netflix.png" width="90" height="90" alt="Netflix" /><br />Netflix</a> *</td>
|
|
36
|
-
<td align="center"><a href=""><img src="https://graphile.org/images/sponsors/chadf.png" width="90" height="90" alt="Chad Furman" /><br />Chad Furman</a> *</td>
|
|
37
|
-
</tr><tr>
|
|
38
36
|
<td align="center"><a href="https://stellate.co/"><img src="https://graphile.org/images/sponsors/Stellate.png" width="90" height="90" alt="Stellate" /><br />Stellate</a> *</td>
|
|
37
|
+
</tr><tr>
|
|
39
38
|
<td align="center"><a href="https://www.accenture.com/"><img src="https://graphile.org/images/sponsors/accenture.svg" width="90" height="90" alt="Accenture" /><br />Accenture</a> *</td>
|
|
40
39
|
<td align="center"><a href="https://microteam.io/"><img src="https://graphile.org/images/sponsors/micro.png" width="90" height="90" alt="We Love Micro" /><br />We Love Micro</a> *</td>
|
|
41
40
|
</tr></table>
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,79 @@
|
|
|
1
|
+
import type { ParsedGraphQLBody, ProcessGraphQLRequestBodyEvent } from "grafserv";
|
|
1
2
|
export type { PersistedOperationGetter } from "./interfaces.js";
|
|
3
|
+
import type { PersistedOperationGetter } from "./interfaces.js";
|
|
2
4
|
declare const PersistedPlugin: GraphileConfig.Plugin;
|
|
3
5
|
export default PersistedPlugin;
|
|
6
|
+
declare global {
|
|
7
|
+
namespace GraphileConfig {
|
|
8
|
+
interface GrafservOptions {
|
|
9
|
+
/**
|
|
10
|
+
* This function will be passed a GraphQL request object (normally
|
|
11
|
+
* `{query: string, variables?: any, operationName?: string, extensions?: any}`,
|
|
12
|
+
* but in the case of persisted operations it likely won't have a `query`
|
|
13
|
+
* property), and must extract the hash to use to identify the persisted
|
|
14
|
+
* operation. For Apollo Client, this might be something like:
|
|
15
|
+
* `request?.extensions?.persistedQuery?.sha256Hash`; for Relay something
|
|
16
|
+
* like: `request?.documentId`.
|
|
17
|
+
*/
|
|
18
|
+
hashFromPayload?(request: ParsedGraphQLBody): string | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* We can read persisted operations from a folder (they must be named
|
|
21
|
+
* `<hash>.graphql`). When used in this way, the first request for a hash
|
|
22
|
+
* will read the file, and then the result will be cached such that the
|
|
23
|
+
* **filesystem read** will only impact the first use of that hash. We
|
|
24
|
+
* periodically scan the folder for new files, requests for hashes that
|
|
25
|
+
* were not present in our last scan of the folder will be rejected to
|
|
26
|
+
* mitigate denial of service attacks asking for non-existent hashes.
|
|
27
|
+
*/
|
|
28
|
+
persistedOperationsDirectory?: string;
|
|
29
|
+
/**
|
|
30
|
+
* How many milliseconds should we leave it between scans of the persisted
|
|
31
|
+
* operations folder, checking for new files?
|
|
32
|
+
*
|
|
33
|
+
* Set this to the string "watch" to use `fs.watch` to monitor for changes. [EXPERIMENTAL].
|
|
34
|
+
*
|
|
35
|
+
* Set to `-1` to disable.
|
|
36
|
+
*
|
|
37
|
+
* Default: -1
|
|
38
|
+
*/
|
|
39
|
+
persistedOperationsDirectoryScanInterval?: number | "watch";
|
|
40
|
+
/**
|
|
41
|
+
* An optional string-string key-value object defining the persisted
|
|
42
|
+
* operations, where the keys are the hashes, and the values are the
|
|
43
|
+
* operation document strings to use.
|
|
44
|
+
*/
|
|
45
|
+
persistedOperations?: {
|
|
46
|
+
[hash: string]: string;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* If your known persisted operations may change over time, or you'd rather
|
|
50
|
+
* load them on demand, you may supply this function. Note this function is
|
|
51
|
+
* **performance critical** so you should use caching to improve
|
|
52
|
+
* performance of any follow-up requests for the same hash.
|
|
53
|
+
*/
|
|
54
|
+
persistedOperationsGetter?: PersistedOperationGetter;
|
|
55
|
+
/**
|
|
56
|
+
* There are situations where you may want to allow arbitrary operations
|
|
57
|
+
* (for example using GraphiQL in development, or allowing an admin to
|
|
58
|
+
* make arbitrary requests in production) whilst enforcing Persisted
|
|
59
|
+
* Operations for the application and non-admin users. This function
|
|
60
|
+
* allows you to determine under which circumstances persisted operations
|
|
61
|
+
* may be bypassed.
|
|
62
|
+
*
|
|
63
|
+
* IMPORTANT: this function must not throw!
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
*
|
|
67
|
+
* ```
|
|
68
|
+
* app.use(postgraphile(DATABASE_URL, SCHEMAS, {
|
|
69
|
+
* allowUnpersistedOperation(event) {
|
|
70
|
+
* return process.env.NODE_ENV === "development" && event.request?.getHeader('referer')?.endsWith("/graphiql");
|
|
71
|
+
* }
|
|
72
|
+
* });
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
allowUnpersistedOperation?: boolean | ((event: ProcessGraphQLRequestBodyEvent) => boolean);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
4
79
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,iBAAiB,EACjB,8BAA8B,EAC/B,MAAM,UAAU,CAAC;AAGlB,YAAY,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAGhE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAGhE,QAAA,MAAM,eAAe,EAAE,cAAc,CAAC,MA8CrC,CAAC;AAEF,eAAe,eAAe,CAAC;AAoR/B,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,cAAc,CAAC;QACvB,UAAU,eAAe;YACvB;;;;;;;;eAQG;YACH,eAAe,CAAC,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,GAAG,SAAS,CAAC;YAEjE;;;;;;;;eAQG;YACH,4BAA4B,CAAC,EAAE,MAAM,CAAC;YAEtC;;;;;;;;;eASG;YACH,wCAAwC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;YAE5D;;;;eAIG;YACH,mBAAmB,CAAC,EAAE;gBAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;aAAE,CAAC;YAEjD;;;;;eAKG;YACH,yBAAyB,CAAC,EAAE,wBAAwB,CAAC;YAErD;;;;;;;;;;;;;;;;;;;eAmBG;YACH,yBAAyB,CAAC,EACtB,OAAO,GACP,CAAC,CAAC,KAAK,EAAE,8BAA8B,KAAK,OAAO,CAAC,CAAC;SAC1D;KACF;CACF"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,wEAAmC;AAGnC,qCAAoC;AAQpC,gEAAgC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,wEAAmC;AAGnC,qCAAoC;AAQpC,gEAAgC;AAGhC,6CAAuC;AAEvC,MAAM,eAAe,GAA0B;IAC7C,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,0CAA0C;IACvD,OAAO,EAAP,oBAAO;IAEP,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,IAAI;QACF,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,sBAAsB,CAAC;QAC1E,MAAM,IAAI,GAAG,eAAe,CAAC,OAAyB,CAAC,CAAC;QACxD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;YAC5B,IAAI,yBAAyB,IAAI,OAAO,OAAO,EAAE,KAAK,KAAK,QAAQ,EAAE;gBACnE,OAAO,OAAO,CAAC,KAAK,CAAC;aACtB;YAED,MAAM,IAAI,KAAK,CACb,qEAAqE,CACtE,CAAC;SACH;QACD,MAAM,MAAM,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAC1C,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;KACrB;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,KAAK,CAAC,gDAAgD,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;QAE5E,2EAA2E;QAC3E,6BAA6B;QAC7B,OAAO,IAAI,CAAC;KACb;AACH,CAAC"}
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -1,81 +1,7 @@
|
|
|
1
1
|
import type { PromiseOrDirect } from "grafast";
|
|
2
|
-
import type { ParsedGraphQLBody, ProcessGraphQLRequestBodyEvent } from "grafserv";
|
|
3
2
|
/**
|
|
4
3
|
* Given a persisted operation hash, return the associated GraphQL operation
|
|
5
4
|
* document.
|
|
6
5
|
*/
|
|
7
6
|
export type PersistedOperationGetter = (hash: string) => PromiseOrDirect<string>;
|
|
8
|
-
declare global {
|
|
9
|
-
namespace GraphileConfig {
|
|
10
|
-
interface GrafservOptions {
|
|
11
|
-
/**
|
|
12
|
-
* This function will be passed a GraphQL request object (normally
|
|
13
|
-
* `{query: string, variables?: any, operationName?: string, extensions?: any}`,
|
|
14
|
-
* but in the case of persisted operations it likely won't have a `query`
|
|
15
|
-
* property), and must extract the hash to use to identify the persisted
|
|
16
|
-
* operation. For Apollo Client, this might be something like:
|
|
17
|
-
* `request?.extensions?.persistedQuery?.sha256Hash`; for Relay something
|
|
18
|
-
* like: `request?.documentId`.
|
|
19
|
-
*/
|
|
20
|
-
hashFromPayload?(request: ParsedGraphQLBody): string | undefined;
|
|
21
|
-
/**
|
|
22
|
-
* We can read persisted operations from a folder (they must be named
|
|
23
|
-
* `<hash>.graphql`). When used in this way, the first request for a hash
|
|
24
|
-
* will read the file, and then the result will be cached such that the
|
|
25
|
-
* **filesystem read** will only impact the first use of that hash. We
|
|
26
|
-
* periodically scan the folder for new files, requests for hashes that
|
|
27
|
-
* were not present in our last scan of the folder will be rejected to
|
|
28
|
-
* mitigate denial of service attacks asking for non-existent hashes.
|
|
29
|
-
*/
|
|
30
|
-
persistedOperationsDirectory?: string;
|
|
31
|
-
/**
|
|
32
|
-
* How many milliseconds should we leave it between scans of the persisted
|
|
33
|
-
* operations folder, checking for new files?
|
|
34
|
-
*
|
|
35
|
-
* Set this to the string "watch" to use `fs.watch` to monitor for changes. [EXPERIMENTAL].
|
|
36
|
-
*
|
|
37
|
-
* Set to `-1` to disable.
|
|
38
|
-
*
|
|
39
|
-
* Default: -1
|
|
40
|
-
*/
|
|
41
|
-
persistedOperationsDirectoryScanInterval?: number | "watch";
|
|
42
|
-
/**
|
|
43
|
-
* An optional string-string key-value object defining the persisted
|
|
44
|
-
* operations, where the keys are the hashes, and the values are the
|
|
45
|
-
* operation document strings to use.
|
|
46
|
-
*/
|
|
47
|
-
persistedOperations?: {
|
|
48
|
-
[hash: string]: string;
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* If your known persisted operations may change over time, or you'd rather
|
|
52
|
-
* load them on demand, you may supply this function. Note this function is
|
|
53
|
-
* **performance critical** so you should use caching to improve
|
|
54
|
-
* performance of any follow-up requests for the same hash.
|
|
55
|
-
*/
|
|
56
|
-
persistedOperationsGetter?: PersistedOperationGetter;
|
|
57
|
-
/**
|
|
58
|
-
* There are situations where you may want to allow arbitrary operations
|
|
59
|
-
* (for example using GraphiQL in development, or allowing an admin to
|
|
60
|
-
* make arbitrary requests in production) whilst enforcing Persisted
|
|
61
|
-
* Operations for the application and non-admin users. This function
|
|
62
|
-
* allows you to determine under which circumstances persisted operations
|
|
63
|
-
* may be bypassed.
|
|
64
|
-
*
|
|
65
|
-
* IMPORTANT: this function must not throw!
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
*
|
|
69
|
-
* ```
|
|
70
|
-
* app.use(postgraphile(DATABASE_URL, SCHEMAS, {
|
|
71
|
-
* allowUnpersistedOperation(event) {
|
|
72
|
-
* return process.env.NODE_ENV === "development" && event.request?.getHeader('referer')?.endsWith("/graphiql");
|
|
73
|
-
* }
|
|
74
|
-
* });
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
allowUnpersistedOperation?: boolean | ((event: ProcessGraphQLRequestBodyEvent) => boolean);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
7
|
//# sourceMappingURL=interfaces.d.ts.map
|
package/dist/interfaces.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG/C;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG,CACrC,IAAI,EAAE,MAAM,KACT,eAAe,CAAC,MAAM,CAAC,CAAC"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "0.0.0-beta.
|
|
1
|
+
export declare const version = "0.0.0-beta.14";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafserv/persisted",
|
|
3
|
-
"version": "0.0.0-beta.
|
|
3
|
+
"version": "0.0.0-beta.14",
|
|
4
4
|
"description": "Persisted operations support for Grafserv",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"node": ">=16.10"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"grafast": "^0.1.1-beta.
|
|
50
|
-
"grafserv": "^0.1.1-beta.
|
|
51
|
-
"graphile-config": "^0.0.1-beta.
|
|
49
|
+
"grafast": "^0.1.1-beta.2",
|
|
50
|
+
"grafserv": "^0.1.1-beta.4",
|
|
51
|
+
"graphile-config": "^0.0.1-beta.5"
|
|
52
52
|
},
|
|
53
53
|
"peerDependenciesMeta": {
|
|
54
54
|
"graphile-config": {
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"grafast": "^0.1.1-beta.
|
|
60
|
-
"grafserv": "^0.1.1-beta.
|
|
61
|
-
"graphile-config": "^0.0.1-beta.
|
|
59
|
+
"grafast": "^0.1.1-beta.2",
|
|
60
|
+
"grafserv": "^0.1.1-beta.4",
|
|
61
|
+
"graphile-config": "^0.0.1-beta.5",
|
|
62
62
|
"jest": "^29.6.4",
|
|
63
63
|
"jest-serializer-graphql-schema": "^5.0.0-beta.3",
|
|
64
64
|
"ts-node": "^10.9.1",
|